5 ms·
Often this sort of leakage comes down to timing, you can infer what a person is doing by the amount of time it takes you to do something. In the simplest exampl
by steckerbrett 11y ago
Often this sort of leakage comes down to timing, you can infer what a person is doing by the amount of time it takes you to do something. In the simplest example (and only slightly related to the linked article), imagine we have an API end point that allows you to log in using a password. A naive implementation of authentication might look like this:
if ( password = "hunter2" ):
return True
This in a lot of cases will be vulnerable to a timing attack. If the user submits the password "huntducks" it will take the function momentarily longer to return than if they had submitted "whalehorn", due to the underlying comparison exiting at the first non-match. With a bit of trial and error they can deduce the password one character at a time by altering their guess to take longer and longer to execute. To avoid this security sensitive code needs to be time constant, which is a lot harder than you'd imagine.
Attacks like the author are performing are a lot more complicated and use tricks like coercing the victim into signing distinctive plaintexts, but the example also works for more complex systems like ECDSA where people can derive the signing key by just knowing how long it took.
- davnicwil 11y agoVery interesting, and something I'd never considered before. Instead of going to the effort of making the function run in a constant time, might adding a small random delay before it returns also mitigate against this type of attack?
- dustcoin 11y agoThe noise could be filtered out with enough samples, so this mitigation only increases the number of attempts required and does not prevent the attack.
- deleted 11y ago[deleted]
- deleted 11y ago[deleted]
- briholt 11y agoBest practice is to hash the password. This is good for a lot of reasons, one of which is that the time to compare hash("hunter") vs hash("hunter2") vs hash("hunter21") does not correlate in any meaningful way. https://en.wikipedia.org/wiki/Hash_function https://en.wikipedia.org/wiki/Hash_function
- Dylan16807 11y agoAnd it gets even worse than that, in certain environments the fact that it takes more energy to flip a transistor than to keep it on the same output can leak information. Noise technically mitigates, but it's like covering your unlocked safe with a cardboard box.