On 16 November, visitors to the sites of 178 organisations were served malicious JavaScript through Optimizely. These aren't small names. Zoom, the BBC, IKEA, HSBC and Air France-KLM are all on the list, according to security researcher Scott Helme of Report URI (opens in new tab), who found the attack first. BleepingComputer (opens in new tab) saw the script load on Zoom, KLM, the BBC and Salesforce, among others.

What strikes me is that these companies have their own security teams, and it still happened. Their own code wasn't hacked. The problem sat in a script from a supplier they trusted. Any webshop that loads other people's scripts runs that same risk, big or small.

What happened

Optimizely is a platform companies use to run experiments on their website and personalise pages. To do that, they load a JavaScript file from Optimizely on their pages. That file includes a field for the customer's own code, which runs on every page.

That's where the attacker got in. Optimizely confirmed to BleepingComputer that someone exploited a vulnerability in the signup flow for Experimentation accounts and used it to add malicious JavaScript to customer projects. The file was still served from Optimizely's own servers, with its own certificate. To the affected sites, everything looked trusted.

That code loaded a second script, which did several things at once:

  • It replaced crypto wallet addresses on the page and in the clipboard with the attacker's. Report URI says crypto was actually stolen.
  • It read card number, expiry date and CVV from forms and sent them to the attacker. That worked for card fields in a site's own form. Card details typed into a payment window from Stripe, Adyen or similar were out of its reach.
  • On iPhones and iPads it loaded the Coruna and DarkSword exploit kits, which target flaws in older iOS versions.
  • It also collected cookies and screenshots of the page.

Optimizely says it blocked the vulnerable path, deployed a fix and removed the injected code from the projects. According to Report URI, all infected files were clean again by the end of 16 November.

Why this matters for your webshop too

This isn't the first time this autumn. On 29 October, DebugBear's performance monitoring script on polymarket.com was replaced with code that drained accounts. Report URI (opens in new tab) puts the loss at roughly 2.6 million dollars in crypto. That's twice in under three weeks that an external script from a trusted supplier suddenly did something very different. And according to Report URI, the attacker behind the Optimizely attack was already in scripts from Kissmetrics and others between 13 and 16 November.

That pattern is the point for me. Every script you load from someone else, whether it's for testing, analytics, chat or ads, runs in your customer's browser with the same rights as your own code. It can read what's on the page and it can change things, on your checkout too. That isn't theory. This script read form fields and swapped addresses on the page. Report URI puts it well: trusted JavaScript doesn't always remain trustworthy.

What to do now, before Black Friday

Black Friday falls on 27 November this year. This is what I would sort out before then:

  1. List every external script on your site. Which ones are there, who added them, who manages the account with that supplier, and do you still need them? Include whatever comes in through your tag manager.
  2. Remove what you no longer use. A testing tool from an old campaign, or a chat widget nobody looks after anymore, gives you nothing and still carries the risk.
  3. Set up a Content Security Policy, or CSP. That's the security rule that decides which scripts your site may load, and which addresses your page may send data to. Start in report-only mode. The browser doesn't block anything yet, but it does report what falls outside your rules. That way you see what's actually running before you lock anything down.
  4. Consider Subresource Integrity for scripts that don't change. You give the browser a fingerprint of the file. If the file no longer matches, it doesn't run. That doesn't work for scripts a supplier changes all the time, as Report URI also points out. For a fixed version of a library, it does.
  5. Keep your checkout as bare as you can. A testing tool, chat or ad pixel has little business on the page where someone enters their card. And let customers enter card details in your payment provider's payment window. In this case, that kept the card data out of reach.
  6. Actually read the CSP reports. Report-only only helps if someone is looking. A new script, or an unknown address receiving data, is something you want to know about the same day. Polymarket's CSP had no reporting set up, so even if something had been blocked, nobody would have heard about it.

One more thing about CSP, because having one doesn't automatically mean it helps. Report URI checked the CSP of the affected organisations. 68 had none. For 50, the CSP let the script and the theft straight through. For 24, the script was blocked. Allowing Optimizely itself didn't help, because the code came from Optimizely. What did work was a tight list of script sources, without loose settings like 'unsafe-eval' and 'strict-dynamic'. And at 17 organisations the script did run, but a limit on outgoing connections stopped the theft of card data, cookies and screenshots.

Do you use Optimizely yourself? Report URI recommends going through the custom code in every project and experiment for anything you didn't write, and checking who has write access to your account.

Where to start

Not sure which scripts run on your checkout, or who added them? Then now is a good moment to find out, before Black Friday. I run a check of external scripts and CSP for webshops: what's running, what can go, and how to set up a CSP safely in report-only mode. Feel free to get in touch.

Sources