In this guide
1. Lock out the attacker completely
Do this first, because a valid login lets an attacker back in without any malware at all.
- Change every password: hosting control panel, SFTP/SSH users, the database, every WordPress administrator and editor, and the hosting email account.
- Revoke application passwords before anything else, because they keep working after a password change: Users → Profile → Application Passwords, or
wp user application-password delete <user> --all. - End all login sessions and replace the security keys:
wp config shuffle-saltssigns everyone out. - Remove unknown users, including accounts that look like they belong to WordPress, your host, or “support”.
- Reconnect remote services with fresh keys: management dashboards, backup services, SMTP and API keys stored in plugins.
- Tell everyone who logged in while the site was infected to close all its tabs, clear the site’s data in their browser, and change any password they typed in during that time.
2. Close the hole they came in through
A cleanup that doesn’t find the entry point is a temporary cleanup. Usually it’s one of these: an outdated plugin or theme with a known vulnerability, a nulled (pirated) plugin, a weak or reused password, or another site in the same hosting account. Fix it:
- update WordPress, every plugin and every theme;
- delete plugins and themes you don’t use, because deactivated still means attackable;
- replace nulled software with genuine copies, or remove it;
- clean, or remove, every other site in the same hosting account.
3. Harden the basics
- Turn on two-factor authentication for every admin.
- Add
define( 'DISALLOW_FILE_EDIT', true );towp-config.php. - Block PHP execution in
wp-content/uploads. - Set sensible file permissions (folders 755, files 644,
wp-config.phpas strict as your host allows). - Put a firewall in front of the site, either a security plugin or a cloud firewall.
- Remove file manager plugins once you don’t need them.
The full list, with code snippets, is in my WordPress security checklist.
4. Start fresh with backups
Your old backups may contain the malware. Make a new full backup of the clean site and label it clearly. That’s your new baseline. Then set up automatic off-site backups that go back several weeks, so a future problem never forces you to restore an infected copy.
5. Clean up the outside world
- Google Search Console: request a review if there was a security warning, remove unknown owners, and submit your sitemap.
- Hosting provider: if the site was suspended, send them a summary of what was removed.
- Blocklists: check whether antivirus vendors still flag the site. See antivirus and browser warnings.
- Email: if the site was sending spam, check your domain and server IP against spam blacklists.
- Customers: if personal or payment data may have been exposed, check your legal obligations.
6. Watch closely for 30 days
Reinfections usually show up within the first days or weeks:
- run a malware scan daily or weekly;
- check Users and recently modified files every week;
- keep Search Console alerts on, and add uptime monitoring;
- test the site on a phone through a Google search now and then.
If the same problem returns, something was missed. See why WordPress malware keeps coming back.
From my cleanup work: the reinfection I see most often after someone else’s cleanup isn’t clever malware. It’s an attacker logging in with a password that was never changed, or an application password nobody knew existed. Step 1 alone prevents a large share of repeat hacks.
Want this done and kept up for you?
Everything on this page is part of my malware cleanup, and the security care plan keeps it in place every month afterwards.