WordPress Service Worker Malware: Remove Browser Persistence After Server Cleanup

WordPress browser protected while a malicious service worker is isolated from the cleaned website

WordPress service worker malware can make a cleaned website appear infected in one browser because a previously registered background script may still control requests within its scope. Do not assume every cache symptom proves this attack. First compare the browser registration, the network response, and the WordPress source that registered it.

RyoheiYokoyama

I’m Ryohei Yokoyama, founder of SiteFixNow. With over 20 years of IT engineering experience and practical WordPress malware removal and hacked-site recovery work, I treat browser persistence and server cleanup as separate evidence layers so that a returning redirect is traced instead of merely hidden.

What you’ll learn
  • How a service worker can control pages after a cache clear.
  • How to record scope, source URL, state, and intercepted requests before removal.
  • Where WordPress themes, plugins, and injected scripts can register the worker.
  • How to unregister it, remove related storage, and prove that it does not return.
On This Page

WordPress Service Worker Malware Is Browser Persistence, Not an Ordinary Page Cache

Key decision

Confirm that a registered worker controls the affected origin and scope before calling the symptom service worker malware.

A service worker is JavaScript that a supporting browser runs separately from an open page. It can intercept requests, respond from Cache Storage, support offline behavior, and continue through a lifecycle that is not identical to a normal tab. A legitimate progressive web app, push-notification plugin, or performance feature may use exactly those capabilities.

const regs = await navigator.serviceWorker.getRegistrations();
console.table(regs.map(r => ({
 scope: r.scope,
 active: r.active?.scriptURL ?? null,
 waiting: r.waiting?.scriptURL ?? null,
 installing: r.installing?.scriptURL ?? null
})));
console.log('controller', navigator.serviceWorker.controller?.scriptURL ?? null);
console.log('cache names', await caches.keys());

WordPress Service Worker Evidence Must Be Captured Before Unregistering

Key decision

Record the registration and its network behavior first; unregistering too early can erase the easiest route to the malicious source.

Open developer tools for the affected origin and use the Application panel’s Service Workers and Cache Storage sections. Record the exact scope, source URL, status, update time if shown, cache names, and whether the page is controlled. Save representative request URLs and response headers while excluding cookies, authorization headers, personal data, and live tokens.

Evidence to keep without copying secrets
  • Origin, scope, worker source URL, lifecycle state, and current controller
  • Cache names and representative request URLs, not private cached content
  • Network-versus-intercepted result with time, profile, and test path
  • Worker-source hash and expected owner plugin, theme, or deployment
  • Relevant WordPress, server, CDN, and administrative timeline entries

WordPress Service Worker Registration Sources Must Be Removed at the Server

Key decision

Find and remove the code that calls serviceWorker.register(); otherwise the unwanted registration can return after browser cleanup.

Search trusted copies of the active theme, child theme, ordinary plugins, must-use plugins, custom snippets, tag-manager configuration, and generated front-end assets for service worker registration. WordPress itself does not require a front-end service worker for a normal installation. A legitimate plugin may add one, but its script path, scope, and owner should be documented and reproducible from a clean package.

# Run only on the confirmed site copy.
rg -n 'serviceWorker\.register|navigator\.serviceWorker|importScripts\(' \
 wp-content/themes wp-content/plugins wp-content/mu-plugins

# Review generated HTML without changing the site.
curl -fsS https://example.com/ | rg -n 'serviceWorker|worker\.js|sw\.js'
Security investigation tracing a browser service worker through cache storage to its WordPress registration source

WordPress Service Worker Removal Requires Registration and Storage Cleanup

Key decision

Remove the server-side registrar first, then unregister the confirmed unwanted worker and delete only storage associated with the incident.

After the registration source has been disabled or replaced, unregister the unwanted worker from an owner-controlled browser profile. The standard unregister method returns a promise and a boolean, but a competing page can call register again for the same scope. That is why server-side removal and closed extra tabs matter before interpreting the result.

