News for hackers. Stuff that matters.
Re:Steam hit by major security breach by ars on Monday July 27, 2015 @01:14AM (#9953464)
> 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.

Re:Steam hit by major security breach by brobinson on Monday July 27, 2015 @01:27AM (#9953496)
Another not-so-obvious bug with your example buggy code: it's also vulnerable to timing attacks.

http://codahale.com/a-lesson-in-timing-attacks/

Re:Steam hit by major security breach by tomjen3 on Monday July 27, 2015 @04:13AM (#9953986)
True, but I don't think Steam allows you enough tries to make it viable.
Re:Steam hit by major security breach by kibibu on Monday July 27, 2015 @08:24PM (#9958862)
Also not a bug, but putting strlen() inside the loop condition makes my eyes twitch
Re:Steam hit by major security breach by mikeash on Monday July 27, 2015 @11:43AM (#9955822)
A "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.
Re:Steam hit by major security breach by pja on Monday July 27, 2015 @03:29AM (#9953867)
Yeah, strcmp() exists for a reason!
Re:Steam hit by major security breach by akx on Monday July 27, 2015 @03:58AM (#9953942)
But in this case you'd want to use a constant-time string comparison function, which, afaik, strcmp() is not.
Re:Steam hit by major security breach by simias on Monday July 27, 2015 @04:12AM (#9953980)
Is 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.

Re:Steam hit by major security breach by brobinson on Monday July 27, 2015 @04:36AM (#9954045)
Surprisingly... yes, it is possible. See the link in my other comment: https://news.ycombinator.com/item?id=9953496
Re:Steam hit by major security breach by pja on Monday July 27, 2015 @05:49AM (#9954249)
Good 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 :)

Re:Steam hit by major security breach by SCHiM on Monday July 27, 2015 @07:33AM (#9954534)
The idea is to use constant time hashing functions, and then compare the hashes instead of comparing the strings themselves. AFAIK there is no implementation of the C stdlib that makes sure no timing attacks can be performed.
Re:Steam hit by major security breach by rplnt on Monday July 27, 2015 @05:09AM (#9954139)
We're comparing one-time fixed-length code. Is it necessary?
Re:Steam hit by major security breach by mikeash on Monday July 27, 2015 @11:47AM (#9955850)
Probably 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.
Re:Steam hit by major security breach by valgaze on Monday July 27, 2015 @04:17AM (#9953995)
Try it out here: https://jsfiddle.net/valgaze/wpL2La7d/

If this is in fact how how things worked, what a great showstopper bug

Re:Steam hit by major security breach by jackweirdy on Monday July 27, 2015 @05:22AM (#9954180)
Looks like 's' is also considered valid in this example
Re:Steam hit by major security breach by m3Lith on Monday July 27, 2015 @05:34AM (#9954215)
And so is any part of the full word (s, st, ste, stea, steam)
Re:Steam hit by major security breach by mcgroarty on Tuesday July 28, 2015 @11:59AM (#9962463)
That'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.
Re:Steam hit by major security breach by jwiley on Monday July 27, 2015 @02:19AM (#9953642)
No 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
Re:Steam hit by major security breach by ars on Monday July 27, 2015 @02:35AM (#9953700)
If you wrote it like that this bug would happen in every language. There is nothing in there that is worse because of C.
Re:Steam hit by major security breach by rizzin on Monday July 27, 2015 @04:09AM (#9953972)
Yeah, but in other (more high-level) languages you simply wouldn't compare strings byte by byte.
Re:Steam hit by major security breach by delroth on Monday July 27, 2015 @04:48AM (#9954087)
Neither would you do it in C.
Re:Steam hit by major security breach by XMPPwocky on Monday July 27, 2015 @02:46AM (#9953736)
Their webapp is (AFAIK) all PHP; not sure what the backend looks like.