Written by: Mio Kanzaki(Security Analyst (AI))Reviewed by: 千葉圭介Updated
A salt is a string made at random for each password, mixed in before hashing, and stored together with the hash value. OWASP describes it as a string made unique for each password and added during hashing. Even with the same password, each person ends up with a different hash value.
How does a salt work?
Even with the same ingredients, if you change the secret flavoring for each person, each dish ends up with a different taste. A salt is that flavoring. If you mix a salt into the password and then hash it, two people with the same password still have different stored values.
OWASP lists three roles for a salt. One is to prevent attacks that look values up in a precomputed table, such as a rainbow table. The second is that it forces the hash values to be cracked one at a time. The third is to hide whether two users use the same password.
Many libraries make the salt automatically. NIST rules that passwords be hashed with a salt, and asks that the salt be at least 32 bits. The whole of hashing is also set out in cryptographic failures. If you want your password storage reviewed, contact us.
Why does a salt matter?
When a database leaks, without salt the same password gives the same hash value, and they line up. They may also be looked up all at once in a precomputed table. If the salt differs for each person, you can raise the effort these attacks take.
The term definition in NIST SP 800-63B-4 treats the salt as a non-secret value. The salt and the hash value are stored together for each password. The role of a salt is not to hide, but to not allow the same result to be reused.
The pair of this is the pepper. OWASP describes a pepper as a value shared by everyone. A pepper is not stored together with the hash value but kept in a secret vault, as one way of layering defenses. These are the points to check in an implementation.
- Make the salt a different value for each person.
- Make the salt at random.
- Store the salt and the hash value together.
- Do not make your own. Use a library that handles the salt automatically.
Related terms
- Hashing: processing that converts data into a form that cannot be reversed to protect passwords
- Rainbow table: a precomputed table for working back from a hash value to the original string
- Password reuse: the danger of using the same password on several sites
- Key management: the series of management that makes, protects, and replaces encryption keys
Frequently asked questions
Does a salt have to be kept secret?
No. The term definition in NIST SP 800-63B-4 treats a salt as a non-secret value. Store the salt together with the hash value. What is kept secret and stored separately is the pepper, which everyone shares.
Is it all right if everyone has the same salt?
No. OWASP says a salt should be made unique and random for each password. NIST also asks that overlap of salts be avoided so that no accounts have the same hash value.
Next step
Leaks that come from cryptographic failures are covered on the cryptographic failures page. If you are unsure how your passwords are stored, contact us. The free URL check shows only what is visible from outside.
Frequently asked questions
Does a salt have to be kept secret?
No. The term definition in NIST SP 800-63B-4 treats a salt as a non-secret value. Store the salt together with the hash value. What is kept secret and stored separately is the pepper, which everyone shares.
Is it all right if everyone has the same salt?
No. OWASP says a salt should be made unique and random for each password. NIST also asks that overlap of salts be avoided so that no accounts have the same hash value.