Part 3: Do the work · Chapter 10
WordPress Security for Client Sites (and What to Do When One Is Hacked)
How agencies keep client WordPress sites secure: the routine that prevents most hacks, hardening settings worth applying, and a step-by-step response plan for when a client site is compromised.
By Mike Valera · Last updated
Short answer: Most WordPress sites are compromised through a plugin or theme with a known vulnerability, or through a weak or stolen admin password. So the security routine that matters most is unglamorous: patch known vulnerabilities quickly, remove what isn't used, keep admin accounts few and protected with two-factor login, keep off-site backups, and get alerted when something changes. When a site is hacked anyway, contain it first, lock the attacker out by changing every password, find how they got in, clean it or restore a known-good backup, close the hole, and tell the client what happened.
Security is the part of a care plan clients care about most and understand least. They can't see it working, but they'll remember the week their site redirected to a spam page. This chapter covers the routine that prevents most problems, and the plan to follow when prevention fails.
How client sites actually get hacked
It's rarely a clever, targeted attack. Most compromises are automated: bots scan the web for sites running a plugin version with a published vulnerability, or try common and leaked passwords on login pages. The usual ways in:
- A plugin or theme with a known vulnerability that hasn't been updated. This is the most common cause. Once a vulnerability is published, attacks often start within days.
- An abandoned plugin or theme that will never get a fix, because its developer stopped maintaining it or it was removed from wordpress.org.
- A weak, reused or stolen admin password, especially on accounts without two-factor login.
- Nulled (pirated) premium plugins, which often ship with a backdoor already inside.
- Another site on the same hosting account. One hacked site can spread to every site that shares the account.
The practical conclusion: the routine below, done every week, prevents most of what you'll ever face.
The weekly security routine
These steps belong in every care plan, on every site:
- Patch known vulnerabilities first. Check every site for plugins, themes and WordPress versions with published vulnerabilities, and update those ahead of your normal schedule. High and critical issues should be patched within a day or two.
- Remove what isn't used. Every inactive plugin and theme is code that can still be attacked. Delete them (keep one default theme as a fallback).
- Replace abandoned plugins. Anything closed on wordpress.org or not updated in a long time goes on a list to replace.
- Review admin accounts. Remove admins who no longer need access, give staff the lowest role that works, and turn on two-factor login for every admin.
- Keep off-site backups. A recent, restorable backup stored off the server is the difference between a bad day and a disaster. See how to set up off-site WordPress backups.
- Keep PHP supported. A PHP version that no longer gets security fixes is a risk on its own, and many plugin updates stop supporting old versions.
- Watch for changes. New admin users, changed nameservers, unexpected redirects and spam pages in search results are early signs of a compromise.
Hardening settings worth applying
Hardening won't stop an attack through a vulnerable plugin, but it removes easy wins and limits the damage. These are low-risk on most sites:
| Setting | Why |
|---|---|
| Disable the theme and plugin file editor | Stops an attacker with an admin login from editing code in the browser |
| Turn off debug mode on live sites | Error messages can reveal file paths and versions |
| Disable XML-RPC if nothing uses it | Removes a common target for password guessing (check Jetpack and mobile apps first) |
| Use security keys and salts | Protects login cookies; changing them logs everyone out |
| Make login errors generic | Stops the login page confirming which usernames exist |
| Block author enumeration | Stops bots collecting usernames from author archives |
| Add security headers | Basic browser protections against clickjacking and content sniffing |
| Serve the whole site over HTTPS | Protects logins and form data in transit |
Avoid the admin username | One less thing for bots to guess |
Test after changing anything that can affect how the site works, especially XML-RPC and security headers.
What to promise clients
Be careful with security wording in your care plan and your sales copy. No one can promise a site won't be hacked. What you can promise:
- Known vulnerabilities are patched quickly
- The site is monitored, and you'll know fast when something changes
- Backups are stored off-site and can be restored
- If something happens, you'll respond within the time in your plan
Say in your care plan terms whether cleanup is included for sites on the plan, up to a limit, and that a site hacked before the plan started is a separate job.
When a client site is hacked: the response plan
Common signs: the site redirects to spam or scam pages, Google shows a "This site may be hacked" warning, the host suspends the account, unknown admin users appear, the site sends spam email, or search results show pages you never created.
When it happens, work through these steps in order. Don't skip to cleanup: a site cleaned without finding the way in is often reinfected within days.
1. Contain it
- Put the site in maintenance mode or take it offline if it's harming visitors (redirecting them, serving malware)
- If the host has suspended it, find out what they detected; their notice often names files
- If other sites share the hosting account, check them too
If the site is behind Cloudflare, its "I'm Under Attack" mode can slow automated traffic while you work, though it won't remove anything from the site.
2. Preserve evidence
Before changing anything, take a full backup of the hacked site and download the server access logs. You'll need both to work out how they got in, and you may need them if the client's data was exposed. Keep this backup separate from your clean ones.
3. Lock out the attacker
- Change the passwords for every WordPress admin, the hosting account, SFTP/SSH, the database and the domain registrar
- Remove any admin users you don't recognize
- Change the WordPress security keys and salts, which logs everyone out
- Check the server for things outside WordPress: scheduled tasks (cron jobs), SSH keys and extra FTP accounts. Backdoors often hide there so they survive a WordPress cleanup.
4. Find the way in
Look for the vulnerable plugin, the stolen login or the other hacked site. Useful places:
- Your vulnerability scan history: was a plugin on this site vulnerable recently?
- Access logs around the time the first malicious file appeared
- The site's activity log for logins and admin changes
- File modification times in the plugin, theme and uploads folders
5. Clean or restore
You have two options:
- Restore from a backup taken before the compromise. Fastest and most reliable, if you know when it started and the backup is older than that. Then apply every update immediately, because the hole that let them in is still in the restored copy.
- Clean the site in place. Needed when there's no clean backup, or when the restore would lose too much recent data (orders, for example). Replace WordPress core, plugins and themes with fresh copies from their source (
wp core verify-checksumsandwp plugin verify-checksums --allin WP-CLI show which files were changed), then check the uploads folder for PHP files, which shouldn't be there, and the database for injected scripts, unknown users and spam content.
If you aren't confident you can clean it fully, bring in a specialist cleanup service. A half-cleaned site costs more in the end.
6. Close the hole and harden
Update or remove the vulnerable plugin, apply the hardening settings above, and confirm two-factor login is on for every admin.
7. Request reviews
If Google flagged the site, request a review in Search Console under Security issues once it's clean. Do the same with any blocklists or the host's abuse team if they were involved.
8. Tell the client
Send a short, factual note: what happened, when, how you found it, what you did, and what you're doing to stop it happening again. If customer data may have been exposed (orders, accounts, form entries), tell the client straight away, because they may have legal duties to notify people. Don't guess at causes you haven't confirmed.
9. Watch it closely
Keep a close eye on the site for the next few weeks: new files, new admin users, changed content and search results. If something was missed, a reinfection often shows up within days.
After the incident
- Write down what happened and what you changed, so you'll recognize it next time
- Check your other sites for the same plugin or weakness
- If the cleanup was outside the plan, invoice it as agreed
- Ask whether the routine missed something: a slow patch, an admin account that should have been removed, a backup that wasn't off-site
Frequently asked questions
How do most WordPress sites get hacked?
Through plugins or themes with known vulnerabilities that haven't been updated, and through weak or stolen admin passwords. Core WordPress is rarely the way in when it's kept up to date.
Is a security plugin enough?
It helps, but it isn't a substitute for the routine. A security plugin can block some attacks and scan for malware, but the most important protection is patching vulnerable plugins quickly and keeping admin accounts locked down, which a plugin can't do on its own.
Should I restore from a backup or clean a hacked site?
Restore when you have a backup from before the compromise and can afford to lose the changes since. Clean in place when you can't. Either way, find and close the way in first, or the site will be hacked again.
Should cleaning up a hacked site be included in a care plan?
That's your call, but say it in writing. A common approach is to include cleanup for sites on the plan up to a set number of hours, and quote sites that were hacked before the plan started as a separate job.