| ▲ | edoceo 9 hours ago | |||||||||||||
I'm curious about how GC languages handle crypto. Is it a risk that decrypted stuff or keys and things may be left in memory (heap?) before the next GC cycle? | ||||||||||||||
| ▲ | OhMeadhbh 9 hours ago | parent | next [-] | |||||||||||||
What we did with Java (J/SAFE) was to add explicit methods to zero out sensitive info. It was a bit of a PITA because Java's never had consistent semantics about when final(ize,ly) methods were called. Later we added code to track which objects were allocated, but no longer needed, which also wasn't much fun. Back in the Oak days Sun asked us (I was at RSADSI at the time) to review the language spec for security implications. Our big request was to add the "secure" storage specifier for data. The idea being a variable, const, whatever that was marked "secure" would be guaranteed not to be swapped out to disk (or one of a number of other system specific behaviors). But it was hard to find a concrete behavior that would work for all platforms they were targeting (mostly smaller systems at the time.) My coworker Bob Baldwin had an existing relationship with Bill Joy and James Gosling (I'm assuming as part of the MIT mafia) so he led the meetings. Joy's response (or maybe Goslings, can't remember anymore) was "Language extension requests should be made on a kidney. Preferably a human kidney. Preferably yours. That way you'll think long and hard about it and you sure as hell won't submit 2." | ||||||||||||||
| ▲ | FiloSottile 8 hours ago | parent | prev | next [-] | |||||||||||||
You might find this proposal and the upcoming runtime/secret package interesting. | ||||||||||||||
| ▲ | networked 4 hours ago | parent | prev | next [-] | |||||||||||||
I evaluated but didn't adopt https://github.com/awnumar/memguard in Go. No matter how well-implemented and reliable it is, I can't pass its secrets to https://github.com/FiloSottile/age. I assume all process memory may contain residual secrets. As a mitigation in a password manager and an encrypted file editor, I prevent process memory from being swapped to disk with https://pkg.go.dev/syscall#Mlockall. | ||||||||||||||
| ▲ | Thaxll 9 hours ago | parent | prev | next [-] | |||||||||||||
If you have access to the local machine no language will save you. | ||||||||||||||
| ||||||||||||||
| ▲ | alphazard 9 hours ago | parent | prev | next [-] | |||||||||||||
It can be, another risk it that a secret value is left on the stack, and is never overwritten because the stack doesn't get to that memory address again, so it's never overwritten or zerod. Go really just needs a few `crypto.Secret` values of various sizes, or maybe a generic type that could wrap arrays. Then the runtime can handle all the best practices, like a single place in memory, and aggressive zeroing of any copies, etc. | ||||||||||||||
| ||||||||||||||
| ▲ | gethly 4 hours ago | parent | prev [-] | |||||||||||||
clear([]byte) if you want to go to the extreme and clean your own memory. | ||||||||||||||