5 ms·
> Steam accepted blank recovery codes for password resets Sample buggy code (that I just made up): (user_token is user supplied token, token is the correct to
by ars 11y ago
> Steam accepted blank recovery codes for password resets
Sample buggy code (that I just made up):
(user_token is user supplied token, token is the correct token)
for(i = 0; i < strlen(user_token); i++) {
if(user_token[i] != token[i]) return false;
}
return true;
If code is blank this will falsely return true. This is also subject to truncation attacks.
I'm trying to think of a bug where blank fails, but truncated versions do not.
- brobinson 11y agoAnother not-so-obvious bug with your example buggy code: it's also vulnerable to timing attacks. http://codahale.com/a-lesson-in-timing-attacks/ http://codahale.com/a-lesson-in-timing-attacks/
- deleted 11y ago[deleted]
- jwiley 11y agoNo idea or visibility into Steam's backend. Hope to god they are not using C for this very reason. Great for games, terrible for SAS
- pja 11y agoYeah, strcmp() exists for a reason!
- akx 11y agoBut in this case you'd want to use a constant-time string comparison function, which, afaik, strcmp() is not.
- simias 11y agoIs such a timing attack really possible over the internet? I'd expect the code to expire after a few failed attempt anyway. But I guess you're right, better safe than sorry.
- brobinson 11y agoSurprisingly... yes, it is possible. See the link in my other comment: https://news.ycombinator.com/item?id=9953496 https://news.ycombinator.com/item?id=9953496
- rplnt 11y agoWe're comparing one-time fixed-length code. Is it necessary?
- mikeash 11y agoProbably not. Ideally you'd implement this endpoint to invalidate the code after a few failures, so a timing attack would be impossible to carry out. But it's a good idea to use one anyway, in case it turns out that you're wrong, or that other code is also broken somehow. It costs almost nothing to do so.
- pja 11y agoGood point. Is there are library of constant time functions for security sensitive applications to replace the standard ones in libc? (Seems like the kind of thing that the OpenBSD people might have written.) strcmp() is at least better than a buggy equivalent that doesn’t actually work :)
- valgaze 11y agoTry it out here: https://jsfiddle.net/valgaze/wpL2La7d/ https://jsfiddle.net/valgaze/wpL2La7d/ If this is in fact how how things worked, what a great showstopper bug
- jackweirdy 11y agoLooks like 's' is also considered valid in this example
- m3Lith 11y agoAnd so is any part of the full word (s, st, ste, stea, steam)
- deleted 11y ago[deleted]
- deleted 11y ago[deleted]
- mikeash 11y agoA "goto fail" style bug could allow for blankness but not truncatedness. Basic idea: if(!check_params()) { failed = true; goto fail; } if(some_other_check()) { failed = true; goto fail; } if(token_length == 0) { goto fail; // oops, forgot to set failed } ...check the token... fail: if(failed) { return auth_failure; } I have no idea if this is anything like what actually happened, of course.
- mcgroarty 11y agoThat's one possibility. Another possibility is they were merely comparing the submitted nonce to the nonce on file. If a nonce had never been generated for a user, the database may have contained an empty string. An empty string in the db would match an empty string submitted by an attacker.