WordPress Pharma Hack: How a Website Can Look Perfectly Normal While Being Compromised

wordpress pharma hack

There is a common assumption about hacked websites: if a site has been compromised, you will notice.

The homepage will change. Visitors will be redirected somewhere suspicious. An error will appear. The website will stop working. Something, somewhere, will make it obvious that there is a problem.

That is not always what happens.

I recently dealt with one of the most well-hidden WordPress compromises I have encountered in years of managing websites.

From the outside, the website looked completely normal. Its legitimate pages were online, the content was intact, and there was nothing in the everyday user experience to suggest what was happening behind the scenes.

On the server, however, the situation was very different.

More than 1,500 malicious PHP files had been introduced into the WordPress installation, many with filenames related to Viagra, Cialis and other pharmaceutical products. At the same time, Google had started indexing pharmaceutical spam URLs associated with the legitimate domain — URLs that had never been created as actual website pages.

This is commonly referred to as a WordPress pharma hack.

What made this incident particularly useful as a case study was not simply the attack itself. It was what happened during the recovery: a clean backup did not initially remove the malicious files, updating WordPress was not enough, and even after the server had been cleaned, Google continued to display the spam URLs.

This is what it actually took to recover the website.

What is a WordPress pharma hack?

A pharma hack is a type of website compromise in which attackers use a legitimate website to host, generate or promote spam content, typically related to pharmaceutical products.

The names vary — Viagra, Cialis, Kamagra, Levitra and countless variations — but the objective is generally the same: to exploit the reputation and search authority of an existing domain in order to get unwanted pages or URLs indexed by search engines.

One of the reasons these attacks can remain undetected is that the legitimate website may continue to function normally.

There was no “Viagra” link in the navigation of this website. There were no obvious pharmaceutical posts inside WordPress. A regular visitor could browse the site without seeing anything unusual.

The spam became visible primarily through specific Google searches involving the domain.

This is an important distinction: a website can have a perfectly normal public-facing version while simultaneously developing an entirely different footprint in Google Search.

In more sophisticated attacks, cloaking can also be used, serving different content to search-engine crawlers and normal visitors.

“But the website was being updated”

The website in this case had not simply been abandoned.

It was a site I had managed for years, and updates were performed as part of its regular maintenance.

That matters because one of the first assumptions people make when a WordPress website is compromised is that somebody must have neglected its updates.

Certainly, abandoned WordPress installations carry significantly more risk.

But that is not the only way a compromise happens.

Software vulnerabilities are not necessarily known when a particular version is released. A version considered safe today may be found tomorrow to contain a vulnerability.

And once a serious vulnerability becomes public — particularly one that can be exploited automatically — the race between attackers and website administrators begins.

Bots do not care whether a website is famous or receives millions of visitors. They can scan enormous numbers of WordPress installations looking for the same vulnerable component.

That is relevant to what happened here.

Avada and a critical 2026 vulnerability

This website had been built using Avada, together with its associated builder and core plugins.

On August 25, 2026, Avada released version 7.16.1 and disclosed that it fixed a remote code execution vulnerability in the Fusion Patcher.

The related vulnerability, CVE-2026-18431, affected Avada versions up to and including 7.16. Patchstack rated it CVSS 9.8 and described it as an unauthenticated arbitrary file-write issue capable of allowing malicious files to be written to the server. It was patched in Avada 7.16.1.

When I restored an earlier backup during the recovery process, the installation contained, among other components:

Avada Builder 3.15.6
Avada Core 5.15.6

There had also been another real-world complication.

At an earlier point, updating the Avada stack had created a compatibility problem on the live website. To keep the production site functioning correctly, I had temporarily rolled the installation back to the previous stable version while the incompatibility was being resolved.

This is one of the uncomfortable realities of maintaining production websites.

“Install every update immediately” sounds simple until an update breaks part of a live site.

At that point, the developer has two responsibilities that can temporarily conflict: maintaining availability and maintaining the newest possible software stack.

A rollback can be the correct short-term decision. But it should remain a temporary decision, because remaining on an older release also extends the period of security exposure.

