Salt and hashing, why not use username?

Lasse V. Karlsen picture Lasse V. Karlsen · Apr 6, 2011 · Viewed 12.2k times · Source

I must confess to being largely ignorant on most of the high-tech security issues relevant for web applications, but there is one thing I at least thought I could ask because it is a direct question with (hopefully) a concrete answer.

Take this website: http://www.15seconds.com/issue/000217.htm

It shows a bit down that they store the salt value in the table, I understand the principles and the math behind using a salt, but I'm wondering this:

Why did they not just use the username as a salt value instead of generating one?

Answer

Thomas Pornin picture Thomas Pornin · Apr 6, 2011

The point of the salt is to be unique. The salt is meant to prevent attack cost sharing, i.e. an attacker trying to attack two hashed passwords for less than the twice the cost of attacking one.

One solution to ensure uniqueness is to generate a random salt in a wide enough space. Therefore, getting twice the same salt for two distinct password instances is sufficiently improbable that it will not happen in practice.

The user name is not adequately unique:

  • The user name does not change when the user changes his password. An attacker seeing the old hashed password and the new hashed password may attack both at a cost less than twice the cost of attacking one.
  • At a given time, user names are unique system-wide, not world-wide. There are many "bob"s out there (in a Unix system, consider "root"). Using the user name may allow an attacker to attack several systems simultaneously.

Salt entropy is not really important, except in so much as it ensures uniqueness in a random generation setting.