News for hackers. Stuff that matters.
Re:Ginzametrics Open Sources Odin, A Cookie-Based Single Sig... by tptacek on Tuesday August 14, 2012 @03:36PM (#4382701)
I think this has the HMAC timing flaw. This is a hard flaw to exploit, and a very common one that many people could spot, so:

    die "Invalid signature\n"
        if ( $hmac ne hmac_for($secret, $user, $roles, $ts, $ua) );
The "ne" operator in Perl will terminate at the first non-matching byte. You need an HMAC compare to touch every byte. The idiom is, XOR each successive byte, then reject the hash if the accumulated sums aren't 0.

Also, I'm not wild about a structured cookie with "-" as the separator that contains any user-controlled data. The user-agent is last in the cookie, which is good, but you worry about usernames with the "-" character. "Canonicalization" is the process of ensuring that every piece of data that hits the hash is in a character set that can reliably be extracted from the cookie. For data that is in any way under user control, if you're going to use "-" as a separator, I'd hex-encode the strings.

Re:Ginzametrics Open Sources Odin, A Cookie-Based Single Sig... by mpasternacki on Wednesday August 15, 2012 @06:34AM (#4385331)
Thank you for your remarks, this is really helpful.

It doesn't seem to me that timing attack is feasible here: timing of comparison of a relatively short string vs network latency and everything else that happens during Apache's request handling would require a lot of repeated attempts and statistical analysis of very noisy data if it's at all possible to get meaningful results. Still, it's better to be on the safe side and I'm going to close it up.

Sanity check for idea of resolution: adding a random length sleep, 1 to 3 seconds, if HMAC is invalid. This would fuzz the small timing difference in string comparison, and at the same time tarpit any exploit attempts (invalid HMAC is more likely to be sign of manipulation attempt rather than a honest error). Does that make any sense?

Regarding user-controlled data: the context here is that usernames aren't under user's full control (they need to be entered into Google Apps by someone, and also validated). In general case this is a valid issue - a valid login could break the scheme here.

This is in no way an excuse, but rather explanation of my reasoning: the initial idea was to port GodAuth and be at least "kind of compatible", because some people use GodAuth and it might be meaningful for interoperability. Also, as I'm no specialist in crypto (as you can clearly see), I followed the route of not touching crypto-related code that is already written. The issues you've found are strong enough reasons to diverge from GodAuth - especially that GodAuth interoperability is way more theoretical than an actual security issue even if it may not be exploitable. Thank you for reviewing the code and your remarks.

Re:Ginzametrics Open Sources Odin, A Cookie-Based Single Sig... by gose1 on Tuesday August 14, 2012 @06:18PM (#4383357)
Also, using sha1_hex(secret+...) and calling it HMAC is a slippery slope (see http://netifera.com/research/flickr_api_signature_forgery.pd...). Although it's seemingly not exploitable due to the structure of the data, look into using a proper HMAC (RFC 2104) to prevent length-extension attacks.
Re:Ginzametrics Open Sources Odin, A Cookie-Based Single Sig... by tptacek on Tuesday August 14, 2012 @08:37PM (#4383818)
Whoah. That is a good catch. I admit, I skimmed this, saw "hmac_for", thought "I'm not a Perl programmer", and assumed it was HMAC.

Guys, fix this ASAP. SHA1(secret || data) (secret-prefix MAC) is totally insecure. (In practice, every valid forgery to this MAC is going to look like x-y-z-useragent-GIBBERISH-evil-content, but you don't want to be relying on that for your security).

Embarrassing (for me).

Re:Ginzametrics Open Sources Odin, A Cookie-Based Single Sig... by mpasternacki on Wednesday August 15, 2012 @06:37AM (#4385342)
Thank you! This will be closed up by end of this week. As I wrote in the article and in the presentation, one of main points of open sourcing it is to have people smarter than myself look at the crypto and protocols to find any issues like this. It should be fairly easy to close up.
Re:Ginzametrics Open Sources Odin, A Cookie-Based Single Sig... by rgrieselhuber on Wednesday August 15, 2012 @12:46AM (#4384627)
Glad to have more eyeballs on this. Thanks guys. We're on it.
Re:Ginzametrics Open Sources Odin, A Cookie-Based Single Sig... by rgrieselhuber on Tuesday August 14, 2012 @03:58PM (#4382802)
This is really helpful, thanks.