Your WordPress site has been hacked: what to do, in order
The instinct is to delete the bad files and move on. That usually leaves the attacker's way back in. Containment first, then assessment, then cleanup, then closing the door.
The short answer
Take the site offline or into maintenance mode, take a forensic copy before changing anything, then find how they got in before cleaning up. Rotate every credential, including hosting, database, WordPress users, API keys and any password reused elsewhere. Cleaning malware without finding the entry point means it comes back, usually within days.
Your WordPress site is hacked: contain first
Before investigating, stop the damage growing. A compromised site may be sending spam, serving malware to visitors, or being used to attack other systems, and every hour of that increases the reputational and legal exposure.
- Put the site into maintenance mode or take it offline. A brief planned outage is better than continuing to serve malware
- Take a full forensic copy of files and database before you change anything. You will need it to understand what happened
- Notify the host. Many have security teams, and some will have already flagged the account
- If payment or personal data may be involved, start the disclosure clock immediately. Regulatory deadlines are shorter than most people assume
Do not skip the forensic copy
The instinct to clean immediately destroys the evidence that tells you how the attacker got in. Without that, you clean the symptom and they return through the same door. Copy first, always.
WordPress hacked: assess what happened
The goal is to establish the entry point, the extent of the compromise, and whether data was taken. That is three separate questions and the third is the one clients care about most.
Find the entry point
- Check for files modified around the time symptoms began, which narrows the search dramatically
- Compare core files against a clean WordPress release; core files should never differ
- Review the list of plugins and themes for anything with a known vulnerability, particularly ones behind on updates
- Check for administrator accounts you do not recognise, and for existing accounts whose role was recently elevated
- Look at server access logs around the first modified file for the request that created it
- Check scheduled tasks for entries that reinstall payloads
In practice, the entry point is a vulnerable plugin far more often than anything else, followed by weak or reused administrator credentials, followed by compromised hosting or FTP access. Sophisticated targeted attacks against small business WordPress sites exist but are not the common case.
Establish the extent
Look for injected content in posts and options, modified .htaccess rules, unfamiliar files in the uploads directory, backdoors in the theme's functions.php, and additions to wp-config.php. Backdoors are frequently placed in several locations specifically so that removing one still leaves access.
Clean up properly
For most compromises, restoring a known-clean backup and then patching the vulnerability is faster and more reliable than manual cleaning, because it guarantees you have not missed a backdoor. The critical word is known-clean: if the compromise happened three weeks ago and you restore from last week, you restore the backdoor along with everything else.
- Restore from a backup predating the compromise, or replace core, plugins and themes with fresh copies from source
- Never restore plugin or theme files from the compromised site; download them fresh from their origin
- Manually review wp-config.php, .htaccess and the uploads directory, which restores do not always fully clean
- Update everything to current versions before bringing the site back online
- Rotate every credential: WordPress users, database, hosting, SFTP, API keys, and anything reused elsewhere
- Force a password reset for all users and invalidate existing sessions
The conversation with your client
This is the part agencies handle worst, usually by delaying until they have good news. Clients tolerate a security incident considerably better than they tolerate discovering you knew about it for two days and said nothing.
- Tell them early, with what you know and what you do not yet know
- Be specific about whether customer data may be involved, because that determines their legal obligations as well as yours
- Give a realistic timeline rather than an optimistic one
- Follow up with a written account of the cause and what has changed to prevent recurrence
- If personal data was accessed, they may have regulatory reporting duties with short deadlines. Say so explicitly rather than assuming they know
Preventing the next one
Almost every WordPress compromise an agency deals with traces back to a component with a known, published vulnerability that had a patch available. The attack was not clever; the patching was slow. That is uncomfortable but it is also good news, because it means the fix is operational rather than technical.
- Monitor for known vulnerabilities across the whole portfolio rather than site by site
- Prioritise by exposure: a vulnerable plugin on eleven client sites matters more than one on a staging copy
- Patch security releases quickly, with a restore point taken automatically so speed does not mean risk
- Enforce strong unique credentials and two-factor authentication for administrators
- Remove unused plugins and themes entirely; deactivated code is still code on disk
- Keep off-site backups in a different failure domain, with retention long enough to predate a slow-burning compromise
- Review administrator accounts regularly, especially after staff or contractors leave
Related questions
Not on its own. Removing visible malware without finding the entry point means the attacker returns, usually quickly, because backdoors are typically placed in several locations. Find how they got in first.
Often you cannot know with certainty without server-side logs, which is why the forensic copy and your host's logs matter. If the site stored personal data and you cannot rule out access, treat it as though data was accessed and take advice on disclosure obligations. Guessing optimistically is the wrong error to make.
Yes, if the backup predates the compromise and you patch the vulnerability before going back online. If you restore a backup that already contains the backdoor, you have restored the problem along with the site.
A firewall and malware scanner add value, but they are not a substitute for patching. The overwhelming majority of compromises exploit known vulnerabilities with available patches, so the highest-leverage change is usually reducing the time between a patch being published and it being applied across your portfolio.
Related reading
Vulnerability monitoring
Portfolio-wide detection of known plugin and theme vulnerabilities, prioritised by exposure.
See the featureBackups and restore
Off-site restore-tested backups with retention deep enough for a slow compromise.
Read moreActivity logs
A timestamped record of every change, which is where an investigation starts.
Read morePatch faster across every site you manage
Vulnerability monitoring that prioritises by portfolio exposure, with safe updates so patching quickly does not mean patching recklessly.
Free during early access. No credit card required.