This incident reinforced something I already believe strongly: important updates should ideally be tested in a staging environment, and a rollback should be treated as a temporary recovery measure rather than a permanent solution.

I also want to be precise about attribution.

I do not have sufficient forensic evidence to state that CVE-2026-18431 was definitively the entry point used in this particular attack. Proving that would require complete server logs and forensic analysis around the exact time of compromise.

What we do have is a clear technical compatibility between the type of vulnerability disclosed at the time — unauthenticated arbitrary file writing / remote code execution — and what was ultimately discovered on the server: unauthorised PHP files.

That distinction matters.

Security analysis should not turn correlation into certainty simply because the explanation appears plausible.

This was also the last website I built with Avada

There is another aspect of this case that is relevant to the way I build websites today.

This was the last website I had originally developed using Avada.

That is not meant as criticism of Avada. It remains actively maintained software, and its developers issued security updates when vulnerabilities were identified. Indeed, only weeks after 7.16.1, Avada 7.16.2 was released on September 30 with fixes for six additional security issues and further security hardening.

But development stacks evolve.

For newer projects, I have moved to different themes and lighter WordPress architectures that better match the way I now want to build, optimise and maintain websites.

The mistake is not that a website was built eight years ago using a technology that made sense at the time.

The mistake is assuming that because the website still loads correctly in a browser, its underlying architecture should remain untouched indefinitely.

More on that later.

Where the malicious PHP files were hiding

One of the malicious files found during the investigation was located under a path such as:

wp-includes/css/dist/preferences/styles/50mg_viagra.php

That path is worth looking at carefully.

The attacker had not simply created an obvious directory called /malware/.

The malicious PHP file was placed deep inside the legitimate WordPress core directory structure, under folders associated with CSS assets.

To anyone casually browsing thousands of WordPress files and directories, it is extremely easy for something like this to disappear into the noise.

And this led to one of the most important lessons of the entire recovery.

Why restoring a clean backup did not remove the malware

The obvious first response to discovering the compromise was to restore a known-clean backup from before the attack.

We restored the backup.

The malicious files remained.

We tried an earlier clean restore.

Some of the malicious files were still there.

At first, this sounds impossible.

If the backup predates the compromise, why would files introduced later still exist?

Because restoring a backup does not necessarily mean deleting the current filesystem first and recreating it exactly as it existed on the backup date.

Depending on the restore method, the operation may copy the backed-up files over the existing installation.

Files that exist in both locations are replaced.

But a malicious file that was created later and therefore does not exist at all in the backup may simply be left untouched.

Plesk has discussed this behaviour in relation to WordPress Toolkit restores: restoring files does not necessarily remove additional files that are absent from the backup, which is why a genuinely clean restoration may require an empty document root first.

That was exactly the problem here.

The backup itself was clean.

The malicious PHP files were additional files that had been introduced into legitimate WordPress directories after the backup was created.

The restore had nothing with which to overwrite them.

They simply stayed where they were.

This is also why saying “they were in a CSS folder that WordPress does not update” would be inaccurate.

The real issue was not the folder.

The issue was that they were unauthorised extra files inside an otherwise legitimate directory tree.

A WordPress update is not a malware-cleaning system either. Updating core files does not mean WordPress will identify and delete every unknown PHP file an attacker may have placed somewhere under wp-includes.

That distinction became crucial.

Restoring a clean backup over a compromised filesystem is not necessarily the same thing as performing a clean restore.

The recovery required a completely new document root

Once it became clear that malicious files were surviving the restore process, I stopped trying to repair the existing directory.

Instead, the entire existing document root was renamed and isolated as infected.

A new, empty directory was then created for the live domain.

The clean backup was restored into that empty location.

That changed the situation completely.

We were no longer copying legitimate files over a filesystem whose full contents could not be trusted.

We were starting with nothing and introducing only the files contained in the known-clean backup.

After the new installation had been checked and confirmed to be functioning correctly, the old infected directory was permanently removed from the hosting account.

That final deletion matters too.

