2 ms·
I've pointed this problem out early last year to libsodium, but they chose to ignore it. My memset_s does a full memory barrier, but no others do. Esp. the so-
by rurban 7y ago
I've pointed this problem out early last year to libsodium, but they chose to ignore it.
My memset_s does a full memory barrier, but no others do. Esp. the so-called "secure" libs.
- shakna 7y ago> I've pointed this problem out early last year to libsodium, but they chose to ignore it. I'm guessing you're referencing this [0]. libsodium's response that your suggestion wasn't enough seems reasonable, as does their response: > `sodium_memzero` should be considered as best-effort, with reasonable tradeoffs. The documentation for memzero [1] doesn't read like it works 100% of the time, no matter what. It reads like there are tradeoffs involved. > My memset_s does a full memory barrier, but no others do. Esp. the so-called "secure" libs. Your memset_s also doesn't work on big endian, whilst "the so-called 'secure' libs" often do. I'm fine with self-promotion, but don't disparage efforts that have a much larger surface that they deal with, simply because you disagree with the tradeoff they find acceptable. A one-liner isn't enough for that conversation. [0] https://github.com/jedisct1/libsodium/issues/802 https://github.com/jedisct1/libsodium/issues/802 [1] https://download.libsodium.org/doc/memory_management#zeroing-memory https://download.libsodium.org/doc/memory_management#zeroing...
- rurban 7y agoThe tradeoff they are talking about is leaving secrets in the cache, because mb(lb) is slow. This is not acceptable for security, only for performance. That time they had no idea about the upcoming cache exploits, they were only apparent to me. So who was right?
- shakna 7y ago> That time they had no idea about the upcoming cache exploits, they were only apparent to me. So who was right? I don't see anything that suggests you did have an idea about "upcoming cache exploits", so I'm afraid I can't say that you were. I saw you mentioning something that would help, but was nowhere near enough, to deal with Spectre, which was then dealt with by microcode, kernels and every other part of the software stack, making attacking libsodium with Spectre something that might not even be possible. > The tradeoff they are talking about is leaving secrets in the cache, because mb(lb) is slow. This is not acceptable for security, only for performance. Not entirely. The main reason is this one: > SPECTRE-like attacks can be conducted during all the time the secret is present, prior to zeroing. The required preconditions and the time window during which a full memory barrier could help, seem to be negligible compared to the actual lifetime of the secret.
- floodyberry- 7y agoWhich would be more difficult, reading the secret at some point before the memory was cleared, or reading it _after_ the memory was cleared, but _before_ the cache was overwritten?
- rurban 7y agoThe secrets stay in the cache much longer, and are rarely evicted to the heap at all.
- floodyberry- 7y agoCryptographic operations can take hundreds of thousands of cycles during which the values can be freely read. The cache will stay stale after the values have been cleared for _longer_ than that?
- rurban 7y agoAt least one of the 3 caches will stay much longer, yes. Esp. the L3. Throwing a tantrum because of 50 cycles for the mb is laughable. They should call it fast crypto, but not secure crypto.