Site icon NexGismo

Optimizely Supply Chain Attack: The CSP Settings That Held

Optimizely Supply Chain Attack: The CSP Settings That Held
TL;DR
  • What: Attackers wrote malware into Optimizely Web Project JavaScript, served from Optimizely’s own CDN.
  • Why it matters: Allowing a vendor’s domain in your CSP did nothing; the poisoned code came from that domain.
  • What to do: Drop ‘strict-dynamic’ and ‘unsafe-eval’ where you can, lock down connect-src, and hash-watch vendor scripts.
  • Key stat: Only 24 affected organisations (15%) had a CSP that blocked the payload.

The Optimizely supply chain attack was a 16 November 2026 compromise. An attacker inserted a malicious loader into customers’ Optimizely Web Project JavaScript. Browsers trusted it because it came from cdn.optimizely.com. A restrictive Content Security Policy could not stop the snippet itself. It could block the follow-on script, the eval fallback and the data theft.

A client-side supply chain attack compromises a third-party script that a website loads into visitors’ browsers. The site’s own servers are never touched. The malicious code gets the same access to the page, forms and cookies as first-party JavaScript, and it arrives from a domain the site already trusts.

The Optimizely supply chain attack is the cleanest real-world test of Content Security Policy in years. On 16 November 2026, Report URI found malicious code in 188 of 1,611 Optimizely snippets. They belonged to 178 organisations, including Zoom, the BBC, CNN and HSBC. None had their own servers breached. They loaded a script they always loaded, from a host they always trusted.

Most of us added the vendor’s domain to script-src, copied the vendor’s sample policy, and moved on. This post shows what the payload needed from the browser and which CSP settings stopped it. It also shows why the vendor’s own example let the first stage through. You get a Node.js CSP auditor and a script watcher, run on Node v22.23.5.

What happened in the Optimizely supply chain attack?

An attacker gained write access to many unrelated Optimizely Web projects. They added a loader to each project’s Project JavaScript field. Optimizely’s status page blames “a flaw in the Optimizely Web Experimentation account signup flow” used to impersonate users. Optimizely says it closed the hole within three hours of detection. It says less than 5% of its customers were impacted.

The exposure window was longer than that. The first injection was seen at 04:21 UTC. A card skimmer was added at 13:43 UTC. The last infected file Report URI monitored was clean at 23:11 UTC, almost 19 hours later.

What did the payload actually do?

The loader inserted a script tag for track.js on an attacker domain. Per Report URI’s analysis, that script:

  1. Swapped cryptocurrency wallet addresses in page text, form fields, the clipboard and outgoing requests.
  2. Skimmed card numbers, expiry dates and CVVs typed into the site’s own form fields, sending them with navigator.sendBeacon.
  3. Stole cookies not marked HttpOnly, plus screenshots rendered with html2canvas.
  4. Loaded iOS exploit kits in a hidden iframe for older iPhone and iPad versions.

The payload was rebuilt 26 times during the day. The attacker’s wallets received about $7,150 before being emptied. Cards typed into hosted payment iframes, such as Stripe or Adyen, were out of reach.

Why didn’t allowing cdn.optimizely.com protect anyone?

A host allowlist says where code may come from, not whether it is honest. Report URI put it bluntly: “Allowing cdn.optimizely.com was never going to help.” Apart from the Project JavaScript field, the snippet was a normal Optimizely file.

The loader came in three shapes. One was a plain script tag. One hid the URL behind atob(). The third was an inline copy of the payload, run with eval when the attacker’s domain was blocked. Each shape needs something different from the browser. That is where CSP earns its keep.

Nor was this a one-vendor event. Report URI traced an earlier wave via Kissmetrics, StorifyMe and Minute Media scripts. Any tag with a writable “custom code” field carries the same risk. Our guide to npm supply chain attack defense layers covers the build-time half of this problem.

Which CSP settings stopped the Optimizely supply chain attack?

A restrictive script-src without 'strict-dynamic' was the deciding factor. Report URI crawled 256 hosts of affected organisations. It sorted the organisations by what their CSP allowed:

How ‘strict-dynamic’ passed trust to the attacker

'strict-dynamic' tells the browser to trust any script inserted by an already-trusted script. Per MDN’s script-src reference, allowlist entries such as 'self' “will be ignored” when it is present. So the nonce-tagged snippet was trusted. It inserted track.js. The browser never checked that new host against anything.

Here is the uncomfortable part. Optimizely’s own CSP documentation recommends a nonce plus 'strict-dynamic'. Its simplified version is just script-src 'nonce-[your-nonce-value]' 'strict-dynamic'. That is sound advice against classic XSS. It fails when the trusted loader itself gets poisoned.

How ‘unsafe-eval’ undid an otherwise good policy

