If an attacker obtained a copy of wp-config.php, changing the administrator password may not be enough to stop access. This file contains WordPress keys and salts used to sign authentication cookies, nonces, and other security mechanisms. Stolen cookies may remain usable until these cryptographic values are changed.
Rotating SALT keys is an important incident response step, but it is not a complete access cleanup procedure. Afterward, you must review the configuration, user accounts, API keys, integrations, server, and backups to ensure that the attacker has not retained another way to log in.
When to Rotate WordPress Keys and Salts
Rotate the keys if wp-config.php was accessible to an unauthorized party, exposed in a public repository, included in a backup, archive, or error log, or if you suspect that the hosting account or server was compromised. You do not need to wait for confirmation that stolen cookies were used: if the secrets may have been read, treat them as compromised.
Changing the SALT values invalidates current WordPress cookie sessions. This forces users to log in again and usually invalidates nonces created with the old keys. However, rotation does not change user passwords, Application Passwords, external service keys, or the database password.
- A confirmed or likely wp-config.php leak.
- Unknown access to the file system or hosting control panel.
- Suspicious logins, file changes, newly created administrators, or unfamiliar cron jobs.
- A need to force all active sessions to end after an incident.
Prepare Before Changing the SALT Values
Schedule a short maintenance window. During the rotation, administrators and users may be forced to log out, while integrations that rely on cookies or nonces may temporarily stop working. Before starting, save a copy of the configuration in a secure location outside the web root, and do not leave it in the site directory.
If the incident is still in progress, first restrict access to the server or control panel, preserve logs, and record when the work is performed. Do not overwrite the only copies of logs or delete suspicious files before they have been analyzed.
Make sure you have SSH access or another secure administration method, a current backup, and a way to restore the file if the automated change fails.
- Back up wp-config.php outside the web directory.
- Confirm that the backup is not included in Git, a public repository, or an automatically accessible upload directory.
- Notify the team that users will be required to log in again.
- Prepare a list of integrations, webhook secrets, API keys, and service accounts for later rotation.
How to Rotate SALT Keys with WP-CLI
The most convenient method is to run the WP-CLI command as the user who owns the WordPress installation. Use the actual path to the site rather than copying the example without checking it. The command updates the keys and salts in wp-config.php.
Before running it, verify that WP-CLI is working with the intended installation. If the server hosts multiple sites, an incorrect --path value could modify the configuration of another WordPress site.
- Connect to the server through a secure SSH connection.
- Change to the site directory or use the --path parameter.
- Run the command as a user who has permission to modify wp-config.php.
- Save the command output and confirm that the operation completed without errors.
wp config shuffle-salts --path=/var/www/site
How to Check the File After the Change
Confirm that the file is still in place, belongs to the correct system user, and is not writable by everyone. The specific owner and group depend on the hosting setup: on some servers, PHP runs as the site owner; on others, it runs as a separate system user.
Do not apply chmod or chown blindly on a production server. First identify the current owner and the established access policy. The web server must be able to read the configuration, while unauthorized users must not be able to view or modify it.
- Check the owner, group, and permissions for wp-config.php.
- Confirm that backups and temporary configuration files are not stored in the web directory.
- Do not paste the contents of wp-config.php into a chat, ticket, or command line recorded in shared shell history.
- Confirm that the site loads and that PHP does not report configuration read errors.
stat -c '%U %G %a %n' /var/www/site/wp-config.php
What Changes After Rotation
After the keys are changed, active WordPress cookie sessions should become invalid. Users will be redirected to log in again, and previously created nonces may fail validation. This is expected behavior, not necessarily a sign that the site is malfunctioning.
Some mechanisms may not use the standard WordPress cookie session. For example, an external service may use an Application Password, a static API key, a webhook secret, or its own authentication scheme. Rotating the salts does not automatically revoke these credentials.
Users should be warned that they will need to log in again, but do not disclose the secrets themselves or details that could make an attack easier. If nonce or authentication errors appear after rotation, first refresh the page and log in again, then check caching.
- Active cookie sessions and the nonces associated with them become invalid.
- User passwords are not changed.
- Application Passwords and API keys are not revoked automatically.
- Webhook secrets, SSH keys, hosting access, and database credentials must be changed separately.
Which Credentials Must Be Revoked Separately
SALT rotation does not remove all consequences of a wp-config.php leak. If the file was read, the attacker may have obtained not only WordPress keys but also database connection details, the table prefix, and other secrets stored in the configuration.
Change the database user password and update it in wp-config.php. Before doing so, confirm that the application, CLI commands, cron jobs, and backups use the new credentials. If the database account has broader permissions than the site requires, reduce them.
Review WordPress administrators, Application Passwords, SSH keys, the hosting control panel, CDN, email service, payment systems, repositories, and third-party APIs. Webhook secrets must be replaced on both the sender and receiver sides; otherwise, the old secret may remain valid.
- Change the database password and verify the site's connection.
- Review the list of administrators and remove unknown accounts.
- Revoke and recreate Application Passwords.
- Replace API keys, webhook secrets, SMTP passwords, and integration tokens.
- If necessary, change hosting, SSH, SFTP, and DNS control panel passwords.
Check the Site and Look for Signs of a Breach
After rotating the keys, test the site as a regular user and as an administrator. Log in again, open pages with forms, check the REST API, file uploads, scheduled tasks, and critical integrations. For the REST API, test both public endpoints and operations that require authentication.
Review web server, PHP, WordPress, and hosting control panel logs for the period when the leak may have occurred. Look for unusual IP addresses, repeated login failures, newly created users, plugin and theme changes, unknown PHP files, and suspicious cron jobs.
If there are signs that files were modified, rotation alone is not enough. Perform an integrity check, analyze a backup, or involve an incident response specialist. Do not restore a backup created after the compromise without verifying it first.
- Verify access to the admin panel and confirm that the old session was forcibly terminated.
- Test the REST API, forms, payments, email, and other critical integrations.
- Review administrators, plugins, themes, cron jobs, and recently modified files.
- Confirm that wp-config.php and its copies are not accessible through a browser.
- Document the actions performed, the rotation time, and the credentials that were changed.
Common Mistakes During SALT Rotation
The most common mistake is changing the administrator password and assuming the incident is over. Old cookies may remain valid, while an attacker may use an API key or database access. Another frequent problem is running the command for the wrong site or changing a file that is not used by the current installation.
Do not edit salts manually using random short strings, and do not copy secrets into unsecured online generators. Do not leave the old wp-config.php as wp-config.php.bak in the web directory: the server may serve that file as plain text.
Do not skip integration testing. Automation that relied on an old cookie session or nonce may stop working after rotation, with errors visible only in logs or job queues.
- Do not rely only on changing a user's password.
- Do not leave old configuration copies in the site directory.
- Do not run the command with the wrong --path.
- Do not revoke only WordPress sessions while ignoring API and server access.
- Do not delete logs before the initial incident analysis is complete.
Frequently asked questions
Is running wp config shuffle-salts enough if wp-config.php was leaked?
No. The command ends active WordPress cookie sessions, but it does not change passwords, Application Passwords, API keys, webhook secrets, database access, SSH credentials, or hosting panel access. Review and revoke all potentially compromised credentials as needed.
Will the administrator's password be changed automatically?
No. Rotating keys and salts does not change user passwords. If the password may have been stolen, change it separately after reviewing the account.
Do I need to rotate the SALT values if the old session was already ended manually?
Yes, if there is any possibility that the keys in wp-config.php were read. Ending one session manually does not guarantee that other stolen cookies are invalid.
What should I do if forms or integrations stop working after rotation?
First log in to the site again and check whether the form is using an old nonce. Then review caching, logs, Application Passwords, API keys, and webhook secrets. Do not restore the old salts just to temporarily remove the error.
Where should I store a backup of the old wp-config.php?
Store it in a secure location outside the web directory, with restricted access and controlled permissions. After the investigation is complete, delete unnecessary copies or destroy them according to your internal security policy.
Conclusion
Rotating SALT keys is a fast way to invalidate stolen WordPress cookies after a wp-config.php leak. Perform the rotation through WP-CLI for the correct installation, verify the file owner and permissions, and then test the admin panel, REST API, and critical integrations.
Treat rotation as only one part of the response. Change every secret that may have been exposed through the configuration or server, review the logs, and confirm that no old copies of wp-config.php remain in the web directory.