On November 16, visitors to a number of well-known websites were served JavaScript that those sites had never intended to run. The script came through Optimizely Web Experimentation, a service used for A/B tests and personalization. The URL belonged to a familiar vendor. The TLS certificate was valid. The browser had no reason to regard the initial file as suspicious.
The code inside that file was another matter.
Scott Helme's investigation for Report URI found malicious additions in 188 of 1,611 Optimizely scripts examined, associated with 178 organizations. Optimizely subsequently confirmed a vulnerability in its Experimentation product that allowed unauthorized JavaScript to be added to some customer projects. Those figures describe the scripts the researchers could inspect, not every Optimizely deployment on the internet.
The interesting part is not just the scale. It is how little had to change in the websites themselves.
| 188
Scripts with malicious additions |
1,611
Scripts examined |
178
Organizations represented |
A clean delivery path can carry hostile code
Optimizely customers typically load a snippet from the vendor's CDN. That snippet can include a field for customer-written Project JavaScript, which may execute across pages where the integration is present. In this incident, the attackers placed a loader in that field. The existing delivery infrastructure did the rest.
From the browser's point of view, an external script included in a page executes in the context of the embedding page, not in a restricted sandbox belonging to the CDN. It can interact with the page's DOM and, subject to browser protections, the data and network capabilities available to page scripts. The fact that its bytes arrived from a different hostname does not confine it to that hostname's privileges.
This is the trust decision the attack exploited. A website granted a third-party script the ability to run; the contents of that script changed upstream.
How the trust path crossed the boundary
| Stage | What happened and why it mattered |
|---|---|
| 01 · Project configuration | Unauthorized code was added to customer Project JavaScript.
WHY IT MATTERED · The malicious change sat outside the site's own source repository. |
| 02 · Vendor delivery | The changed snippet was served through Optimizely's normal delivery path.
WHY IT MATTERED · A familiar URL and valid HTTPS did not establish that the bytes were safe. |
| 03 · Page execution | The browser executed the snippet within the website's page.
WHY IT MATTERED · The code gained the capabilities normally available to scripts on that page. |
| 04 · Secondary behavior | The loader attempted to fetch additional code, manipulate content and send data.
WHY IT MATTERED · The site's CSP and runtime monitoring became the next lines of defense. |
The researchers documented multiple loader variants, including a directly referenced external payload, an encoded reference and an inline fallback. That variation matters operationally: a search for a single hostname would not have found every version. Nor would checking a Git diff in the website's repository have shown the upstream modification.
What the payload could actually reach
The observed payload had several jobs. It attempted to replace cryptocurrency payment addresses in page content and user interactions, watch payment details entered into accessible forms, collect browser-visible information, and direct some iOS visitors toward further exploit code. These are different behaviors with different prerequisites. A page that loaded the affected snippet was exposed to malicious code; that alone does not establish that a visitor entered card details or that an iPhone was successfully compromised.
One browser boundary was particularly important. A script on the page can read payment fields that belong to that page. It cannot simply reach into a properly isolated, cross-origin payment iframe. The same distinction applies to cookies: HttpOnly prevents JavaScript from reading their values through document.cookie, although it does not make an otherwise compromised page harmless. A malicious same-origin script may still interact with authenticated application functions.
This is why the incident deserves attention from application security teams, not just threat intelligence analysts. The payload did not need to discover a new SQL injection or bypass the website's login flow to begin manipulating what the browser showed and did.
The limits of an allowlisted domain
A common Content Security Policy starts by allowing only selected script hosts. That is useful against an unexpected <script> tag pointing to a random domain. It is less reassuring when the first malicious instructions arrive inside an already allowed script.
In this case, an allowlist entry for Optimizely would have permitted the initial snippet. The more useful questions were what that script could load next, where the page could send data, and whether dangerous evaluation paths were available.
Report URI's CSP review found materially different outcomes across affected sites. Some policies blocked the secondary payload. Others blocked connections to attacker infrastructure while still allowing some on-page manipulation. That difference is easy to miss if a team treats CSP as a single pass-or-fail setting.
| Control | Protection and remaining exposure |
|---|---|
Restrictive script-src |
Could constrain: Loading an unapproved second-stage script or evaluating blocked code.
Would not solve: A compromised script already permitted by the policy. |
Restrictive connect-src |
Could constrain: fetch, XHR and sendBeacon traffic to unapproved destinations.
Would not solve: DOM changes, address substitution or every possible exfiltration channel. |
Avoiding unsafe-eval |
Could constrain: Fallback payloads that depend on dynamic code evaluation.
Would not solve: Other malicious behavior within allowed JavaScript. |
HttpOnly session cookies |
Could constrain: Direct JavaScript access to cookie values.
Would not solve: Abuse of authenticated page actions. |
| Script inventory and change monitoring | Could constrain: Unexpected changes in vendor-provided code and new dependencies.
Would not solve: Immediate prevention unless enforcement is added. |
There is another subtlety here. With script-src 'strict-dynamic', trust granted to a nonce- or hash-authorized script can extend to scripts that it dynamically creates. That is legitimate CSP behavior, not a browser defect. But it makes the decision to trust a third-party loader particularly consequential. MDN documents this propagation model.
What about Subresource Integrity?
Subresource Integrity (SRI) checks a downloaded script against an expected cryptographic hash. For a fixed library version, it is a strong answer to an unexpected byte-level change: the browser refuses to execute a file whose hash no longer matches.
Experimentation snippets are awkward candidates for static hashes because their legitimate content may change whenever a project is updated. Pinning one version requires a release process that deliberately approves and updates the hash. Without such a process, the choice often becomes breaking experiments or silently abandoning integrity checks. That does not make SRI useless; it means teams should distinguish versioned, immutable dependencies from remote code intentionally designed to change. The latter deserves stricter change control, monitoring and a clear owner. See MDN's SRI guidance.
Test the dependency as part of the application
There is a practical way to turn this incident into security test coverage. Start by listing scripts executed on login, checkout, account recovery and other sensitive pages. For each one, record who can change it, whether its contents are pinned, what additional scripts it may load, and which browser capabilities it actually needs.
Then test the controls against a harmless, deliberately changed script in a staging environment. Can an approved vendor script append a new script from an unapproved host? Does CSP block the request? Does a rejected sendBeacon appear in telemetry? If the vendor code changes without a deployment to your repository, does anything alert the team? Finally, check whether disabling the integration during an incident is a documented operation or a scramble through tag managers and templates.
The point is not to simulate card theft. The point is to verify the boundaries around third-party execution before someone else tests them for you.
For teams reviewing applications, four questions are particularly revealing:
- Who can publish code to the browser without a pull request? Marketing tags, experiment dashboards and analytics consoles count.
- What happens after that script starts running? Map dynamically loaded scripts, cross-origin connections and frame creation.
- Would the change be visible? Compare fetched script contents over time, retain hashes and investigate new destinations.
- Can the dependency be removed quickly? A kill switch is only useful if the owners know where it is and have tested it.
A response plan must include the browser
Optimizely said it fixed the vulnerability and removed injected code, while taking steps to secure affected accounts. That closes a reported entry point, but downstream organizations still need to establish what their users were served during the exposure window. The vendor's remediation is not a substitute for each website's own review.
For affected deployments, preserve historical script copies and relevant CSP reports, inspect Project JavaScript and experiment code, review account and API-token access, and identify sensitive forms present on the affected pages. Treat observed network requests and payment activity as evidence to investigate, not proof that every visitor lost data. The public reporting as of November 17 did not establish a complete count of stolen card details or successfully compromised iOS devices.
The lesson is less about distrusting a particular vendor than about being precise with the word trusted. HTTPS authenticates the delivery channel. An allowlist recognizes the source. Neither tells you that tomorrow's JavaScript will behave like yesterday's. If a third party can change code that runs inside your users' sessions, that dependency is part of your application's attack surface, whether or not it appears in your repository.
Find issues like this in your own codebase
SecureHup runs this exact exploit chain — discovery, enumeration and cross-tenant validation — on every deployment, automatically.