Live data from Hacker News

The definitive guide to forms based website authentication

stackoverflow.com

61–70 of 74 posts

Re: The definitive guide to forms based website authentication

#61

2 points by sreeix 160 days ago | flag | discuss http://news.ycombinator.com/item?id=4047424 316 points by moonlighter 457 days ago | flag | comments http://news.ycombinator.com/item?id=2859234

One url is terminated by a /. HN isn't doing URL normalization (by hitting the URL and only recording what is at the end of the 302-redirect-chain)

Re: The definitive guide to forms based website authentication

#62
post #53

Well, this is weird. I created this question when StackOverflow was just out of beta, hoping to steer it to more broader questions - guides, if you wish. This question really took off, but the format didn't, and SO mostly became a stack of incredibly specific questions and answers. And now somebody, but not me, has submitted this question to HN. Under my name. I'm puzzled...

It's not under your name, unfortunately. mdemare != mmare

But it indeed seems to be somebody who is claiming to be the author of the SO post (perhaps for karma?).

They only created the HN account today in order to post this story, and they chose a username which is obviously a reference to Michiel de Mare from the SO post.

Whereas according to mmare's profile, he's been around on HN for a good while now.

I agree that it's strange.

Re: The definitive guide to forms based website authentication

#64
post #6
post #4

it's mostly good. NIST abolished their algo for pasword entropy estimation some time ago. i do not much like any password strength tests, most of which rate any number of terrible passwords as strong. as such i think they give a false sense of security. maybe consider cracklib. as DenisM said, always use SSL for all traffic if security matters and don't trust SO for security advice.

The only really useful password strength test would be one that said "A stock Thinkpad would be able to brute force this password in $x hours and $y minutes." Might make people think twice about that six character password.

That is only useful if you also specify yhe conditions under which the "cracking" takes place. Do you mean on-line password guessing? Or do you mean brute-forcing a hashed password leaked from a database?

In case 1 a lock-out policy would quite easily negate your attack. In case two the hashing algorithm used is often more important than the length and complexity of the password (up to a point of course, but that point is nowadays well beyond what's pactical for a user)

Re: The definitive guide to forms based website authentication

#65
post #51
post #5

Earlier quoted context omitted.

There was some information in there about SRP being patented that I thought was misleading. It is patented, but it's freely licensed.

The main problem with SRP being mentioned at all is that it has no meaningful security value in web application context. It makes sense when client does not entirely trust server, which makes no sense when you deliver client as bunch of .js files from the same "untrusted" server.

Very true, however, most users are willing to download such things as native programs (e.g. installing web browsers) from unauthenticated sources over unencrypted connections. If you are in a position to inject .js resources, then the user's security would be compromised anyway.

EDIT: SRP is going to be integrated into TLS soon anyway, so we might as well hold our breath for that.

Re: The definitive guide to forms based website authentication

#66

Earlier quoted context omitted.

I think that is the beauty to this post it wasn't one person... However, Jeff Atwood seems to be the main contributor. He was also the co-founder of Stack Overflow. http://stackoverflow.com/posts/477578/revisions The power of team work.

He's probably incorporating information from highly rated posts below, rather than generating content.

That's what he says he did in the related meta post: http://meta.stackoverflow.com/questions/95172/old-problemati...

Re: The definitive guide to forms based website authentication

#67
The first answer mentions a couple of time that any token given to the user (for remember-me login or password reset) should be hashed in the database.

Would it be possible to replace the whole storing by signing the token with some private key, so that the validity of the token can be checked without having to compare it to some stored value ?

Re: The definitive guide to forms based website authentication

#68
post #67

The first answer mentions a couple of time that any token given to the user (for remember-me login or password reset) should be hashed in the database. Would it be possible to replace the whole storing by signing the token with some private key, so that the validity of the token can be checked without having to compare it to some stored value ?

Yes, you could use an HMAC for this, however you need to keep the private key, well... private, which in practice is not easy. If the server is compromised, an attacker could steal the secret key and use it to generate signed cookies for any user. This method is also subject to reply attacks for the duration of the token's validity, though that is less relevant with SSL.

Whereas if only token hashes are stored in the database, then the entire database could be stolen and nobody can use it to generate valid cookies.

EDIT: Also, if an account goes rogue you have no way to invalidate its cookies, so you'll have to do a lookup for each request to see if the account is blocked.

Re: The definitive guide to forms based website authentication

#69
post #59

I'm normally highly sceptical of anything which is essentially a how to guide on security of, well, anything but I have to say whoever this author is they absolutely know their stuff. Normally security advice is just 1980s circle-jerking of the same meaningless "sound good" concepts (e.g. "At least one upper-case, number, special character") but actually, no, not in this case. Instead he is giving advice which is mod…

To provide a counterpoint, the section about the "Remember Me"-cookie is rather terrible (I stopped reading after that). It's not fundamentally flawed but rather inelegant (and potentially expensive) to store a magic number server-side for each session. You can implement the same thing more easily by handing out tamper-proof (HMAC) cookies containing the start- and end-time, and storing only the last_logout-timestamp…

The problem for most mere mortals with the HMAC scheme is that there is a very real possibility of the server being compromised and the secret key being stolen. In this case an adversary could generate valid cookies for any user. However, with the magic number scheme as long as only the hash of the random number is stored (we should add a per-user salt too) then the entire session database could be compromised, but an attacker cannot do anything with it.

Also, though less of an issue with SSL, the HMAC approach is subject to replay attacks while expire_at .

EDIT: The HMAC approach also lacks any method to invalidate cookies manually, or automatically e.g. when the user changes their password. This means a compromised account is open to attack until expire_at , and there's nothing you can do about it other than blocking the account for that duration, which now means that each request needs to do a database lookup to see if the account is blocked. You could generate a per-user secret key, but now you have a database lookup again, so you might as well use the magic number scheme.

Re: The definitive guide to forms based website authentication

#70
post #23

> if an attacker got his hands on your database, he could use the [persistent login cookie] tokens to log in to any account If an attacker gets his hands on your database, it's kind of game-over already.

No, not at all. There are many scenarios in which data can be accessed read-only such as ACL misconfiguration, poorly secured backups, 0-day attacks which allow stealing cryptographic keys, overly verbose exception messages, etc.

An adversary who makes a single copy of your database could impersonate any user, and go unnoticed for potentially a huge period of time unless you have good intrusion protection. A targeted attack might steal just a single token, and could last a few seconds only, but then have unauthorised access indefinitely via the token.

EDIT: Incidentally this is why only the hash of the token should be stored in the database, just like storing passwords. Also the token should expire.

Post reply on HN