Renaming an infected directory does not make its contents harmless from the perspective of a hosting-account malware scan. If those malicious PHP files still exist somewhere under the account, a server-wide scan can continue to detect them.

Isolation was temporary.

Permanent deletion was part of the cleanup.

The files were not the only problem

The investigation also included the WordPress users.

A user account existed that did not belong to any authorised administrator.

It was removed.

This is another reason malware cleanup should never be reduced to “find suspicious PHP files and delete them”.

A compromised installation should also be checked for:

unauthorised WordPress administrators, FTP or SFTP accounts, modified configuration files, database injections, backdoors, scheduled tasks, API credentials, redirects and other persistence mechanisms.

Deleting the visible payload while leaving an attacker-controlled administrator account is not recovery.

It is cosmetic cleanup.

Plugins were not simply updated

Once the clean installation was restored, WordPress, the theme and the plugins were brought up to date.

For Avada Core and Avada Builder, I deliberately did not simply update over the existing plugin directories.

The old copies were deactivated and removed.

Fresh ZIP packages were downloaded from the official Avada account and installed again.

The recovered site ultimately ran:

Avada 7.16.2
Avada Builder 3.16.2
Avada Core 5.16.2

This mattered because after a real compromise, I wanted clean plugin directories from known official packages rather than relying solely on an in-place update.

And the timing is instructive: Avada 7.16.2 itself included six additional security fixes and further hardening.

Security is not a permanent status assigned to a version of software.

It changes as vulnerabilities are discovered, disclosed and patched.

After a compromise, old credentials should no longer be trusted automatically

Once the filesystem was clean, the next stage was credential rotation.

If an attacker has reached the point where arbitrary PHP can be executed on a WordPress installation, it is reasonable to assume that configuration data may potentially have been accessible as well.

For example, wp-config.php contains database credentials.

As part of the recovery process:

the Plesk/hosting password was changed, the WordPress administrator password was changed, an unauthorised WordPress user was removed, and instead of continuing to rely on the previous database credentials, a new database user and a new database password were created and configured in wp-config.php.

FTP/SFTP access was also reviewed.

Finally, the WordPress authentication keys and salts were regenerated.

This last step is easy to overlook.

WordPress uses its security keys and salts when generating and validating authentication cookies. Regenerating them invalidates previous login sessions and forces authenticated users to log in again.

After an actual compromise, that is exactly what you want.

Malware cleanup without credential and session cleanup leaves part of the job unfinished.

The server was clean. Google was not.

Once the website had been restored, another problem remained.

Google was still showing search results for pharmaceutical spam pages.

This is where it is important to separate two completely different systems:

the current state of the server and Google’s existing index.

Google had already discovered spam URLs while the website was compromised.

Deleting the malicious files from the server does not instantly remove all previously indexed URLs from Google.

Google has to revisit them.

In Google Search Console, both Security Issues and Manual Actions were checked.

Neither showed an active issue.

That is important in itself.

The absence of a Search Console security warning does not prove that a server is clean.

And, conversely, seeing old pharmaceutical URLs in Google after a cleanup does not necessarily mean that the live installation is still compromised.

The filesystem and the search index have different timelines.

Why manually removing hundreds or thousands of spam URLs is not the solution

Google Search Console includes the Removals tool, which can temporarily hide URLs from Search.

That is useful when a small number of highly visible hacked results need to disappear quickly.

It is not a realistic forensic-cleanup workflow for hundreds or thousands of URLs.

More importantly, a Search Console removal request is temporary.

The durable solution is for the URL itself to stop serving the malicious content.

When Google crawls it again, the server should return an appropriate response such as:

404 Not Found

or

410 Gone.

Once Google repeatedly sees that the content no longer exists, those URLs can disappear naturally from the index.

That means the real objective is not:

“How do I manually delete 1,500 URLs from Google?”

It is:

“How do I ensure those 1,500 URLs no longer resolve to malicious content when Google returns?”

This also means hacked URLs should not simply be blocked with robots.txt before Google has had an opportunity to recrawl them. If Googlebot is prevented from visiting the URL, it becomes harder for Google to observe that the unwanted page has actually disappeared.

