Web Supply Chain Attacks: How a Third Party Script Becomes the Attacker's, and How to Stop It
British Airways in 2018, Polyfill.io in 2024, Optimizely in November 2026. The same attack each time: a script your site loads from a vendor is changed at the vendor, and the browser runs it as yours. What the attacker gets, why the usual defences miss it, what has actually stopped it, and the defence in order, with a free check for your own site.
Every script your website loads from someone else's server runs with full access to your pages, your visitors and everything they type. If that vendor is compromised, your site is compromised, with no change to your own code and nothing on your side to notice. This has happened to an airline, to a hundred thousand sites through one code library, and this month to 178 household names through one testing tool. The defence that works is a Content Security Policy that names only the script sources you need, and allowing the vendor's own CDN in that list does not help. The strongest position is to serve every script from your own domain and allow nothing else. That is how this site runs, and you can check yours in a few seconds.
Check your own site first. The free website script check reads one page, names the vendors it loads script from, opens its tag manager container, and says whether the policy would have stopped the Optimizely payload. Or send us the domain and we will read the whole site, free and in writing.
What a web supply chain attack is
Your website is not one piece of code. The typical corporate site loads a tag manager, an analytics tag, a visitor identification tracker, a consent banner, a chat widget, two or three advertising pixels, a testing tool and a video player, each from a different vendor's server, each updated by that vendor whenever they choose, each with full access to the page. The browser does not distinguish between code you wrote and code you loaded from a vendor. Once a script runs on your page it can read every field as it is typed, rewrite any link, post data to any host, and load further scripts and frames, all under your domain and your visitors' trust.
A web supply chain attack changes that code at the supplier, so that your site serves the attacker's code without anything on your site changing. Your own penetration test would have passed the day before. Your monitoring saw a normal day. The only controls that count are the ones that decide what the browser is allowed to do on your page.
The incidents, and what each one taught
| Incident | How the code got in, what it did, what stopped it |
|---|---|
| British Airways, 2018 | A card skimmer of about 22 lines was inserted into a script on the airline's own site and ran on the payment page from late August to early September 2018, sending the card details of around 400,000 customers to an attacker domain. The ICO fined BA £20 million in October 2020, reduced from a proposed £183 million. Lesson: the skimmer needed only to send data out. A connect-src naming the real payment endpoints would have stopped it. The Register, 16 October 2020. |
| Polyfill.io, 2024 | A free code library used by over 100,000 sites was sold in February 2024 to a company that, by June, was serving a modified version that redirected visitors to scam sites, targeting mobile users and avoiding detection by admins. The domain was taken down and Cloudflare and Fastly offered clean mirrors. Lesson: a vendor can change hands, and a script you trusted in 2019 is a different supplier in 2024. BleepingComputer, 25 June 2024. |
| npm, September 2025 | Not a web script but the same shape one layer down. A maintainer was phished on 8 September and malicious versions of chalk, debug and about sixteen other packages, with hundreds of millions of weekly downloads between them, carried a cryptocurrency stealer for a few hours. A week later the Shai-Hulud worm spread through more than 180 packages harvesting credentials. Lesson: the code your developers build with is a supply chain too. BleepingComputer, 16 September 2025. |
| Optimizely, November 2026 | An attacker wrote code into the project configuration of 188 Optimizely snippets belonging to 178 organisations, and the vendor's CDN served card skimming, cookie and screenshot theft, wallet address swapping and iOS exploit kits for most of 16 November. The same injector had appeared in three other vendors' scripts that week. Only 15 percent of the affected sites had a policy that blocked it. Lesson: the vendor's compromise is your incident, and a policy that allows the vendor's CDN is a policy that allows the payload. Report URI, 16 November 2026. Our account of the day. |
What the attacker gets from your site
It depends on what the page does, and a site with no payments is not safe.
- Payment cards, wherever a card is typed into a field on your page rather than inside a payment provider's hosted frame.
- Everything typed into forms: enquiries, logins, the names and companies of the prospects you most want to protect.
- Sessions, through any cookie not marked HttpOnly, and screenshots of what the visitor sees.
- Your visitors' devices. Any script can open a hidden frame, and in November 2026 that frame delivered exploit kits to unpatched iPhones and iPads. The theft is from your visitor, served from your domain, and your organisation is the one named in the report.
- Your name. Your visitors' security teams see malware from your domain. They are not interested in whose CDN it came through.
A penetration test checks your code. A web application firewall checks requests to your server. Vendor due diligence checks the vendor's paperwork. None of them sees a script that was clean yesterday and is not today, served from a host you trusted on purpose. Optimizely is a serious company with a security team, and it still happened. The question is not whether your vendors are trustworthy. It is what runs on your site when one of them has a bad day.
What has actually stopped it, in numbers
The Optimizely incident is the first with a published count of what worked, because Report URI crawled the affected organisations' sites and grouped them by what their Content Security Policy did when the payload arrived.
| Outcome | Sites | What it means |
|---|---|---|
| No policy at all | 68 | Payload ran, data left the page, exploit frames loaded. Nothing in the way. |
| Policy allowed both | 50 | A policy existed but permitted the vendor script and the attacker's hosts. No better than none. |
| Payload ran, theft blocked | 17 | A restrictive connect-src stopped cards, cookies and screenshots leaving the page. Wallet address swapping, which happens inside the page, still worked. |
| Payload blocked | 24 | A script-src that listed only the hosts actually needed. The malicious code never ran. 15 percent of the affected sites. |
Source: Report URI, 16 November 2026. The groups do not sum to the total crawled because some hosts could not be assessed.
- Allowing the vendor's CDN did not help. The payload was served from the vendor's own CDN, so every policy that trusted that CDN trusted the payload. A policy written as "allow our vendors" is a list of the places an attacker can reach you from.
- Two common shortcuts defeated the policy.
'strict-dynamic', which lets an allowed script load whatever it likes, and'unsafe-eval', which lets code build more code from text. One site's inline fallback ran the payload throughevalafter its tag was refused. - A tight
connect-srcis a second wall. It would have stopped British Airways' skimmer in 2018 and it stopped the theft on 17 sites in 2026, even where the script ran. It costs nothing to add.
The defence, in order
- Inventory. List every third party host your pages load script from, and open the tag manager container, which is where most of them hide. The website script check does both for one page. Most organisations are surprised by the count.
- Prune. Decide who approved each one and whether it is still used. Pixels from campaigns that ended years ago are common. Every script you remove is a supplier you no longer depend on.
- Self host what you keep. Most analytics and tracking scripts work from your own domain, so a compromise of the vendor's CDN cannot reach your visitors. Some vendors prohibit it, some scripts update too often to copy, and a tag manager cannot sensibly be self hosted. Each is a decision to make on purpose, and copies need a refresh on a schedule.
- A Content Security Policy whose
script-srcnames only what you need. Your own origin, hashes or nonces for your inline code, and the few hosts you cannot avoid. No'unsafe-inline','unsafe-eval','strict-dynamic'or wildcards. Withconnect-srcandform-actionnaming your real endpoints,frame-srcset to none or the few things you embed, andbase-uriandobject-srcclosed. - Integrity hashes where the script is static. A subresource integrity attribute makes the browser refuse a script whose content changed. It does nothing for scripts that are meant to change, which is most tags, but it closes the library case.
- Reporting, before enforcing. A violation reporting endpoint tells you within minutes that something on your page tried to do something it should not, and lets you run a new rule in report only mode until the reports are quiet. Without one, you find out from a visitor's security team or from a blog post naming you.
- Govern the tag manager. Who can add a tag, who reviews it, and when it is removed. A container with 300 tags is 300 suppliers, added by whoever had access at the time.
How our own site runs, and how to check it
We advise organisations on security, so this site runs the position described above rather than a counter example of it. No script is loaded from a third party host: the two analytics scripts we use are served from our own domain, after consent. Every page carries a Content Security Policy that allows script from our own origin and the hashes of our own inline code only, with no vendor host in script-src, no 'unsafe-eval' and no 'strict-dynamic'. Connections are limited to our origin and the two analytics collection endpoints, frames and plugins are forbidden, and the standard headers for clickjacking, content sniffing, referrers and device permissions are set.
You can verify every claim in that paragraph from a terminal without trusting us. The response headers:
curl -sI https://www.c4cgroup.co.uk/ | grep -i -E "content-security|x-frame|x-content|referrer|permissions"
And the per page policy, which sits in a meta tag in the head of every page:
curl -s https://www.c4cgroup.co.uk/ | grep -o '<meta http-equiv="Content-Security-Policy"[^>]*>'
Or run our website script check against this domain, or paste it into securityheaders.com. If a script tag pointing at any host other than our own appears in the page source, the claim is false and we would like to know.
Two questions settle whether your website is exposed to the next incident of this kind. First, which third party hosts does our site load code from, and who approved each one. Second, if one of those hosts served malware tomorrow, would our policy stop it, limit it, or allow it. If nobody can answer both from memory, the honest answer to the second is "allow it", and the fix is a few days of work by someone who understands the policy. The website script check answers both for one page in a few seconds.
Ask us to check your siteYour script vendors are one part of a wider supplier picture. For how to assess every supplier's security before you buy or renew, see our guide to third party and supplier security risk.
Does AI change this?
It changes the speed, not the mechanism. Attackers are using AI to find vulnerabilities and produce working exploit code faster, and the first fully automated exploitation frameworks, with no human in the loop, were reported in November 2026. Defenders are using it too, from finding bugs before they are exploited to reading a tag manager container in seconds. The controls above are the same either way, which is the point: a policy that names only your own origin does not care how the payload was written. The detail, with the published evidence on both sides, is in AI in cyber attacks and defence.
How C4C helps
We are a cybersecurity consultancy with decades on the vendor side, so we know what the tools do and what the claims are worth. We start with advice: the same read we apply to our own site, done on yours, an inventory of every third party host your site loads code from and every tag in the container, what each can reach, what your current policy would have done on 16 November, and a written plan to a position where the next vendor compromise is somebody else's incident. For most corporate sites it is days of work, not months, and most of it is configuration rather than code.
Where the plan needs tooling, such as policy reporting, script monitoring, a web application firewall or a managed detection service, we apply our IDEAL framework to identify the need, decide between the options on your numbers, execute the implementation, make sure it is adopted and manage it across its lifecycle. We select and supply the right software where that helps, and we tell you plainly when the gap is configuration you already own. If the website turns out to be the least of your problems, the wider cyber security posture review is where that conversation goes next.
Find out what would run on your site
Give us the domain. Within two working days we will send you the list of third party hosts your site loads code from, what the tag manager may load, what each one can do on your pages, and what your current headers and policy would do against a compromised vendor script. Free, written, and no obligation.
Prefer email? Reach us directly at hello@c4cgroup.co.uk.
Frequently asked questions
What is a web supply chain attack?
A web supply chain attack compromises code that your website loads from a third party, such as an analytics tag, a chat widget, an advertising pixel, a testing tool or a code library, so that the attacker's code runs on your pages without any change to your own site. Because the browser treats every script on the page as yours, the attacker gets full access to your visitors, their keystrokes, their cookies and their devices, served from your domain. The British Airways skimmer of 2018, the Polyfill.io compromise of 2024 and the Optimizely incident of November 2026 are all examples.
Does a Content Security Policy stop third party script compromise?
Only if it is written tightly. In the Optimizely incident, 24 of the affected sites, 15 percent, had a script-src that listed only the hosts they actually needed, and the payload never ran on those sites. A further 17 had a connect-src that stopped data leaving the page even though the script ran. Policies that allowed the vendor's CDN, used strict-dynamic, or permitted unsafe-eval did not protect the site. A policy is a list of what the browser may do on your page. It only helps if that list is short and does not include the host that was compromised.
Should we self host third party scripts like Google Analytics?
Where the vendor's terms and the script's design allow it, yes. Serving a copy from your own domain means a compromise of the vendor's CDN cannot reach your visitors, because your pages never request anything from it. The costs are that you run the version you copied until you refresh it, that you must keep the copy current on a schedule, and that some scripts expect to load further modules from the vendor, which a strict policy will block. We self host both of our analytics scripts and refresh them quarterly. A tag manager is harder, because its whole purpose is to load other people's code at run time.
Our website has no payments or logins. Are we still at risk?
Yes, in two ways. First, anything a visitor types into a form on your site, such as an enquiry with their name, company and email, can be read by any script on the page and sent elsewhere. Second, and more serious, any script can load a hidden frame that delivers exploit code to the visitor's device. The Optimizely payload did exactly that against unpatched iPhones and iPads. The theft is from your visitor, not from you, and it is served from your domain, so your organisation is the one named in the incident.
Does a web application firewall or a penetration test protect against this?
No. A web application firewall inspects requests arriving at your server, and a penetration test examines your own code and infrastructure. Neither sees a script served to the browser from a vendor's host that was clean yesterday and is not today. The controls that work are the ones that govern what the browser may do on your page: the Content Security Policy, subresource integrity for static scripts, and serving scripts from your own domain.
How do I check what third party scripts my website loads?
The quickest way is our free website script check at c4cgroup.co.uk/tools/website-script-check/, which lists the third party hosts a page loads script from, names the vendors, opens the Google Tag Manager container if there is one, reads the Content Security Policy and security headers, and says what the policy would have done against the Optimizely payload. By hand: open the page in a browser, open the developer tools, select the Network tab, filter to JS, and reload. Every host in the list other than your own is a supplier whose code runs on your page. Then check the response headers with curl or a scanner such as securityheaders.com for a Content-Security-Policy header.
Does AI make web supply chain attacks more likely?
It makes them faster and cheaper to produce, which over time means more of them. Attackers are using AI to find vulnerabilities and write working exploit and injection code, and fully automated exploitation frameworks were reported in November 2026. It does not change the mechanism or the defence: a policy that allows script from your own origin only refuses a payload whether a person or a model wrote it. Our guide on AI in cyber attacks and defence sets out the published evidence on both sides.
What does C4C's own website load from third parties?
No script at all. Google Analytics and a visitor identification tracker are served as copies from our own domain, after consent, and every page carries a Content Security Policy that allows script from our own origin and the hashes of our own inline code only, limits connections to our origin and the two analytics collection endpoints, and forbids frames and plugins. Fonts are loaded as stylesheets from Google Fonts, which the policy permits for styles only. Anyone can verify this by reading the response headers and the page source, or by running our website script check against our own domain.