The inline fallback ran wherever 'unsafe-eval' was allowed. At HSBC, the CSP blocked track.js and the data theft, but the inline copy still ran. Some Optimizely features need 'unsafe-eval', such as audiences with custom JavaScript conditions, notes Optimizely MVP Mark Stott. Removing it is a product decision, not just a header change.

How do you audit your CSP against this attack in Node.js?

Check your policy against the four things the payload needed. Those are a script from a new host, eval, an outbound connection and a hidden iframe. The auditor below models the key CSP Level 3 rules: default-src fallback, host lists ignored under 'strict-dynamic', and eval needing 'unsafe-eval'. It is a triage model, not a browser test.

// csp-audit.mjs (excerpt)
export function audit(header, { newHost = 'https://evil.example/track.js' } = {}) {
  const csp = parseCsp(header);
  const script = fallback(csp, 'script-src', ['default-src']);
  const sd = script?.includes("'strict-dynamic'");
  return {
    insertedScriptFromNewHost: script === null || sd || hostAllowed(script, newHost),
    evalFallback: script === null || script.includes("'unsafe-eval'"),
    exfilViaConnect: hostAllowed(fallback(csp, 'connect-src', ['default-src']), newHost),
    hiddenIframe: hostAllowed(fallback(csp, 'frame-src', ['child-src', 'default-src']), newHost),
  };
}

We ran node csp-audit.mjs on Node v22.23.5 against four policies. Policy B is the full example from Optimizely’s CSP page, placeholders filled in. true means the attack step is allowed.

policy                                   newHostScript  evalFallback  exfil  iframe
A: no CSP                                true           true          true   true
B: Optimizely docs full example          true           false         false  false
C: allowlist + unsafe-eval, open connect false          true          true   true
D: allowlist, no eval, tight connect     false          false         false  false

Policy B lands in Report URI’s “partial” group. The payload loads through 'strict-dynamic'. A narrow connect-src and default-src 'none' block the theft and the iframe. Wallet swapping would still work. Policy C mirrors the HSBC pattern. Only policy D blocks all four steps.

What does a hardened CSP look like for a Node.js or Next.js app?

Use a per-request nonce, but keep an explicit host allowlist. Leave out 'strict-dynamic' when a writable vendor loader is your root of trust. This node:http server sends policy D. The same logic fits Express middleware or a Next.js proxy.ts.

import http from 'node:http';
import { randomBytes } from 'node:crypto';

function cspFor(nonce) {
  return [
    "default-src 'self'",
    // No 'strict-dynamic': scripts the snippet inserts must match this list.
    `script-src 'self' 'nonce-${nonce}' https://cdn.optimizely.com https://*.optimizely.com`,
    "connect-src 'self' https://logx.optimizely.com",
    "img-src 'self' https://cdn.optimizely.com",
    "style-src 'self' 'unsafe-inline' https://*.optimizely.com",
    "frame-src 'none'",
    "object-src 'none'",
    "base-uri 'none'",
    'report-uri https://example.com/csp-reports', // legacy, still needed
    'report-to csp-endpoint',
  ].join('; ');
}

http.createServer((req, res) => {
  const nonce = randomBytes(16).toString('base64');
  res.setHeader('Reporting-Endpoints', 'csp-endpoint="https://example.com/csp-reports"');
  res.setHeader('Content-Security-Policy', cspFor(nonce));
  res.setHeader('content-type', 'text/html');
  res.end(`<script nonce="${nonce}" src="https://cdn.optimizely.com/js/123456789.js"></script>`);
}).listen(3000);

We started this server and piped its live header into the auditor. All four checks returned false. Accept two trade-offs deliberately:

  1. Without 'strict-dynamic', every vendor host must be listed. Expect violation reports when a vendor adds one.
  2. Without 'unsafe-eval', custom JavaScript audience conditions may break, per Stott’s write-up.

No CSP today? Start with Content-Security-Policy-Report-Only, as MDN’s CSP guide recommends, then enforce. Report-only mode detects but does not protect. MDN also advises sending both report-to and report-uri, since report-to lacks full cross-browser support. Our Next.js 16 auth and security mistakes guide covers where proxy-level code does and doesn’t run.

Why can’t Subresource Integrity fix this, and what can?

Subresource Integrity needs a fixed hash, and experimentation snippets change on every publish. For mutable vendor tags, Chrome’s Modern Web Guidance says to “omit integrity on that URL and restrict it with Content Security Policy (strict-dynamic / nonces) or iframe sandboxing instead.”

Most write-ups miss this. MDN’s own CSP guide also suggests adding strict-dynamic when a trusted script loads third-party scripts. The Chrome guidance just shipped as Modern Web Guidance 1.0, a skill for AI coding agents. An agent following it literally would add 'strict-dynamic' for a vendor tag. That is the setting that carried this attack. If agents write your headers, review their CSP against your real vendor list.

