4 ms·
Timing attack, 6.66% faster
- squigs25 12y agoAnother reason to hash your passwords!
- homakov 12y agoIt has nothing to do with passwords and hashes. API keys are not hashed normally. And all kinds of signatures. It's about way you compare strings from params with secret strings
- tshadwell 12y agoPerhaps another reason to use a fixed time string equality function
- yeukhon 12y agoYou mean checking 123 == 1234 actually going through all 4 characters instead of immediate stop?
- mikeash 12y agoI believe it's OK to bail out early if the lengths aren't equal, but otherwise yes, you'd want e.g. 1234 == 1345 to continue to the end even though it's obvious from the second character that they aren't equal.
- bmm6o 12y agoBailing early reveals the information that the lengths are different. In most cases the attacker knows the length of the target string and so this test will never pass. You can probably imagine a scenario where the length isn't known and step 1 is to determine the target length.
- emidln 12y agoI can think of a couple examples where hashing passwords directly contributes to leaking information recoverable by examining timing (e.g. enumerating django privilege status for a site's users). Edit: not to say that you should store your password plaintext. Hashing (well, properly using a KDF) isn't a panacea.
- squigs25 12y agoEveryone who down voted this: 1) I know this would NEVEEERRRRRRR happen, but if there was a website that didn't hash a password, the timing attack would be applicable. 2) It worth mentioning that a timing attack can be frequently foiled if hashing is used on the server side. I.E. Google gives me an API key, stores the hash on there side. I send the API key to Google they hash it and ocmpare the hash to their stored hash. I think it's crazy how fat fingered people have become with the down vote trigger finger. I think it's 100% crazy to discus the timing attack without considering how it could be thwarted.
- tptacek 12y agoDoing 16 bits at a time instead of 8 isn't going to make Ruby string comparison timing tractable; the timing difference you're looking at is less than a nanosecond per byte, because Ruby's string comparison is essentially just C memcmp. That's below the noise floor even on a LAN.† Even for signals above the noise floor, ie, higher than the "WAN" threshold Crosby and Wallach worked out, actually performing these attacks is very difficult. Among other things, you'll probably need to goof around with your network drivers and write your own timer code. Timing attacks against simple string comparison might belong to a small class of attacks that get worse over time, not better, because networks do not get less noisy as fast as computers get faster and shrink the signal. Unfortunately, not all timing attacks devolve to simple string compare. Look for instance at the Lucky 13 attack on TLS; the distinction being profiled there isn't a single byte comparison, but rather entire invocations of a hash core function. † Here's a link to the most recent measurements I could find: http://twitter.com/tqbf/status/491607410537406465/photo/1 http://twitter.com/tqbf/status/491607410537406465/photo/1
- homakov 12y agoI didn't mean to claim "it will work just great" I claimed "it is supposed to be 6% more efficient of what we have now". In theory, this particular comparison attack is entirely based on amount of operations, and by making it 6% longer we make it 6% easier to detect, am I right? My point is 6% is quite a significant improvement and instead of using regular technique I see in blog posts everywhere on the Internet, we should mention the possibility of tree-like patterns. Furthermore, for [01] alphabet it is gonna be about 90% improvement. I'm hundred percent sure the technique was discovered by someone long time ago, but I'm confused I never saw that in casual articles (I read bunch of them recently).
- tptacek 12y agoIt's hard to find any articles about practical experiences with string comparison timing attacks over networks, probably because so many of the results of those experiments are going to be negative. There definitely are circumstances where it's a concern, and, worse yet, some of those circumstances happen below the language layer, so it's not enough to say "Ruby string comparison isn't exploitable"; depending on the runtime, things could be as bad as they were in Java. So it's still important to doc those flaws --- when they're meaningful --- but a lot of the time we set them "sev:low" or even "sev:info".
- anuragbiyani 12y agoA server can easily add an extra random wait to all unauthorized responses, making such attacks almost infeasible (at least for web-app case).
- homakov 12y ago1) extra random is not going to help, in long term any "noise" disappears and signal can be seen. 2) such attacks are infeasible most of the time, so we don't need to worry
- anuragbiyani 12y agoI agree that actual "signal" can still be learned over time, but if we chose additional random wait time from a distribution unknown to attacker (or even better, randomly select the distribution itself, and shuffle often), we can reduce the efficiency of attack dramatically. But another possible way is to add a deterministic amount of additional wait time (instead of random), i.e., "lie" about computation time of all inputs consistently. If designed properly, this won't leak any signal (assuming the strategy on how to "lie" is chosen randomly itself and shuffled often, so attacker doesn't learn it). Strategy of waiting for maximum time across all possible requests (as mentioned in your post) is sort of a special case of this, where one (deterministically) add a wait time of W - C (where W = Worst case time across all inputs, and C = actual time taken for this input). But we can use a less aggressive approach to hide the actual computation time as well.