The site was cleaned, it works again, and a few days or weeks later the same symptoms are back. It is almost never bad luck. A cleanup removes what was planted; it does not necessarily remove what let it be planted, or what lets the attacker come back. This guide explains the three ways reinfection happens, where each one hides, and what to close so the hack stays gone.
By Simon Vasconcelos Lee
Published on 22 November 202611 minute read
wp-content/uploads, mu-plugins, .user.ini files, scheduled tasks, the database.wp-config.php keys.A cleanup answers “what was planted?”: code that redirects, spam pages, a malicious script. Reinfection answers a different question: “how did it get in, and what lets it come back?”. As long as that stays open, the site falls again, often with the same symptom. Three mechanisms nearly always explain it:
The cleanup is visible; closing the doors is not, and it is what matters. If your site has just been hacked, the hacked WordPress site page covers the first hour; this guide deals with what makes the hack come back.
A backdoor sits where a cleanup does not look: outside the core files that get replaced, outside the active theme, often somewhere that never shows in the admin area. Of the 39,594 sites its team cleaned in 2023, Sucuri found at least one on 49.21%: one hacked site in two.
| Location | What you find there | How to check it |
|---|---|---|
wp-content/uploads | PHP files, sometimes disguised as images or tucked into a dated subfolder | No PHP file belongs there, apart from an empty index.php |
wp-content/mu-plugins | A “must-use” plugin, loaded automatically and missing from the Plugins screen | Every file in this folder must be accounted for |
.user.ini, php.ini, .htaccess | An auto_prepend_file directive that runs a file before every page | Search the whole hosting account for the directive |
wp-content/plugins | A plugin hidden from the admin list, or a file added inside a legitimate plugin | Compare the folder with the list, and the files with the checksums |
| Database | Code in wp_options or in page content, a setting that loads a script | Search for <script, eval(, base64_decode( |
| Scheduled tasks | A WP-Cron event that puts the code back at regular intervals | List the events, spot the unknown names |
| Inactive themes | An old theme left installed, vulnerable or modified | Delete every theme you do not use |
find wp-content/uploads -name "*.php"
ls -la wp-content/mu-plugins
grep -rn "auto_prepend_file" --include=".user.ini" --include="php.ini" --include=".htaccess" ~
ls wp-content/plugins
wp plugin list --fields=name,status,version
wp plugin verify-checksums --all
wp cron event list
The third command searches the whole home directory of the hosting account, not just the site: a directive placed above the site’s folder still applies to it. Comparing the contents of the plugins folder with the WP-CLI list exposes a plugin that is on disk but missing from the list.
Changing the password on your own account does not close the access the attacker gave themselves. Each one has to be checked on its own:
wp-config.php logs every session out, the attacker’s included.~/.ssh/authorized_keys), database users, delegated access to the control panel. Wordfence names compromised hosting credentials as a frequent source of intrusion.wp user list --role=administrator --fields=ID,user_login,user_email,user_registered
wp user application-password list 1
wp config shuffle-salts
The second command lists the application passwords of user number 1: repeat it for each administrator, and revoke any that nobody created with wp user application-password delete.
The original hole is the piece people look for least, and the one that matters most. Two clues point to it: the date of the first malicious file, and the requests the server received that day.
find . -name "*.php" -newermt "2026-10-01" ! -newermt "2026-10-08"
grep "07/Oct/2026" access.log | grep "POST" | grep -v "wp-cron.php"
A burst of requests to a plugin file, to admin-ajax.php with an unusual parameter, or to xmlrpc.php, just before the first file appeared, points to the door. Then check each plugin and its version against the public vulnerability databases (WPScan, Patchstack, Wordfence Intelligence): a plugin flagged as vulnerable in the installed version is the prime suspect.
Plugins carry the bulk of the flaws. In 2025, Patchstack recorded 11,334 new vulnerabilities in the WordPress ecosystem, 91% of them in plugins and only 6 in core; 46% had no fix from their developer by the time they were made public. And attacks follow closely: for flaws exploited in 2025, Patchstack measures a weighted median of five hours to first exploit.
The number of plugins on a site gives the measure of its exposure. Across the 3664 SMB WordPress sites in our monthly survey, the median site depends on 3 different vendors, and 66% of sites run at least one plugin that is not in the public directory, whose updates go through a licence and the vendor’s own account. Let the licence lapse, and the plugin stops receiving its fixes.
Two special cases. A plugin removed from the WordPress.org directory over an unpatched flaw is not flagged in the site’s admin: it stays installed, with no update ever coming (1,614 plugins and themes were removed for that reason in 2024, according to Patchstack). And a premium plugin downloaded from anywhere other than its vendor (a so-called “nulled” version) routinely ships with its own malicious code, and never gets updated.
Several sites installed in the same hosting account usually share the same system user: a malicious file dropped by one can write into the others. An old test site, a previous version in an /old folder, an abandoned install on a subdomain: any of them can reinfect a site that has just been cleaned. List everything the account holds, and clean or delete every install, not just the one showing the symptom.
wp-config.php.Restoring a backup is not a cleanup. The intrusion often happens days or weeks before the first symptoms: a recent backup may already contain the backdoor, and every backup contains the original hole.
A site that has been cleaned and closed becomes vulnerable again the day one of its plugins ships a fix that nobody applies. So the third infection is prevented less by a tool than by a person: someone who follows every vendor’s fixes, applies updates, keeps an eye on files and accounts, and checks the backups. If nobody in-house does that, it is the question to settle before any other.
After two cleanups, the question becomes: who looks after the site from now on? Simafri takes over your WordPress site, puts it back online on a foundation we host, secure and keep up to date, and looks after it month after month. You keep your domain name and your content.
Because one of three causes is still there: a backdoor the cleanup missed, access that is still valid (an added administrator account, a stolen password, an application password), or the original hole, usually a vulnerable plugin still installed in the same version.
Rarely. The intrusion often comes days or weeks before the first symptoms: a recent backup may contain the backdoor, and every backup contains the hole the attacker came in through. Restoring without closing that hole puts the site back in the state that let the hack happen.
No. A backdoor works without a password, an administrator account created by the attacker has its own, and application passwords are revoked separately. Change every credential from a clean device, delete unknown accounts, revoke application passwords and renew the keys in wp-config.php.
The cause is almost always in the site itself: a vulnerable plugin, access that is still valid, a backdoor. Moving hosts while taking those along just moves the problem. Also check the other sites in the same account, which can reinfect the one you are cleaning.
Simafri
Let's talk about your project
Tell us what you need in a few words: we will get back to you quickly.
Thank you! Your request has been sent. We'll get back to you shortly.
Prefer email? Write to us at support@simafri.com.