Thinking through salts for passwords

November 4, 2007

No one who's sane stores actual plaintext passwords; instead they hash the password in some way and store the result, throwing away the password itself as fast as possible. There are three ways you can do this:

  1. you can hash just the password.
  2. you can hash some global value plus the password.
  3. you can hash some per-user value (a 'salt') plus the password.

If you hash just the password, anyone who can somehow gain access to your password hashes can immediately run them through a precomputed dictionary of hashes to see what pops out.

If you hash a global value plus the password, the attacker can no longer use their general precomputed dictionary. However, they can still compute a special dictionary just for you and check all of your hashes against it, either by precomputing the dictionary or by just checking every one of your hashes against every hash they generate.

If you use a per-user value, an attacker cannot compute a site-wide dictionary for your hashes; they must attack each password one by one. This is obviously the best option.

(I don't know enough to know if adding a global value too does any good. I think that at the most it insures that the same password plus salt on two sites will have different hashes. However, a good salt should be large enough and random enough that this is relatively rare anyways.)

Note that all of this says nothing about the difficulty of attacking a single password. As Matasano Chargen reminds us, that comes down to the speed of your password hashing scheme, and things like MD5 and SHA1 are embarrassingly and dangerously fast and should be avoided if you have a choice.

(This is partly me thinking this through out loud to fix it in my head.)

Written on 04 November 2007.
« A thought about the speed of IPv6 deployment
Some notes on Solaris 10 U4 x86 as an iSCSI target »

Page tools: View Source, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Sun Nov 4 22:42:44 2007
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.