Security
The pharma hack: why Google thinks your site sells medication
5 September 2026 · 6 min read
On this page
Your business has nothing to do with pharmaceuticals, but your Google listing mentions them. Or your meta description, which you definitely wrote, now offers cheap medication.
This is the pharma hack — one of the oldest WordPress compromises still in wide circulation, and one of the most persistent, because it is specifically built to survive a casual cleanup.
What makes it different
Most injections are relatively blunt. The pharma hack is not. It typically:
- Serves spam only to search engine crawlers, so the site looks perfect to you
- Stores its payload in the database, not only in files, so replacing files does not remove it
- Rewrites your existing pages' titles and descriptions rather than creating new ones
- Reinstalls itself from a second copy hidden somewhere else
That last point is why people clean it three times before it sticks. There is almost always a copy you have not found.
How to confirm you have it
Search site:yourdomain.com and read the titles and descriptions rather than the URLs. The pharma hack often leaves your real pages in place and simply rewrites how they appear in search — which is exactly why a quick look at the site tells you nothing.
Fetch a page as Google. In Search Console, use URL Inspection on one of your normal pages and choose "Test live URL". Compare the rendered HTML with what you see in a browser. If the crawler version contains drug names, you have it.
Check your database for suspicious option rows. The payload frequently lives in wp_options under an innocuous-looking name, and sometimes in the postmeta table attached to real posts.
Where to look
In order of likelihood:
wp_options— injected rows, often with names that mimic real plugin settings- Theme
functions.php— a long obfuscated line after a block of whitespace - Core files, particularly
index.phpandwp-settings.php - A fake plugin folder containing a single PHP file, deactivated so it never appears in the plugins list
- PHP files in
wp-content/uploads, which should never exist - Files above the WordPress root, outside where anybody thinks to look
If you have SSH, the fastest first pass is searching for the usual obfuscation functions:
grep -rEl "(eval\(|base64_decode\(|gzinflate\()" wp-content/ --include=*.php
Removing it so it stays removed
The order matters more here than with most infections, because of the reinstall behaviour.
- Back up the infected site as evidence
- Replace core, plugins and themes with clean copies — never edit
- Clean the database, checking
wp_options,wp_postsandwp_postmeta - Delete every PHP file in uploads
- Audit scheduled tasks — this is where the reinstaller usually lives
- Look above the web root for stray PHP files
- Remove unknown admin users
- Rotate every credential, including the salts
- Clear all caches, including your CDN
- Fetch as Google again to confirm the crawler now sees clean pages
Step 10 is the one people skip, and it is the only one that actually proves the fix. Your browser was never seeing the spam in the first place.
If the spam returns within a week, you did not find the reinstaller. It is nearly always either a WordPress scheduled task or a PHP file outside the WordPress directory. Those are the two places to look again.
Repairing the search damage
Once the crawler sees clean pages:
- Request a security review in Search Console if Google flagged the site
- Use Removals for the worst affected URLs to speed up re-crawling
- Expect titles and descriptions in the search results to take a couple of weeks to correct themselves
- Watch rankings for a month — a long-running pharma hack can leave a real dent
The uncomfortable part
The pharma hack is old. Every version we clean got in through something patched years ago — an abandoned plugin, a nulled theme, or a site that had not been updated since it was built.
So the honest prevention is the boring one: update weekly and remove what you do not use. Our free plugin will tell you today whether anything on your site is currently vulnerable or abandoned, which is usually where this started.
If it is already in your search results, our cleanup is $249 and includes finding the reinstaller — the part that decides whether it is gone or just hiding.