// Replace both values with the exact unwanted scope and script URL
// recorded during the evidence review. Do not select a legitimate worker.
const targetScope = 'PASTE_VERIFIED_UNWANTED_SCOPE_URL';
const targetScript = 'PASTE_VERIFIED_UNWANTED_SCRIPT_URL';
const regs = await navigator.serviceWorker.getRegistrations();
const matches = regs.filter(reg =>
 reg.scope === targetScope &&
 [reg.active, reg.waiting, reg.installing].some(worker =>
  worker && worker.scriptURL === targetScript
 )
);
if (matches.length !== 1) {
 throw new Error('Expected exactly one verified unwanted registration; stopped.');
}
console.log(matches[0].scope, await matches[0].unregister());
console.log(await caches.keys()); // Review ownership; no automatic cache deletion.

WordPress Service Worker Verification Must Prove It Does Not Return

Key decision

Verify the cleaned browser, a clean profile, direct network responses, and the WordPress source across a realistic recurrence window.

Reload from a newly opened page and confirm that the unwanted scope and source URL are absent. Recheck the current controller, registration list, Cache Storage, and Network panel. Then close and reopen the browser, revisit affected paths, and repeat the test. One successful refresh is insufficient because update checks, delayed scripts, or another tab may register the worker again.

WordPress Service Worker Incidents Need Separate Browser and Server Conclusions

Key decision

Close the incident only when browser persistence is gone and the server-side registration route has been explained and repaired.

Write two conclusions. The browser conclusion states which registration and storage were removed and how absence was verified. The server conclusion states which component registered the worker, how it was restored or disabled, what access route was fixed, and what evidence remains unavailable. Keeping them separate prevents a clean browser from being reported as a clean website.

WordPress Service Worker Malware FAQ

Key decision

Identify the registration, preserve evidence, remove its registrar, clean related storage, and verify that it cannot return.

Does clearing the WordPress cache remove a malicious service worker?

Not necessarily. WordPress, server, and CDN caches are separate from a browser registration and Cache Storage. Remove the registration source, unregister the worker, clean related storage, and verify both layers.

Is every service worker on a WordPress site malicious?

No. PWA, offline, push-notification, and performance features may use legitimate workers. Compare the source URL, scope, owner component, package, and expected behavior before removing it.

Why did the service worker return after I unregistered it?

A page, plugin, theme, tag, compromised bundle, or another open tab may have called register again. Repair that registrar first, then repeat controlled cleanup and verification.

Should visitors paste an unregister script into the console?

No. Asking visitors to paste opaque code is unsafe and resembles common social-engineering attacks. Restore the site through reviewed code and provide browser-specific support steps only when necessary.

WordPress Service Worker Malware Recovery Depends on Removing the Registrar

Key decision

Preserve the registration, separate intercepted and network responses, repair the WordPress source, remove browser persistence, and prove that it stays gone.

A browser can retain a worker after an ordinary server cleanup, but browser cleanup alone is not a full malware response. The decisive result is a documented chain from the original scope and script to the repaired registration source, followed by clean cross-profile tests and no recurrence during monitoring.

If You Can’t Secure or Recover Your WordPress Site Yourself

Ryohei Yokoyama, founder of Site Fix Now — WordPress site recovery, repair, defacement, malware removal and site hijacking specialist. Recovery in as little as 30 minutes.

If your website shows malware warnings, redirects to strange pages, or you are not sure whether it is secure,
SiteFixNow can help clean, repair, and recover your WordPress site.

Common problems we can help with
  • Your WordPress site may be infected with malware.
  • Security warnings appear in Google or browser results.
  • You found unknown admin users or suspicious files.
  • The site redirects to spam or unknown websites.
  • You need urgent WordPress hacked site repair.

We help with WordPress malware removal, hacked site repair, security cleanup, and recovery support.

Why ask for help early?
  • Reduce visitor risk and SEO damage.
  • Find hidden malware and backdoors, not only visible symptoms.
  • Recover the site safely without unnecessary data loss.

About the Author

Hello, I’m Ryohei Yokoyama, an IT engineer with over 20 years of experience.

I have received more than 776 reviews for WordPress recovery,
website repair, and online courses.

Many clients have shared comments such as:

“They restored my site so quickly!”
“They handled it the same day, which was a huge help!”

I am proud to have received a very high rating of 4.9 out of 5.0.

I have also published more than 30 books on WordPress, SEO, Microsoft Office, and related topics,
with multiple titles reaching No. 1 in sales rankings.

In addition, I have created more than 3,000 services, systems, and websites.

Through this experience, I have helped many people overcome technical problems, frustrations, and challenges.
Based on that practical perspective,
I explain complex topics in a clear and easy-to-understand way.

On This Page