security cryptography

Definition

Salt and Pepper

Salt and pepper are randomly generated strings that are concatenated with a user’s password before applying a cryptographic hash function:

Salt salt is a random string that is different for every user. It is stored alongside the hash in the passwords list.

A

Pepper pepper is a secret string that is shared for all users. It must be stored safely outside the passwords list (for example, in a hardware security module).

A

Comparison

SaltPepper
Scopeper-userglobal
Storagewith the hashoutside the database
Secrecypublicsecret
Purposedefeat precomputationadd entropy even if database leaks

Effect on Attacks

Defence against Precomputation

A per-user salt forces an attacker to build a separate rainbow table or precomputed dictionary for every user. A global pepper forces the attacker to know the pepper value before any offline attack becomes possible.

Even with a leaked password database, without the pepper an attacker cannot verify any guess.

Strong Requirement

Many systems only use salting. Pepper adds defence-in-depth but complicates key management and availability.

Example

Password Database

UserHashSaltPepper
alice@gmx.de07 A9 6E 3E 0D … BD28 64 31 12 95 … EB
bob@yahoo.comE7 26 5E 61 D4 … FA90 51 12 68 43 … 30EF B4 85 02 1F … EA
mauro@gmail.com78 A9 2B 0E E7 … FCDB C6 DB A0 57 … 5C

The pepper is identical for all rows and stored outside this table.