You discover a malicious admin user that’s been quietly active on the site for two months. You delete the account, change every other admin’s password, and feel like the incident is closed. Three days later, the attacker is back — same IP range, same behaviour, no need to log in again, because the wordpress_logged_in_<hash> cookie that was issued to them eight weeks ago is still valid. The session never logged out. Until the salts rotate, neither does any other session that was issued before the discovery.
What’s happening
WordPress doesn’t keep server-side sessions for its auth cookies. The cookie is signed and validated using a SHA-256 HMAC keyed on AUTH_KEY + AUTH_SALT (and the parallel constants for LOGGED_IN_*, SECURE_AUTH_*, NONCE_*). The cookie body itself encodes the user ID, an expiration timestamp, and a fragment of the session token that lives in usermeta. The server validates by recomputing the HMAC; if it matches, you’re logged in.
The implication is direct: as long as AUTH_KEY and AUTH_SALT (the pair used by wp_validate_auth_cookie()) haven’t changed since a cookie was issued, that cookie remains valid until its embedded expiration. Default cookie lifetime is 48 hours, but the “Remember me” path extends it to 14 days.
So the salts perform three jobs at once:
- Auth-cookie signing (
AUTH_*) — for the standard wp-admin login. - Secure-auth-cookie signing (
SECURE_AUTH_*) — for the HTTPS-only admin cookie. - Logged-in-cookie signing (
LOGGED_IN_*) — for the front-end “logged-in user” cookie, used by comments, customizer previews, member sites. - Nonce signing (
NONCE_*) — for CSRF tokens on every form, not for long-lived sessions.
Rotating all eight together invalidates every existing cookie of all four types. Every user is forced to log in again. Nonces on submitted-but-not-yet-completed forms (like a half-filled checkout) will fail to validate, which is briefly annoying but operationally safe.
What rotation does not do:
- It does not invalidate the
usermetasession tokens. Those tokens are independent and remain in the database. If you want to also clear them — and after a compromise you do — that’s a separate WP-CLI call. - It does not change application passwords. Those are stored in
usermetaand signed differently. Compromised application passwords need to be revoked through the wp-admin user profile or via WP-CLI. - It does not change REST API JWT tokens issued by third-party plugins. Those usually have their own secret and need separate revocation.
How to verify
Before rotating, inventory what’s about to be invalidated:
# Active sessions per user (usermeta key: session_tokens)
wp user list --field=ID | while read uid; do
count=$(wp user meta get "$uid" session_tokens --format=json 2>/dev/null \
| python3 -c 'import sys,json; d=json.loads(sys.stdin.read() or "[]"); print(len(d) if isinstance(d,dict) else 0)')
if [ "$count" -gt 0 ]; then
login=$(wp user get "$uid" --field=user_login)
echo "$uid $login $count active sessions"
fi
done
# Application passwords in use
wp user application-password list --user=all 2>/dev/null
Confirm salts have, in fact, been rotated before — if all eight strings look identical in age and were never touched since install, you’re probably overdue:
# WordPress doesn't track salt age, but the wp-config.php file's modify time
# combined with a git blame of the salts block is a reasonable proxy
stat -c '%y' /home/<account>/public_html/wp-config.php
grep -nE "(AUTH_KEY|SECURE_AUTH_KEY|LOGGED_IN_KEY|NONCE_KEY)" \
/home/<account>/public_html/wp-config.php
Confirm WP_DEBUG won’t dump errors to the front-end during the rotation. Salts rotation invalidates every nonce in flight; any plugin that doesn’t gracefully handle a wp_die() from a failed nonce check will surface noisy errors for the next 12 hours.
The fix
Generate the new salts. WordPress provides a public endpoint that returns eight cryptographically strong strings:
curl -s https://api.wordpress.org/secret-key/1.1/salt/
The output is eight define(...) lines ready to paste. Don’t paste them straight in — store them in the environment-variable layer so the file itself stays free of secrets (see the wp-config hardening checklist for the env-var pattern).
Apply the rotation. Two paths depending on whether secrets live in env vars or the file:
# Path A — secrets in env vars (PHP-FPM pool config)
sudo vim /etc/php-fpm.d/example-com.conf
# Update env[WP_AUTH_KEY], env[WP_SECURE_AUTH_KEY], env[WP_LOGGED_IN_KEY],
# env[WP_NONCE_KEY], and the four matching SALT entries
sudo systemctl reload php-fpm
# Path B — secrets in wp-config.php directly (legacy/inherited installs)
# Edit the file, replace all eight lines, save. No service restart needed —
# PHP re-reads wp-config.php on every request.
Force-clear every session token in the database. The salts rotation already invalidated the cookies; clearing session tokens prevents any future cookie that an attacker might try to forge from finding a matching server-side token:
# Burn every active session for every user
wp user session destroy --all --user=all
# Or, scoped to a specific user (e.g. the one you suspect was compromised)
wp user session destroy --all --user=42
Revoke and reissue application passwords if any are in use:
# List, then revoke individually after coordination with the team
wp user application-password list --user=all
wp user application-password delete <user> <uuid>
Communicate the forced logout. Every wp-admin user will be kicked. If editorial or support staff are mid-shift, the optics matter — send a heads-up in the team channel five minutes before the change, and acknowledge that the next 30 minutes of nonce errors on the front-end are expected and self-resolving.
When to rotate
- Forced (post-compromise): Any of — confirmed admin account compromise, undetermined-source PHP file in
uploads/, leaked backup tarball (containswp-config.php), departure of a contractor who held administrative access. Rotation happens within the incident window, before any other remediation step that depends on session-trust assumptions. - Scheduled: Annually, on a fixed calendar entry. The cost is one forced re-login per active user; the benefit is a hard upper bound on how long any leaked cookie can be useful. Pair it with the annual password reset for admin accounts.
- Triggered by deploy events: After a major plugin removal where the plugin had its own user role with elevated capabilities, after a hosting migration where backups were copied across providers, after recovering from a database restore that may have replaced known-good sessions with state from before a compromise.
What breaks
- Every active wp-admin session — users see the login page on the next request.
- Open form submissions that depend on a nonce issued before the rotation — they fail with
403 Forbiddenand the user re-submits. This is graceful in most plugins, ugly in a few. - The customizer preview, if anyone has one open, drops to logged-out and re-prompts.
- Front-end “remember me” cookies stop working for the next 14 days of would-have-been-valid sessions. Customers who rely on long-lived front-end logins (membership sites) will see them dropped.
- Application passwords are not invalidated by salts rotation — they’re hashed in usermeta independently. Revoke them separately if they were in the threat model.
Stack Harbor builds salt rotation into the enterprise WordPress support runbook on an annual cadence with a documented incident-response variant for the compromised case. For environments where the last rotation is unknown or pre-dates the current operator, we can sequence the rotation and the session-clear during a maintenance window.