Watch the script, not just the policy

The practical substitute for SRI is change detection. Our script-watch.mjs stores each vendor script’s SHA-256. It flags new risky patterns and hosts outside an allowlist. We served a clean snippet locally, then one with Report URI’s published loader shape (host defanged):

run 1 (baseline):        changed: false  risky: []                    alert: false
run 2 (unchanged):       changed: false  risky: []                    alert: false
run 3 (after injection): changed: true   risky: ['script injection']  unknownHosts: ['evil.example']  alert: true

We also tested the atob() variant. The host check found nothing, because the URL was base64-encoded. Only the atob decode pattern caught it. With no clean baseline, that run did not alert. Capture baselines before you need them.

What should teams using Optimizely Web do right now?

Clean up first, then fix the structural risk. Based on Report URI’s guidance and Optimizely’s statement:

  1. Search all Project JavaScript and custom code for 1688360.cc, atob( and code you didn’t write.
  2. Review users, API tokens and integrations with write access. Rotate credentials.
  3. Rotate secrets stored in non-HttpOnly cookies.
  4. Search 16 November CSP violation reports for the published indicators.
  5. Keep experimentation and tag scripts off checkout and account pages. Use a hosted payment iframe.
  6. Run the auditor and script watcher in CI or on a schedule.

AI agents that browse for you face the same trust problem; see our AI browser agent security guide.

Which control stops which stage of the Optimizely payload (sources: Report URI, MDN, Optimizely docs; sandbox auditor run on Node v22.23.5)
Control Blocks new-host script Blocks eval fallback Blocks data theft Stops in-page wallet swap
Allow cdn.optimizely.com only No No No No
Nonce + ‘strict-dynamic’ (Optimizely docs) No Yes, unless ‘unsafe-eval’ Yes, if connect-src is narrow No
Host allowlist, no ‘strict-dynamic’ Yes Only without ‘unsafe-eval’ Only with narrow connect-src No
Narrow connect-src No No Yes (17 sites in Report URI’s sample) No
Hosted payment iframe No No Cards only No
Script hash monitoring Detects, doesn’t block Detects, doesn’t block Detects, doesn’t block Detects, doesn’t block

The NexGismo verdict: The Optimizely supply chain attack proves “trusted vendor” describes the past, not the present. My recommendation: keep nonces, but drop 'strict-dynamic' where a writable vendor loader is the root of trust. Treat 'unsafe-eval' as a feature cost you sign off on, and lock connect-src to destinations you can name. Then monitor vendor script hashes, because no header can judge code on an allowed host.

Frequently Asked Questions

What happened in the Optimizely supply chain attack?

On 16 November 2026, an attacker abused a flaw in Optimizely Web Experimentation’s signup flow. They wrote a loader into customers’ Project JavaScript. Report URI found it in 188 of 1,611 snippets, across 178 organisations. The payload swapped crypto addresses, skimmed cards and stole cookies.

Does a Content Security Policy stop a compromised third-party script?

Not the first stage. If your policy allows the vendor’s domain, the poisoned snippet runs. A restrictive CSP can still block the next steps: scripts from a new host, code run through eval, and data sent to unknown destinations. In Report URI’s sample, 24 organisations blocked the payload.

Is ‘strict-dynamic’ safe to use with third-party scripts?

It is safe against script tags injected into your own HTML. It is risky when a trusted vendor loader can be modified. Every script that loader inserts inherits its trust, and host allowlists are ignored. That is how the Optimizely snippet loaded the attacker’s track.js.

Can Subresource Integrity protect an Optimizely or tag manager snippet?

Not in practice. Subresource Integrity checks a file against a fixed hash. Experimentation and tag manager snippets change whenever someone publishes, so a pinned hash would break them. Use a tight CSP instead, keep these scripts off payment pages, and monitor their hashes for unexpected changes.

Was Optimizely CMS affected by the Web Experimentation attack?

Optimizely’s status page says no. It says the incident was limited to Web Experimentation and no other product was affected. It also says under 5% of customers were impacted and this was not a credentials breach. CMS sites that load the Web Experimentation snippet should still check it.

Where does this leave your third-party scripts?

The Optimizely supply chain attack was contained within a day, but the pattern will repeat with another vendor. Every tag on your page is someone else’s code running with your site’s authority. A CSP cannot vouch for that code. It can limit where the code loads from, whether it can eval strings, and where it can send data. Pull your current header and run it through the four checks above. Then decide on purpose which trade-offs you accept. For the build-time layer, read our guide to npm supply chain defenses. Which vendor tags were hardest to fit into a strict policy for you?

Sources

Exit mobile version