Security
WordPress Malware Keeps Coming Back? Look Outside WordPress
When WordPress malware keeps coming back, the problem usually isn't WordPress. You clean the files, the scanner turns green, and two days later the spam is back. That pattern almost always means a way back in survived somewhere the WordPress cleanup never looked: the hosting account.
You're in good company. Google's guide to the cloaked keywords hack notes that "20% of hacked sites get hacked again within one day." That's not because cleanups are hard. It's because they stop one layer too early.
This post is the checklist for that layer: cron jobs, FTP and SSH access, abandoned installs, and PHP settings that load code before WordPress even starts. Then the WordPress-level hiding spots that scanners miss. If you've already cleaned twice and you're tired, you can tell me what keeps coming back in a short questionnaire and I'll reply with a plan and a fixed quote within one business day.
Why WordPress malware keeps coming back: the shared-account problem
Here's the mechanism most owners never hear about.
On a typical shared hosting plan, everything in your account runs as the same server user. Your main site, the old test copy in /old/, the staging site from your last redesign, the second domain you parked in 2019. If any one of them is compromised, it can usually write to all the others.
WordPress's own hardening guide warns about the server-level version of this: on a shared server, if "a website on the same server is compromised, your website can potentially be compromised too." The same logic applies inside your own account, with even fewer walls.
So you can clean example.com perfectly, and an outdated WordPress install in example.com/old/ reinfects it overnight. Change the front lock all you like. The side window is still open.
Step 0: Back up the whole account first
Before you delete anything in this checklist, take a full account backup (files, databases and email if it's hosted there), and download it. Some of what you find will look suspicious and turn out to be real. A backup makes that a non-event.
Check 1: Cron jobs that re-download the malware
A cron job is a task the server runs on a timer, like "every 10 minutes." Attackers love them. A single line can fetch a fresh copy of the malware from their server and drop it back into your site, no matter how clean you left it.
In cPanel, open Advanced > Cron Jobs to see them, per cPanel's docs. Over SSH:
# Read-only: show this account's scheduled tasks.
crontab -lEach line is a schedule followed by a command (the format is in the crontab manual). Be suspicious of:
wgetorcurldownloading something and piping it intophporsh- long base64 strings
- PHP files with random names, or files inside
wp-content/uploads - jobs you don't remember creating, at odd intervals like every minute
Write each suspicious line down before you remove it. It often names the attacker's download server, which helps you find other infected files.
Check 2: FTP accounts and SSH keys you didn't create
Both are ways to log into the server without touching WordPress at all. Changing your WordPress password does nothing to them.
- FTP accounts. In cPanel, open Files > FTP Accounts, per cPanel's FTP docs. Delete any account you can't tie to a real person or tool. Then change the password on the ones you keep, and prefer SFTP (the encrypted version) going forward.
- SSH keys. A key in the account's
authorized_keysfile lets someone log in with no password at all.
# Read-only: list the public keys allowed to log into this account over SSH.
# Each line ends with a comment, often a name or computer. Unknown ones should go.
cat ~/.ssh/authorized_keysIn cPanel, Security > SSH Access > Manage SSH Keys shows the same thing. Remove keys you don't recognize. If a developer added one years ago and is long gone, remove it too.
Check 3: Abandoned installs and forgotten folders
In my experience, this is the most common culprit. Find every WordPress install in the account, not just the one you care about:
# Read-only: every WordPress install under your home folder, with its version.
# Old versions here are the usual way back in.
find ~ -path '*/wp-includes/version.php' -exec grep -H '^\$wp_version' {} \; 2>/dev/nullFor each result, ask one question: does anyone still use this? If not, back it up and delete it. If yes, update it and clean it like the main site. An install you're keeping "just in case" is an install an attacker is keeping too.
Look for non-WordPress leftovers while you're there: old .zip backups inside public_html, a phpinfo.php someone forgot, a file manager script from a past migration.
Check 4: PHP settings that run code before WordPress
PHP has a setting called auto_prepend_file. The PHP manual describes it as a file "automatically parsed before the main file." It can be set per folder in .user.ini or .htaccess files.
Security plugins use it legitimately (the Wordfence firewall's extended protection mode does, for example). Attackers use it too, because a file loaded this way runs before WordPress, before any plugin, and survives a full WordPress reinstall.
# Read-only: find every place auto_prepend_file is set in this account.
grep -rn --include='.user.ini' --include='php.ini' --include='.htaccess' 'auto_prepend_file' ~ 2>/dev/nullFor each hit, open the file it points to. If it's your security plugin's file, fine. If it's a random name in a random folder, that's your backdoor.
Check 5: WordPress-level backdoors that scanners miss
Once the account is clean, look inside WordPress for the hiding spots built specifically to survive a cleanup.
In October 2026, Patchstack documented a campaign with four separate ways back in. One detail is easy to miss: a "magic login" link stored as WordPress options (settings saved in the database), tied to the site's oldest administrator. In Patchstack's words, removing the vulnerable plugin, "or even the malicious one, closes none of the last three."
Here's what I check:
# Read-only: scheduled WordPress tasks. Look for hook names you can't tie to a plugin you use.
wp cron event list --fields=hook,next_run_relative,recurrence
# Read-only: must-use plugins load on every page and never appear on the Plugins screen.
ls -la wp-content/mu-plugins/
# Read-only: options with "token" or "login" in the name. Most are legitimate. Unknown ones deserve a look.
wp option list --search="*token*" --fields=option_name,autoload
wp option list --search="*login*" --fields=option_name,autoloadOne catch with listing admin users. WP-CLI's --skip-plugins flag does not skip must-use plugins. The WP-CLI docs say so directly: "mu-plugins are still loaded." So a must-use plugin that hides an admin from the Users screen can hide it from wp user list too. Query the database directly instead:
# Read-only: every account with the administrator role, straight from the database.
# Assumes the default "wp_" table prefix. Check $table_prefix in wp-config.php and adjust both names.
wp db query "SELECT u.ID, u.user_login, u.user_email, u.user_registered FROM wp_users u JOIN wp_usermeta m ON m.user_id = u.ID WHERE m.meta_key = 'wp_capabilities' AND m.meta_value LIKE '%administrator%';"The cron event list docs and option list docs cover more filters if you need them.
Check 6: The hole they came through
Everything above removes the ways back in. This step closes the original door. Without it, the attacker doesn't need a backdoor. They just do it again.
- Update WordPress core, every plugin and every theme. Delete what you don't use.
- Replace anything nulled with a genuine copy. My post on nulled WordPress themes explains why.
- Change every password: hosting, WordPress admins, SFTP, database. Then refresh the salts (the secret keys that sign login cookies), which logs everyone out.
If the account was also sending spam email, that's a sign the backdoor had a mailer attached. My guide to tracing a WordPress site that's sending spam shows how to find the exact script from the mail logs.
When moving hosts is the right call
Sometimes the hosting account itself is the problem: no SSH, no way to see cron jobs, an ancient PHP version, or a dozen forgotten sites nobody will let you delete. In that case, moving the clean site to a fresh account is often faster than auditing the old one.
The order matters, though. Clean first, then move. Migrating an infected site just gives the malware a nicer apartment. I wrote a separate guide on what to ask a host after a hack, with the isolation and backup questions that matter.
Final thoughts
When a cleaned site gets reinfected, the scanner wasn't wrong about the files. It just never looked at the cron jobs, the FTP users, the SSH keys, the forgotten installs or the PHP settings. Check the whole hosting account, then the WordPress hiding spots, then close the original hole. For the full start-to-finish order, see my complete hacked WordPress cleanup guide.
If you've already been through two rounds and want it to stay fixed, tell me how many rounds it's been. Every WordPress cleanup I take on includes the hosting-account sweep. It's the part that stops the third round.
WordPress malware keeps coming back FAQs
Why does my WordPress site keep getting reinfected?
Usually because a way back in survived the cleanup. The most common culprits are a cron job that re-downloads the malware, an old WordPress install in the same hosting account, an unknown FTP account or SSH key, a must-use plugin, or a hidden administrator. Less often, the original vulnerable plugin is still installed. A file-only scan won't catch most of these.
Will restoring a backup stop the reinfection?
Only if the backup predates the infection and you also close the hole. Many backups already contain the backdoor, because attackers often sit quietly for weeks before doing anything visible. A restore also doesn't touch cron jobs, FTP accounts, SSH keys or other sites in the account. Restore, then run the hosting-account checks, then update everything and change passwords.
What is a WordPress backdoor?
A backdoor is a hidden way for an attacker to get back into your site after you've cleaned it. It might be a small PHP file that runs commands, a secret admin account, a must-use plugin that logs them in, or a scheduled task that reinstalls the malware. Backdoors are built to look boring, so scanners and quick manual checks often miss them.
Do I need a new host if my WordPress site keeps getting hacked?
Not always. Most reinfections come from inside your own account, so a thorough sweep usually fixes it. A move makes sense if the host gives you no SSH or cron access, runs outdated PHP, or doesn't isolate accounts from each other. If you do move, clean the site first, then migrate, so you don't carry the backdoor along.
How long should I watch the site after a cleanup?
I'd watch closely for at least two weeks. Check the admin user list, the must-use plugins folder, cron jobs and the Search Console Security Issues report a few times. Run the checksum commands again after a week. Many backdoors wait a few days before reactivating, so a clean result on day one doesn't prove much on its own.
Want a second pair of eyes on your site?
Tell me what's going on in the hacked website repair questionnaire. I reply with a plan and a fixed quote within one business day.