ForgeNEX

Optimizely compromised: malware served from CDN to hundreds of websites

JavaScript code signed by Optimizely was modified to steal crypto wallets, cards and cookies, and to attack iPhone and iPad. We analyze the risk for SMEs.

5 min read

In this article

When we talk about web security, we tend to think about our own server, the firewall or the CMS plugin. But there is a layer that almost nobody audits and that, nevertheless, runs on every visit: third-party JavaScript. This week we have learned of a case that perfectly illustrates that blind spot. According to Ars Technica, hundreds of websites that use the Optimizely personalization platform have served their visitors a rather aggressive malware cocktail, with targets ranging from cryptocurrency wallets to payment card data.

The information attributes the finding to the research firm ReportURI, which identified 178 affected sites, including high-traffic media outlets and services such as CNN, Zoom, the BBC and Salesforce. These are not exactly small-time websites, and that is what should make us raise an eyebrow: if it can happen to them, the argument that "we are too small to be a target" falls apart on its own.

Illustrative detail: Hundreds of websites deliver potent malware cocktail to unsuspecting visitors

What exactly happened

Optimizely provides its clients with JavaScript snippets, the so-called snippets, which combine the platform's own code with code supplied by each client. That JavaScript runs on every page of the site, and can be served directly from Optimizely or from a client endpoint. According to the published information, the attackers managed to insert their own code into a portion of each affected client's JavaScript and served it from cdn.optimizely.com, with a valid certificate for that domain signing the script. In other words, the visitor's browser had no way of distinguishing that malicious code from any other legitimate resource of the platform.

The result, when the payload was successfully installed, was a fairly broad range of actions:

  • Replacement of the user's cryptocurrency wallet addresses with those of the attackers, so that payments ended up in their pockets.
  • Capture of payment card data through skimming techniques.
  • Theft of session cookies and screenshots.
  • Delivery of exploit kits for iOS, identified as Coruna and DarkSword, aimed at iPhone and iPad.

It is worth underlining one detail: the malware was not installed on the victim website's server, but ran in the browser of whoever visited it. That completely changes the liability model and, above all, the way to defend yourself.

Why this matters to an SME

At first glance, an average Spanish SME has no reason to use Optimizely. But the underlying pattern does affect it, and a lot. Most current corporate sites load third-party scripts: analytics, live chat, advertising pixels, tag managers, booking systems, review widgets. Each of those scripts runs with the same privileges as your own code and can read the DOM, cookies and forms. A compromise at any of those providers becomes a de facto compromise of your website.

And there is a second message, perhaps the most uncomfortable one: digital code signing is not enough. In this case the JavaScript was signed with a valid certificate for the CDN domain. The chain of trust was scrupulously fulfilled. What failed was control over who could modify the served content. For an IT team, this is a lesson about the limits of the certificate-based trust model: they guarantee the identity of the issuer, not the integrity of the content throughout its entire lifecycle.

What we recommend doing right away

We are not going to ask anyone to dismantle their marketing stack, but we are going to ask them to treat it as an attack surface. Some concrete measures that we can apply in an SME without the need for a huge team:

  1. Inventory of third-party scripts. Know exactly which external domains are loaded on each page, who authorizes them and for what. If there is no list, the first step is to build one.
  2. Content Security Policy (CSP). A well-defined policy limits which origins can run scripts. It is not a silver bullet, but it drastically reduces the room for manoeuvre of an attacker who manages to inject code from a third party.
  3. Subresource Integrity (SRI) where the provider allows it. It lets the browser verify that the served file is exactly the expected one.
  4. Periodic review of providers. Not only whether they comply with GDPR, but also whether they publish security advisories, whether they have a contact channel and whether their code delivery model is auditable.
  5. Client-side monitoring. Tools that detect unexpected changes in the DOM or in the browser's outbound requests.

This incident fits a trend we have been observing: the attacker is no longer only after the server, they are after the supply chain. It is the same logic we saw when we discussed how Webworm disguised SoftEther VPN to spy on networks without being detected, or when we analyzed the critical 9.8 flaw in vmdir in VMware vCenter. In all cases, the vector is a link in the chain of trust that nobody was watching with enough attention.

The part we cannot solve on our own

There is a component of the incident that is beyond the reach of any SME: the provider's response. The news does not detail how the malicious code was introduced into Optimizely's infrastructure or when the breach was closed. What we do know is that the script was served from its CDN with a valid certificate, which points to a compromise in the provider's publishing chain. For affected clients, the key question is whether their own snippets were altered and for how long. That information must come from the provider, not from the client.

Our closing recommendation is simple: if your website loads third-party JavaScript that you do not control, assume that code is part of your risk surface and act accordingly. You do not need to be CNN for a skimmer in the payment form to ruin the reputation of a small online store. The asymmetry between the cost of prevention and the cost of an incident remains overwhelming.

Source: Ars Technica. Analysis and adaptation: ForgeNEX.

Keep reading

Call us WhatsApp