When an Affiliate Site Gets Hacked: Pharma Spam Injection, the 'This Site May Be Hacked' Label, Cleaning It Up, Recovering in Search Console, and the Backup Setup That Makes It a One-Hour Problem
Affiliate sites get hacked for a dull reason: they run WordPress with a theme and a dozen plugins, some of them abandoned, and nobody updates them because the site has been earning quietly for two years. Then one morning Search Console shows the site ranking for pharmaceutical terms it has never written about.
The damage is to search traffic, which for an affiliate site is the business. The fix is a fixed sequence, and with the right backups it's an hour. Without them it's a week.
This post covers how a hack shows up (the Security issues report, the Performance report, a site: search), how to confirm it when the pages look clean in your browser, the clean-up order that doesn't leave the back door open, the review request that lifts the "This site may be hacked" label and how long it takes.
It also covers what the hack does to rankings and for how long, what to tell Amazon if the injected pages carried your links, and the backup and update routine that turns the next one into a short job.
It assumes a WordPress site; the sequence is the same elsewhere, with different file names.
The short answer
Confirm in Search Console's Security issues report and with a site: search. Change every credential, restore a backup from before the hack, update WordPress, the theme and every plugin, delete what you don't use, check the uploads folder and .htaccess, and 410 the injected URLs.
Then request a review from the Security issues report, describing what you did. Expect the label to lift in days to weeks and rankings to follow. Set up daily off-server backups so the next time is a restore, not a hunt.
How it shows up
- The Security issues report. Google states that if its evaluation determines a site was hacked, the report shows its findings, with a sample of affected URLs; pages affected can appear with a warning label in results or an interstitial in the browser. The sample isn't complete, and sometimes there's an issue with no sample URLs, which doesn't mean no pages are affected.
- The Performance report. Often earlier than the security notice: a run of queries for pills, replica handbags, casino terms or essay services, on URLs you didn't write. The regex-filter post's "what's left" view surfaces them.
- A site: search. Google's own advice for checking: search site:yourdomain.com and read the results for pages you didn't create. Hacked pages are frequently cloaked, so the listing in results is the only place you'll see them.
- Readers. A message saying your site redirected them somewhere, or that their browser warned them. Treat one such message as confirmation, not noise.
Confirming it when the pages look fine
Google warns that hackers hide spam with cloaking, showing the injected content to search engines and a normal page to visitors, and advises against opening infected pages in a browser. Use URL Inspection in Search Console on a sample URL and view the crawled page; that's what Googlebot saw. Or fetch the page from the command line with a Googlebot user agent and read the HTML.
Also check: new admin users in WordPress, files in wp-content/uploads with .php extensions, a modified .htaccess with redirect rules you didn't write, and recently changed core files. Any of those confirms it even if the report hasn't caught up.
The clean-up order
- Take the site offline or into maintenance mode if it's redirecting visitors. A day of no traffic costs less than a week of readers being sent to malware.
- Change every credential. WordPress admin passwords, the database password, FTP and SFTP, the hosting control panel, and the salts in wp-config.php. Remove admin users you don't recognise. A hack with a back door survives a clean-up that skips this step.
- Restore from a backup taken before the hack. Files and database both. If you don't know when the hack started, go back further than you think; the first injected query in the Performance report gives a date.
- Update everything. WordPress core, the theme, every plugin. Delete plugins and themes you don't use rather than leaving them inactive; inactive code can still be exploited. The plugins post has the short list worth keeping.
- Check the places restores miss. The uploads folder for executable files, .htaccess and any server config for redirect rules, cron jobs and scheduled tasks, and the database's options table for injected scripts.
- Remove the injected URLs properly. After the restore they should 404; set them to return 410 if you can, so Google drops them faster. Don't noindex them and leave them live, and don't robots-block them: Google says pages must be crawlable for it to confirm they're clean.
- Scan. Your host's malware scanner or a reputable security plugin, as a check on the above, not a substitute for it.
Requesting the review
In the Security issues report, expand the issue and select Request a review. Google asks that you fix the issue throughout the site first (fixing some pages doesn't earn a partial return), fix every issue listed if there are several, and describe what you did for each category.
For example, write "removed the injected content and corrected the vulnerability by updating an out-of-date plugin". Don't resubmit while a review is pending.
Google says reviews for sites hacked with spam can take up to several weeks, and that requesting a review before the issue is fixed makes the next turnaround longer. In practice, a clean site with a clear description often clears within days. The "This site may be hacked" notice stays until the review succeeds.
What it costs in rankings
While the hack is live, the labelled or dropped pages lose their traffic outright, and the injected pages dilute the site, so guides that weren't touched can slip too.
After a successful review, Google recrawls and the clean pages generally recover over a few weeks. A site that was hacked for months recovers more slowly than one caught in days, which is the argument for watching the Performance report weekly.
Spam backlinks pointing at the injected pages sometimes keep arriving after clean-up; the spam backlinks post covers why that's usually harmless.
If the injected pages carried your Amazon links
Some injection kits copy your page templates, affiliate tag included, so the spam pages carry your Associates ID into search results for terms Amazon would rather not be associated with.
Once the site is clean, it's worth a short note to Associates support saying the site was compromised on these dates, the pages have been removed, and any clicks from them weren't yours. It's rarely needed, and it's the kind of record that helps if the account is ever reviewed.
Making the next one an hour
- Daily backups, off the server, files and database, two weeks of history. A backup on the same server is lost with the server. Managed hosts usually include this; otherwise a plugin writing to cloud storage.
- Test a restore once. On a staging copy. A backup that's never been restored is a hope.
- Update monthly, at least. Core, theme, plugins, on a day you'll notice if something breaks. Delete what you don't use.
- Two-factor on every admin account and no shared logins.
- Weekly glance at the Performance report for queries that aren't yours. It's thirty seconds, and it's how hacks get caught in days rather than months.
Doing it with AffSERP
AffSERP publishes guides through its WordPress plugin as ordinary posts, so a restore from backup brings them back exactly as published, and a Refresh run afterwards re-pulls prices and availability so the restored guides are current rather than two weeks old.
Because the guides live in AffSERP as well as on the site, a guide lost in a bad restore can be re-published from the app.
And since the plugin adds no front-end code of its own, it's one less surface to keep patched; the Competitor Sitemap Explorer can also show whether a competitor that suddenly outranks you is carrying hundreds of injected URLs of its own, which happens more often than you'd think.
FAQ
How do I know if my affiliate site has been hacked?
Search Console tells you first. The Security issues report shows Google's findings when it determines a site was hacked, with sample affected URLs, and Google may email the property owners. Before that, the Performance report often gives it away: queries for pills, luxury handbags or casino terms that have nothing to do with your site, on URLs you didn't create. Confirm with a site: search for your domain, which lists pages a hacker added, and with URL Inspection's view of the crawled page, because hacked content is often cloaked so that a normal browser visit shows nothing.
How do I get Google to remove the 'This site may be hacked' message?
Clean the whole site, then request a review from the Security issues report in Search Console. Google says the notice won't be removed until the owner takes action, that fixing only some pages earns no partial return to results, and that the request should describe what was done for each category of hacked spam, for example that injected content was removed and an out-of-date plugin updated. Reviews for sites hacked with spam can take up to several weeks, and submitting before the site is clean makes the next review slower. Don't resubmit while one is pending.
What does a hack do to an affiliate site's rankings?
Three things, in order. Injected pages and cloaked content get the site labelled in results or dropped from them, which cuts traffic immediately. The spam pages dilute the site, so even unlabelled guides can slip while they exist. And after clean-up and a successful review, rankings usually recover over a few weeks as Google recrawls the clean pages, though a site that stays hacked for months recovers more slowly. The affiliate links in your guides are unaffected by the hack itself; what you lose is the traffic that reached them.
What backups does an affiliate site need?
Daily automated backups of both files and the database, kept off the web server, with at least two weeks of history so you can go back to a version before the hack rather than the night after it. Most managed WordPress hosts include this; for the rest, a backup plugin writing to cloud storage does the job. Test a restore once, before you need it. With that in place, recovery is: change every credential, restore a known-good copy, update everything, re-check, and request review, which is an hour's work instead of a week of hunting for files.
AffSERP guides are ordinary WordPress posts kept in the app as well, so a restore brings them back and a Refresh run makes them current; the plugin adds no front-end code to patch.
Start with free words