Third-Party JavaScript as Attack Surface: What a Vendor Compromise Teaches
- Asma Zubair
- 475 reads
A trusted third-party script delivered malicious code to visitors of major sites. Here's what CSP blocks, what it misses, and how to audit your exposure.

The most useful detail in this incident is what the affected sites didn't do. Their developers didn't push bad code, their servers weren't breached, and their pipelines stayed clean. Visitors still received malicious JavaScript, because those sites trusted a script from a widely used third-party web service, and that service was compromised. The affected sites included news publishers, banks, airlines, and software companies.
How the compromise reached visitors
The attackers never touched the websites themselves. They exploited a weakness in the vendor's platform to gain administrative control of some customer accounts, then modified the JavaScript those customers delivered through the vendor. The vendor's CDN served the altered file to every visitor of an affected page. From the browser's perspective, nothing looked wrong. The file came from a host the site already trusted, behind the vendor's valid certificate.
Researchers who analyzed the injected code found it running on many organizations' sites. It was built to steal payment card details typed into on-page forms, tamper with cryptocurrency transactions, and send readable cookies to attacker-controlled servers. Report URI found that the campaign's primary domain was registered the morning the attack began, which suggests the infrastructure was prepared specifically for this operation.
My read is that this isn't really a story about one vendor. Modern websites run plenty of code their owners didn't write and often don't track.
Why third-party scripts carry so much weight
Analytics, personalization, advertising, consent management, chat, and A/B testing all depend on external scripts. Every script tag pointing at another host lets that host run code in your visitors' browsers with the same privileges as your own code. It can read and modify the page, watch form input, read cookies not marked HttpOnly, and send data elsewhere.
That's what separates a third-party supply-chain compromise from an application compromise. None of the affected organizations had to change their source code, servers, or pipelines. Code review and server-side monitoring had nothing to catch. One weakness in a shared platform reached many organizations in a single day. The blast radius of a script is set by how many customers share the platform that serves it, not by the bugs in your own code.
What Content Security Policy can and can't do
Content Security Policy (CSP) tells the browser which sources may load scripts and receive data. In this case, the injected code pulled its main payload from an attacker-controlled domain, so a strong policy could have blocked it. The word "strong" is carrying a lot of weight in that sentence, though.
Most affected sites either had no CSP or had one that still let the payload execute. Allowlisting the vendor's domain changed nothing, because the malicious code arrived through that very host. Protection came from a restrictive script-src that excluded the attacker's domain. Two settings undercut that protection. 'unsafe-eval' let an inline fallback copy of the payload run, and 'strict-dynamic' extended trust to any scripts the compromised snippet inserted. A tight connect-src limited exfiltration, but it couldn't stop wallet-address swapping happening inside the page itself. CSP narrows what a compromised script can do. It doesn't make in-page manipulation impossible.
Practical guidance for any site running external JavaScript
These practices apply whether you run a bank's checkout or a company blog.
- Know what runs on your pages. Keep an inventory of every third-party script, the pages that load it, its internal owner, and why it's needed. Include scripts added through tag managers.
- Load less, especially on sensitive pages. Remove scripts that no longer serve a purpose, and keep analytics, marketing, and testing scripts off payment, login, and account pages unless they're essential.
- Enforce a strict CSP. Allow only the script and connection sources each page needs, avoid 'unsafe-eval' and 'unsafe-inline', use nonces or hashes where possible, and enable violation reporting. Roll out changes in Report-Only mode first.
- Keep payment entry out of reach. Hosted payment fields served in an iframe from your provider's domain can't be read by scripts running on your own page.
- Protect cookies and sessions. Mark session and authentication cookies HttpOnly so injected scripts can't read them, and set Secure and SameSite as well.
- Pin or self-host what rarely changes. Use Subresource Integrity (SRI) for third-party files that change infrequently, or host them yourself. Scripts that change often, such as tag managers and testing tools, need monitoring instead.
- Hold script vendors to a high standard. Ask how they secure customer accounts and code changes, and how quickly they notify customers of incidents. On your own accounts, enforce MFA or SSO and limit who can publish code.
- Watch for changes. Monitor third-party scripts for new code, new network destinations, and unexpected behavior. A trusted script can change without any deployment on your side.
- Plan your response. Know how to disable a third-party script quickly, and keep web, CDN, and CSP logs long enough to investigate.
Where Qualys tooling fits
Qualys organizes its detections around three questions: what you depend on, how well your controls are configured, and whether malicious content is actually present. TotalAppSec covers the first two, and Web Malware Detection covers the third.
Assessing CSP: QIDs 150206 and 150207
QID 150206 (Content-Security-Policy Not Implemented) flags applications that send no CSP header, which leaves no browser-enforced limit on where scripts load from.
QID 150207 (Content Security Policy Insecure Configuration) flags weak elements: 'unsafe-inline', 'unsafe-eval', wildcard sources, a missing default-src, and missing or invalid reporting. This incident showed the effect of one of these directly, when 'unsafe-eval' let the inline payload run. A 150207 finding doesn't prove a particular policy would have allowed this attack, since that depends on the full script-src, trusted sources, and nonces or hashes. Treat it as a starting point for review. Reporting matters too. The vendor's first recommendation was to review CSP violation reports, and sites without reporting had nothing to review.
Discovering external dependencies: QID 150545
QID 150545 (JavaScript Library Loaded via External Server) reports out-of-scope JavaScript libraries found during crawling, including the page, the library version, and the external URL. It doesn't judge whether a library is malicious. Its value is visibility. An inventory of external scripts is the basis for deciding which vendors to trust and which hosts a CSP should allow.

