Samuel Arendt

The infection that came back seconds after the site was cleaned

When a website is hacked, the most common response is to clean the files and reinstall the system. Most of the time that works. But there are cases in which the infection comes back right away, because the attacker did not get in through the website.

The infection that always came back

For many years, I cleaned hacked websites, most of them on WordPress. The first step was to stop the infection. I compressed all of the site's files into a single archive, deleted everything else, and left only a page online saying the site was under maintenance. That way, no script from the attack kept running.

Next, I uploaded a fresh copy of the files for WordPress, the plugins, and the theme the site used. The custom code written for the site I reviewed file by file, looking for changes or strange snippets, and I only uploaded what was clean. I also checked the folder of files uploaded by users, to make sure there was no PHP file or file with another extension that could be executed, and no disguised files whose type did not match their extension. Finally, I reviewed the database and only then put the site back online.

On one of those sites, none of this worked. I went through the whole procedure and, a few seconds after the site went back online, the malicious files were back. Because the infection returned so quickly, I began to suspect that the problem was not in the site's code. Something on the server was recreating those files.

So I logged into cPanel, the hosting control panel, and opened the list of scheduled tasks, known as cron jobs. There was a scheduled task that recreated the attack script.

The attacker had not come in through WordPress. They had gotten into the hosting panel, which used a very simple password, and created that task. As long as they had that password, any cleanup of the site would be undone within seconds.

This technique is well known. MITRE ATT&CK, a public catalog of attack techniques, describes how attackers use cron to run malicious code repeatedly and keep access to a server.

Other cases where cleaning does not work

The hosting panel is not the only case. Sucuri, a company that specializes in cleaning hacked websites, and Patchstack, which tracks security flaws in WordPress, have documented other situations in which cleaning the files and reinstalling WordPress is not enough.

Plugins kept on a separate tab

WordPress has a folder for must-use plugins, called mu-plugins. According to the official documentation, they are activated automatically, cannot be deactivated from the dashboard, and do not appear in the regular plugin list, only on a separate tab called "Must-Use". In 2025, Sucuri found malicious code in that folder that downloaded the rest of the attack and stored it in the database. Reinstalling WordPress or updating the plugins does not touch that folder.

An infection that rebuilds itself

Malware described by Sucuri in September 2026 spreads across several places at once: a plugin, a theme file, a PHP configuration file that runs code before every page, a row in the database, and the server's memory. Each part recreates the others, and a complete cleanup of the files fails, because the next visit to the site restores everything from the database or from memory. In this case, the order of the cleanup matters. First you have to stop the code from running and delete the copies kept outside the files, in the database and in memory, and only then remove the files, all in one pass. It is the same logic as taking all the files offline before starting the cleanup: keeping the attack from running while the site is being cleaned.

A trigger hidden in the database

Databases allow rules that run on their own when something happens, called triggers. In attacks reported in 2021, the attacker created one of these rules: when someone posted a comment containing a specific phrase, the database created a new administrator user. No file on the site was involved. That is why deleting suspicious users does not guarantee that every way in has been closed.

A forgotten site on the same hosting account

Many companies keep old websites that nobody uses anymore on the same hosting account. If one of those sites is hacked, the attacker can reach the other sites on the account. Sucuri calls this cross-contamination and explains that a single neglected site can keep reinfecting up-to-date, hardened sites on the same account. Cleaning only the main site does not solve the problem while the forgotten site is still there.

A trusted plugin that changed owners

Sometimes the attack arrives through a plugin's official update. In 2025, the company EssentialPlugin sold its portfolio of WordPress plugins. According to Patchstack, the new owner's first code change, in September 2025, planted malicious code in more than 20 plugins, disguised as a compatibility update. The code stayed dormant for seven months and was triggered on April 5, 2026. Two days later, the WordPress.org team closed the plugins in the official directory and pushed a forced update that, in Patchstack's words, attempts to remove the malicious code. Even so, anyone who used these plugins should check whether the site is clean.

What to check

To reduce these risks, it is worth checking with whoever maintains the site:

  • who has access to the hosting panel, whether the password is strong, and whether two-factor authentication is turned on;
  • whether the server's scheduled tasks are reviewed from time to time;
  • whether the mu-plugins folder contains only what the company installed;
  • whether the cleanup of an attack includes the database, and not just the files;
  • whether there are old sites on the same hosting account that can be removed;
  • whether any plugin used on the site has changed owners or been removed from the official directory.

If the site is hacked again right after a cleanup, the investigation has to go beyond the site's files. The hosting panel, the scheduled tasks, the database, and the other sites on the same account also need to be checked.

If your company is weighing something similar or needs support on this topic, reach me on LinkedIn or WhatsApp.

References

#Operations, #Software Quality