Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Expired or hijacked third-party script domain: how to find and fix it

PRF-114High impactCould addBy FunnelGuardPublished Updated
On this page

What this issue is

Many sites load JavaScript from other domains: a CDN, an old plugin vendor, a widget, a tracking helper. Your page trusts that domain completely. Whatever file it returns runs with the same power as your own code.

The risk appears when the company behind that domain stops paying for it, shuts down, or sells it, or when its account is compromised. Someone else can then register or control the domain and serve different JavaScript from the same URL. Your page still points at it, so every visitor gets the new code. This is a form of supply chain attack: the attacker never touches your server.

Why it costs you leads or sales

Injected code can send visitors away from your form or checkout, replace your buttons, or capture what people type. Lost trust follows: browsers and security tools may warn visitors or block your site, and ad platforms can disapprove ads that land on pages with malicious behaviour. Search engines may also flag the site.

How a hijacked script reaches your visitors
  1. Visitor opens your pageYour HTML loads normally
  2. Old script URL requestedPoints to an expired domain
  3. Attacker code runsRedirect, skimmer or pop-up
  4. Form or checkoutVisitor never converts, or data is stolen

The break happens outside your server, which is why it goes unnoticed.

Conversions before and after a hijackExample numbers
Conversions before and after a hijack (example)Before: 120 leads per week; After: 70 leads per week0469212070BeforeAfterleads per week

Example: illustrative numbers for a site whose landing page starts redirecting some visitors.

How to check if your site has it

You need a list of every domain your pages load code from, then a check on who controls each one.

Audit your external script hosts
  1. List external hosts

    Open your key pages in Chrome, press F12, go to the Network tab, filter by JS and reload. Note every domain that is not your own. Check pages with forms and checkout too.

  2. Search your source

    View page source and search for <script src="http, // and import(. Also check theme files, plugin settings and tag manager tags that inject scripts.

  3. Look up each domain

    Use a WHOIS or RDAP lookup (for example lookup.icann.org). Note the expiry date and whether the registration date is recent. A domain registered recently that used to be a vendor's is a red flag.

  4. Test each URL

    Open the script URL in a browser. A 404, a parked page, a changed file or unexpected code means you should remove it. Ask whether you still use the vendor at all.

  5. Check for unexpected behaviour

    Test your pages on a phone, from an ad click and in a private window. Watch for redirects and pop-ups.

How to fix it

If you suspect a script is already serving bad code, remove it first, then investigate. How you remove it depends on where it was added.

Remove the dead or untrusted script
  1. Find the source

    Search the theme and plugin files for the domain, and check Appearance > Theme File Editor, header and footer injection plugins and page builder custom code.

  2. Remove or replace

    Deactivate and delete abandoned plugins that load it. Replace with a maintained alternative, or host the file yourself if the licence allows.

Find the domain in a codebasebash
grep -rn "old-cdn-host.example" ./src ./templates ./public

Then lock down the scripts you keep. Subresource Integrity (SRI) makes the browser refuse a file if its content differs from a hash you recorded. It works for static, versioned files, not for scripts that change by design.

Script with Subresource Integrityhtml
<script src="https://cdn.example.com/lib/1.2.3/lib.min.js"
  integrity="sha384-REPLACE_WITH_REAL_HASH"
  crossorigin="anonymous"></script>
Generate the SRI hashbash
curl -s https://cdn.example.com/lib/1.2.3/lib.min.js | openssl dgst -sha384 -binary | openssl base64 -A

A Content Security Policy (CSP) limits which domains may run scripts. Start in report-only mode so you do not break the site.

CSP header, report-only firsttext
Content-Security-Policy-Report-Only: script-src 'self' https://www.googletagmanager.com https://cdn.example.com; report-uri /csp-reports

How to confirm it's fixed

Confirmation checks
  • The Network tab shows no request to the removed domain on key pages
  • Every remaining external script host is one you recognise and the vendor is active
  • Pinned scripts load with no integrity errors in the Console
  • Forms submit and checkout reaches the payment step normally
  • No redirects or pop-ups on mobile, in a private window or from an ad click
  • CSP report-only logs show no unexpected hosts

How to prevent it happening again

Habits that stop this
  • Keep a written inventory of every third-party script, its owner and why it is there
  • Remove scripts when you cancel a vendor, plugin or campaign
  • Self-host or pin versioned files with SRI where possible
  • Deploy a CSP with a short allow-list
  • Load third-party code through one reviewed tag manager container with limited publish access
  • Review domain expiry and ownership of hosts you depend on every quarter
How a hijack unfolds
  1. Example: Month 0

    A vendor shuts down. Your site still loads its script.

  2. Example: Month 6

    The vendor's domain registration lapses.

  3. Example: Month 7

    A stranger registers the domain and serves new code at the old URL.

  4. Example: Month 7

    Your visitors start getting redirected or skimmed.

  5. After audit

    You remove the tag and add SRI and CSP.

How FunnelGuard handles this

FunnelGuard does not check for this yet. It is a possible future check. Today it does not scan your pages for expired or hijacked script domains, and it cannot tell you whether a script's content has changed.

What FunnelGuard does cover nearby: a robot visitor runs your real journeys (lead forms, checkouts, booking and chat buttons) on a schedule, checks each step and the tracking hits sent to platforms such as GA4, Google Ads and Meta, and checks that test leads reach your inbox and CRM. If injected code redirects the journey or breaks a form step, a failed check can show up as a broken journey, with a screenshot, but the alert would not name the hijacked script as the cause.

To watch for this issue yourself, run the audit above every quarter, set expiry reminders for vendor domains you rely on, use the CSP report-only endpoint to see unexpected hosts, and check Google Search Console's Security issues report. You can also start with the free read-only website audit or the Free plan (1 site, 2 journeys, daily checks, no card) to monitor that your key journeys still work.

Questions people ask

Can an expired domain really serve malicious JavaScript on my site?

Yes. If your page loads a script from a domain whose registration lapsed, anyone who registers it can serve code at that same URL. Your visitors' browsers run it with the same access as your own scripts.

How do I find third-party scripts on my website?

Open the page in Chrome, press F12, go to the Network tab, filter by JS and reload. Every domain that is not yours is a third-party host. Also search your theme, plugin settings and tag manager for script tags.

How do I check whether a script domain has expired or changed owner?

Look the domain up with a WHOIS or RDAP tool such as lookup.icann.org and check the registration and expiry dates. A recent registration date on a domain an old vendor used is a warning sign. Also open the script URL to see if it returns different content.

What is Subresource Integrity and does it stop a hijacked script?

Subresource Integrity adds an integrity hash to a script tag, and the browser refuses to run the file if its content does not match. It protects static, versioned files. It does not suit scripts that the vendor changes on purpose.

What is a Content Security Policy and how does it help?

A Content Security Policy is a header that lists the domains allowed to run scripts on your page. A script from any other host is blocked. Start with Content-Security-Policy-Report-Only to see what would break before you enforce it.

What should I do if my site already loaded a malicious script?

Remove the script, rotate passwords and keys used on affected pages, and scan for other changes. If checkout was affected, tell your payment provider. Check Search Console for security warnings.

Does FunnelGuard detect hijacked third-party scripts?

No, not yet. It is a possible future check. FunnelGuard does run your real journeys on a schedule, so a form or checkout that breaks gets a screenshot, but it does not identify hijacked script domains.

Does FunnelGuard catch this?

Could add

Not checked yet: could be added to FunnelGuard.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.