In short: If a cleaned site is infected again within days, the attacker still has access. In my case the malicious code went straight into the database without a single web request: it changed the site address to a shortened link and added redirect code to the start of 471 content rows. Besides cleaning the files, you have to change the database password and the WordPress secret keys, delete unknown administrators, change the hosting password, update the outdated premium theme and notify the hosting provider.
In November I cleaned a hacked WordPress site. It had been sending visitors to foreign sites, and after the cleanup everything was in order. Two days later, in the evening, it was redirecting again. Here is what I found, and what has to be replaced on a website reinfected after cleanup, beyond the files.
The second infection was different from the first, and it showed exactly what cleaning does not cover.
What happened the second time?
Among the WordPress settings, the home value sets the site's address. Someone changed it to a shortened link that forwarded to a foreign site. On top of that, a short piece of code that redirects as soon as the page loads was added to the start of 471 content rows (posts, pages and their saved revisions).
The web server log showed no trace of this. No web request changed these values: the change was made directly in the database, in about twenty seconds. In the same minute an administrator logged in to the site.
Two things follow from this. The attacker wrote to the database without going through WordPress, so they knew the database password or had access from inside the server. And the administrator login means they also had the password of an admin account.
Why was the first cleanup not enough?
The first time, I cleaned the files. The WordPress core, the theme, the plugins and the uploads were clean, and after the second infection I checked them again and they were still clean.
Cleaning the files removes what the attacker left on the site. It does not take away what they know: the passwords. Anyone who knows the database password can rewrite the content at any time, however clean the files are.
What did we change the second time?
- The database password. It is stored in the
wp-config.phpfile, so during an earlier infection anyone with access to the files could read it. - The WordPress secret keys (salts). Changing them logs out every signed-in user, the attacker included.
- Unknown administrators. There were two admin accounts the owner did not know about, and the owner deleted them.
- The hosting password. Someone had earlier logged in to the hosting control panel from an IP address we did not recognise. We asked the hosting provider to change the password.
- The old premium theme and page builder. Both were several major versions behind. I moved the old versions outside the web root so we could roll back if needed.
The site also got a security plugin, a new login address, a limit on login attempts, and usernames can no longer be read from outside. I also deleted the leftover settings of a file manager plugin used earlier, because a plugin like that lets someone write files to the server from a browser.
What belongs to the hosting provider
If the attacker wrote to the database from inside the server, that cannot be fully ruled out from the website's side. So I wrote to the hosting provider and asked them to:
- install the fix for the October 2026 PHP vulnerability on the server (I wrote a separate article about it),
- run a malware scan across the whole server,
- check the database server log for the few minutes when the change was made,
- explain the unknown login to the hosting control panel.
Some of these are logs the site owner cannot access. Only the provider can.
Checking again days later
After a cleanup, the first days show whether it worked. For this site I scheduled an automatic check for the next morning: it reads the home value again and counts how many content rows contain the shortened link's address. If either comes back, the attacker still has access, and the server-side investigation cannot wait any longer.
I do not run the check from my own browser, because redirect malware often shows itself only to certain visitors. I request the site as a desktop computer, as a phone and as Google's search crawler.
If your site has been reinfected too
- Do not clean only the files. Change the database password, the WordPress secret keys and every administrator's password.
- Go through the user list and delete any administrator you do not know.
- Change the passwords for the hosting control panel and FTP as well.
- Update the theme and the plugins, premium ones included. A premium theme with no licence that cannot be updated is a risk in itself.
- Write to your hosting provider and ask for the checks above.
- Check the site again a few days later, from another device as well.
I collected the signs of an infection in the article on seven signs of a hacked site, and described my earlier cases here. What this kind of work costs is in the article on hacked website repair cost.
If your site got infected again after a cleanup, write to me. If someone else built your site and you do not know who has access to it, mapping that out is the first step of a website takeover.
