What the 8 WordPress keys and salts do
WordPress signs its login cookies and nonces with HMACs. The keys and salts in wp-config.php are the secret input to those HMACs, grouped by cookie type:
| Pair | Protects |
|---|---|
AUTH_KEY / AUTH_SALT | the auth cookie for /wp-admin over plain HTTP |
SECURE_AUTH_KEY / SECURE_AUTH_SALT | the auth cookie over HTTPS |
LOGGED_IN_KEY / LOGGED_IN_SALT | the cookie that marks a visitor as logged in on the front end |
NONCE_KEY / NONCE_SALT | nonces in forms and URLs (CSRF protection) |
Together with read access to the database (password hashes and session tokens), these values are enough to forge a valid login cookie. A leaked wp-config.php contains both the salts and the database password, so it means: new salts, new database password, new admin passwords.
Where to put the salts
Classic install: wp-config.php
Replace the 8 define() lines between /**#@+ and /**#@-*/ with the block above. Save, then log in again.
Bedrock: .env
WP_ENV='production'
WP_HOME='https://example.com'
WP_SITEURL="${WP_HOME}/wp"
AUTH_KEY='…'
SECURE_AUTH_KEY='…'
# … all 8 keysOfficial Docker image: compose.yaml + .env
services:
wordpress:
image: wordpress:6
env_file: .env # WORDPRESS_AUTH_KEY=… etc.
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wp
WORDPRESS_DB_NAME: wpKeep the .env out of git and the image, the same way as for any other app. The guide how to hide .env from git shows the .gitignore and .dockerignore lines.
Rotating salts after a security incident
- Generate new values here (or run
wp config shuffle-saltswith WP-CLI on the server). - Replace all 8 values at once, not just one pair.
- Change all administrator passwords and the database password in
DB_PASSWORD. - Remove unknown administrator accounts and application passwords under Users.
- Check
wp-content/pluginsandwp-content/mu-pluginsfor files you did not install.
New salts end every session, including an attacker's stolen cookie. They do not remove a backdoor file. That is what steps 4 and 5 are for.