Flagging known malicious script references: QID 533507 (new)
QID 533507 (Known Malicious Script Reference Detected) is a new check. It sends an unauthenticated HTTP GET request and inspects the response body for a script src referencing known malicious scripts. Use it to inventory which applications load them, and to prioritize payment and cryptocurrency applications for CSP review.
Detecting malicious content
TotalAppSec shows where you're exposed and how well your controls are configured. Web Malware Detection asks a different question: is malicious content present? It combines heuristic analysis (signature rules for patterns such as encoded JavaScript), behavioral analysis (loading the site in a vulnerable browser and watching for unexpected file writes or processes), reputation checks of pages and remotely loaded resources against public blacklists, and antivirus scanning of downloaded scripts and files.
- QID 207003 (A Match to a Known Virus was Detected): a file written to disk during page rendering is identified as malicious by a virus scanner.
- QID 208000 (Content was Loaded from a Remote Malicious Page): a page loads scripts, iframes, or images from a blacklisted domain.
- QID 208001 (A Link to a Malicious Page was Found): a page links to a domain on one or more blacklists.
Reputation-based detection only works once a domain is blacklisted, and attacker infrastructure is often new. That's why continuous scanning matters alongside preventive controls like CSP. Together these findings give three views. Script references (533507, 150545) show where you depend on someone else. Weak controls (150206, 150207) show how much damage a compromised dependency could do. Malicious content (207003, 208000, 208001) shows that something harmful is already there.
| QID | Product | What it establishes |
| 533507 (new) | TotalAppSec | Page references an impacted script |
| 150206 | TotalAppSec | No Content-Security-Policy header is present |
| 150207 | TotalAppSec | CSP contains weak elements (unsafe-inline, unsafe-eval, wildcards, missing default-src or reporting) |
| 150545 | TotalAppSec | An out-of-scope JavaScript library loads from an external server |
| 207003 | Web Malware Detection | A file written to disk during page rendering matches a virus signature |
| 208000 | Web Malware Detection | Page loads resources from a blacklisted domain |
| 208001 | Web Malware Detection | Page links to a blacklisted domain |
Recommendations for security teams
If you're responding to this specific incident, start with the vendor's guidance. Confirm which pages ran the snippet during the exposure window, review CSP violation reports and outbound requests against the published indicators of compromise, and keep your web, CDN, and CSP logs. The vendor and Report URI published different indicators, so check both.
For every organization, the sequence is:
- Inventory third-party scripts. Use QIDs 533507 and 150545 to see which applications load external JavaScript, and from where.
- Restrict trusted sources. Remove unneeded scripts, especially on payment, login, and personal-data pages.
- Implement CSP and assess it continuously. Resolve 150206 and 150207 findings, keep script-src and connect-src restrictive, avoid 'unsafe-eval', and test changes in Report-Only mode.
- Monitor script changes. A trusted script can change without any deployment on your side.
- Investigate malicious content. Treat Web Malware Detection findings as triggers for investigation, not as noise.
- Remove unauthorized scripts and remediate. Restore known-good code and rotate any secrets that sat in readable cookies.
- Reassess after remediation. Rescan to confirm the fixes are in place.
What to watch next
This incident didn't require breaching a single customer's application. It required one weakness in a platform those applications trusted. The open question is whether vendors tighten account controls and code-publishing safeguards fast enough to matter, and whether sites treat CSP reporting as a default rather than an afterthought. Until then, securing a web application means having visibility into both the code you write and the external scripts you let run in your users' browsers.