The Search Console Removals tool is useful for urgency.

Correct server responses are what solve the underlying indexing problem.

The recovery workflow in practice

If I had to summarise the complete incident-response process, it would look like this:

  1. Confirm the compromise and scan the entire hosting account for unauthorised files.
  2. Inspect WordPress users and remove unknown accounts.
  3. Review .htaccess, configuration files, redirects and the database for suspicious modifications.
  4. Restore a known-clean backup.
  5. Verify whether unauthorised files still remain after the restore.
  6. If the existing filesystem cannot be trusted, isolate the entire compromised document root.
  7. Create a new, empty document root and restore the clean backup there.
  8. Permanently remove the infected copy after verification.
  9. Update WordPress, the theme and all plugins.
  10. Where appropriate, reinstall critical plugins from clean official packages rather than merely updating them in place.
  11. Rotate hosting, WordPress and database credentials and review FTP/SFTP access.
  12. Regenerate WordPress authentication keys and salts.
  13. Check Google Search Console for Security Issues, Manual Actions and indexed spam.
  14. Allow Google to recrawl the former spam URLs and receive proper 404/410 responses.
  15. Continue monitoring the website and hosting account after recovery.

None of these steps in isolation is particularly exotic.

The important part is understanding that none of them replaces all the others.

When is a website simply too old?

This incident also brought me back to a conversation I have regularly with clients:

“If the website still works, why should we rebuild it?”

From a business owner’s perspective, the question makes perfect sense.

The pages load. The contact form sends emails. The website still looks acceptable.

Why invest in it again?

From a technical perspective, however, “it still works” is not enough.

I do not believe websites have an arbitrary expiry date.

I would never say that every site must automatically be rebuilt after exactly five years.

But after four or five years, I believe every professional website should undergo a serious technical and design review.

At five or six years, I start asking whether continuing to invest in the existing architecture still makes sense or whether a more substantial rebuild would be the better long-term decision.

And once a business-critical WordPress website approaches eight years without a meaningful architectural reassessment, I think that conversation becomes difficult to postpone.

Not because an eight-year-old website is automatically insecure.

Because of technical debt.

A mature WordPress website may contain a theme chosen years ago, a page builder, plugins added at different stages, custom CSS, code snippets, integrations, old libraries, changing PHP requirements, multiple generations of updates and workarounds introduced over its lifetime.

Eventually, you are no longer maintaining only a website.

You are maintaining eight years of technical history.

And that history has a cost.

“It still works” is not a maintenance strategy

The fact that a website continues to render correctly in a browser does not necessarily mean its underlying architecture remains the best architecture for the business.

Technology changes.

WordPress changes.

PHP changes.

Performance expectations change.

Accessibility requirements change.

Privacy requirements change.

Search engines change.

Attack techniques change.

And the tools I choose to build websites with today are not necessarily the same tools I chose eight years ago.

That is normal.

Professional website maintenance should include not only keeping individual components patched but periodically asking a broader question:

If I were building this site today, would I still choose this architecture?

If the answer is consistently no, eventually maintenance alone stops being the most sensible investment.

The most important lesson from this pharma hack

The biggest lesson I took from this incident is that website security cannot be reduced to a single checkbox.

It is not:

“I update my plugins.”

It is not:

“I have backups.”

It is not:

“The homepage looks fine.”

And it is not:

“Search Console does not show a security warning.”

All of those things matter.

None of them tells the whole story.

A professionally maintained website requires updates, backups, monitoring, controlled access, credential management and periodic reassessment of the technology on which it was built.

And when a real compromise occurs, proper recovery must address more than the visible malware.

It must address the filesystem, the database, user access, credentials, active sessions, the original vulnerability and the footprint the attack may already have created in search engines.

Sometimes it also forces us to acknowledge something clients understandably do not always want to hear:

A website built for the needs and technology of a business eight years ago does not necessarily need to remain on exactly the same technical foundation forever simply because it still works.

Website security is not something configured once on launch day.

It is an ongoing process of maintenance, monitoring, adaptation — and, when the time comes, renewal.


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top