The short answer
A website gets reinfected after cleaning because the cleanup removed what the attacker did, not how they get in. The usual causes are a hidden backdoor file, an attacker's own administrator account, a vulnerability that was never fixed, an infected database, an infected backup, or another compromised site on the same hosting account.
Key takeaways
- Removing the visible damage doesn't remove the attacker's way back in.
- Check for unknown administrator accounts. They are the simplest way back.
- Malware can live in the database, so cleaning files alone isn't enough.
- If a site has been reinfected after a cleanup, rebuilding is usually safer than cleaning again.
If your website has been cleaned and then hacked again, the cleanup dealt with the symptoms. Something that lets the attacker return is still there. These are the six causes we look for, in the order we usually check them.
1. A backdoor was left behind
A backdoor is a small hidden file, or a few lines added to a normal file, that lets the attacker run commands on your site whenever they like. Good ones are disguised with ordinary-looking names and sit in folders nobody checks, such as image upload folders.
Some backdoors repair themselves. If you delete the visible malware, a second hidden copy puts it back. Until every copy is found, the site reinfects.
How to check: look for program files in folders that should only hold images or documents, files changed around the time of the attack, and code that has been deliberately scrambled so it's hard to read.
2. The attacker has their own account
Many attackers create a website administrator account for themselves. After that they don't need malware at all. They log in like a staff member. Changing your own password doesn't help, because they aren't using it.
How to check: review every administrator, file transfer user and database user. Remove any that nobody on your team can explain. Check for special access passwords created for apps as well.
3. The way in was never closed
Every attack starts somewhere: an outdated plugin or theme, an old version of the site's programming language, a custom page that doesn't check who is logged in, or a stolen password. If that weakness is still there, the attacker, or the next one, uses it again.
How to check: list every piece of software the site runs and its version, and compare each against known security problems. Review any custom-built pages that accept input, especially forms and search boxes.
4. The database is infected too
Cleanups often look only at files. Attackers also write into the database: redirects added to every page, changed site settings, spam posts. Replace all the files and the redirects are still there.
How to check: search the database for links and scripts you didn't add, and compare key settings such as the site's address against what they should be.
5. The backup you restored was already infected
Restoring a backup feels like a clean start. If the attack began before that backup was made, you have restored the backdoor along with everything else.
How to check: find the earliest sign of the attack, then compare it with the backup's date. Treat any backup you can't date as infected.
6. Another site on the same hosting account is compromised
If several websites share one hosting account, an attacker who controls one can usually reach the others. Cleaning one site while its neighbor stays infected doesn't hold.
How to check: list everything in the hosting account, including old test sites and forgotten folders.
What actually stops it
Find the way in, remove every way back, change every password, and update what's out of date. When a site has already been reinfected after a cleanup, or when both the files and the database are infected, rebuilding on clean hosting and moving only the content across is usually the safer and faster route.
Frequently asked questions
My site was cleaned last month. Why is it hacked again?
Most likely something that lets the attacker back in was left behind: a hidden file, an account they created, or the original weakness. A cleanup that removes only the visible symptoms will usually fail again within days or weeks.
Does updating WordPress or PHP stop the reinfection?
Updating closes known weaknesses, which helps, but it doesn't remove a backdoor or an attacker's account that already exists. You need both: remove every way back in, then update.
How quickly can a site be reinfected?
Within minutes. Some malware checks constantly that its files are still in place and puts them back as soon as they are removed, or copies itself back from another hidden location.
Is a security plugin enough to prevent this?
A security plugin helps on a clean site. On a site the attacker already controls, they can simply switch it off. It can't replace finding and closing the way in.