Home / Knowledge hub / Pepper
Knowledge hub
Pepper
A secret added to every password hash and kept outside the database.
What it means
A pepper is a secret value mixed into password hashing and stored somewhere other than the database. It is applied to every password, usually by running the hash through a keyed function such as HMAC, or by encrypting the hash. Without the pepper, a thief holding only the stolen database cannot test password guesses.
It is often confused with a salt. A salt is stored next to each hash, is unique per user, and is not secret. A pepper is the same for everyone, is secret, and lives in a different place: a secrets manager, a hardware module or protected application configuration.
Why it matters
Most database thefts come through a flaw in the application or the data store, such as an injection bug. The attacker leaves with the hashes and starts guessing offline. If the pepper sits in a different system, they are missing a key ingredient, and the hashes cannot be cracked until it is also found.
NIST’s guidance on digital identity recommends this extra keyed step, using a secret key known only to the verifier and stored separately, ideally in hardware. It is a second layer behind slow hashing, not a replacement for it, and it only helps if the key really is kept apart from the data.
How it shows up
In practice, the application reads the pepper at start-up from a secret store, applies it to the password or the hash, and then runs the normal password hashing. The pepper never goes in the database, in source control or in logs. A stored version number next to each hash lets you know which pepper was used.
The hard part is rotation. Changing the pepper invalidates every stored hash unless you keep old versions or re-wrap hashes at the next login. Other mistakes: committing it to the repository as a hardcoded secret, keeping it in the same database table, or treating it as a substitute for a slow algorithm.
Questions people ask
Pepper, answered
What is the difference between a salt and a pepper?
A salt is unique per password, stored beside the hash and not secret. It defeats precomputed tables. A pepper is shared, secret and stored elsewhere. It makes stolen hashes useless without the key.
Use both.
Where should a pepper be stored?
Outside the database: in a secrets manager, a hardware security module or environment configuration with tight access. Never in the same place as the hashes.
Anyone who can read both can crack the hashes.
Can we rotate a pepper?
Yes, with planning. Store a version with each hash, keep old peppers available, and upgrade hashes as users sign in. Rotation is why many teams find peppers awkward.
Plan the process before you need it.
Is a pepper required?
No. A strong slow hash with a unique salt is the baseline. A pepper adds protection for the case where only the database leaks, and OWASP describes it as an additional layer on top.
Do the baseline first.
Does a pepper help if the server itself is compromised?
Much less. An attacker with access to the running application can read the pepper from memory or configuration, and then test guesses. It is aimed at database-only leaks, so keep the application hardened as well.
Slow hashing still matters.
Related
Terms that sit next to this one
Salt
Random data added to each password before hashing so identical passwords differ.
Hashing
A one-way transformation, so a password can be checked but never read back.
Secrets management
Keeping keys, passwords and tokens out of code and in a vault.
Hardware security module (HSM)
A tamper-resistant device that holds keys and does cryptography inside it.
Hardcoded secret
A password, API key or token written straight into source code.
Would a stolen database be enough?
Where passwords are stored is something we can read and test. Our white-box mode reads your code while testing the running app, so a finding can point to the file and line. Ask us to run it on one of your applications.
Or start with a $199 pilot on one application: thirty days, success criteria agreed before day one, credited against the annual if you convert.