Password Salting
A salt is unique random data mixed into each password before hashing, so identical passwords produce different digests and precomputed attacks fail.
Definition
A password salt is a random value stored alongside a hash and combined with the password input so that equal passwords yield unequal stored representations.
Context and scope
It is a baseline requirement for credential storage and is built into modern password hashing libraries.
Common misconceptions
- a salt is a secret that must be protected like a key
- salting alone makes a fast hash suitable for passwords
Anti-patterns
- reusing one global salt for every account
- implementing salting by hand instead of using a reviewed library
Related concepts
Related examples
Authoritative source
https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html
Definition
A password salt is a random value stored alongside a hash and combined with the password input so that equal passwords yield unequal stored representations.
It is a baseline requirement for credential storage and is built into modern password hashing libraries. Compared to simpler alternatives, this concept fits best when the trade-off it represents is the one the system actually cares about.
When to use it
A common use case is applying it at the boundary where the cost of getting it wrong is highest, and the scenario usually involves a concrete guarantee the system must uphold. Unlike an ad hoc approach, it makes that guarantee explicit, reviewable, and testable.
How it works
Because the salt is unique and stored with the hash, an attacker cannot reuse a table computed for one user against another, and equal passwords no longer reveal shared credentials.
The salt does not need to be secret, only unique and unpredictable; its purpose is to remove precomputation, not to add a second secret.
Trade-offs and alternatives
Salting increases the cost per guess only marginally, so it must be combined with a slow algorithm tuned so that verification stays responsive for legitimate users. The main drawback is the extra complexity it introduces, so the benefit should clearly outweigh that cost before a team adopts it.
Common misconceptions
A persistent misconception is that a salt is a secret that must be protected like a key. Another is that salting alone makes a fast hash suitable for passwords. For example, an engineer who assumes otherwise may design around a guarantee that does not actually exist, which only becomes obvious under load or failure.
Anti-patterns to avoid
Two recurring anti-patterns are to reusing one global salt for every account and to implementing salting by hand instead of using a reviewed library. Both tend to surface as hard-to-debug production issues rather than obvious test failures. Related concepts include Authenticated Encryption (AEAD), Forward Secrecy, Key Derivation Functions.