Security

Optimizely Security Incident: How Hackers Injected Malicious JavaScript Into Websites

For part of one day, an attacker used a flaw in Optimizely's testing tool to make some customer websites load harmful JavaScript. Here is what happened, what the script did, and what developers can do to protect their own sites.

Optimizely Web Experimentation security incident with malicious JavaScript on customer websites
Optimizely says an attacker abused Web Experimentation to run malicious code on some customers' websites on Nov. 16.

Optimizely has published a public account of a security incident in its Web Experimentation product. On Nov. 16, 2026, an attacker used a flaw to put malicious JavaScript on some customers' websites. The company says it fixed the flaw within hours and has contacted every affected customer directly.

The company's update came out on Nov. 25. It says the investigation is still going, and it has hired Mandiant, part of Google Cloud, to help. Mandiant's final report is expected in a few weeks.

How Web Experimentation works

Web Experimentation lets a company test changes on its website, such as a different button or headline. It works by adding one line of JavaScript, called the snippet, to the site. The snippet loads the company's experiments and any custom code it set up.

One piece of that custom code, Project JavaScript, runs on every page where the snippet is installed. That is what made this incident serious: one edit could reach every page.

Plain idea: a snippet is like a doorway into your website. Whatever code sits behind the doorway runs for every visitor.

What happened

How the attacker got in

The attacker found a flaw in an old free-trial sign-up flow. They used it to create their own trial accounts. Then, using brute force guided by public information, they worked out the addresses of real users at Optimizely's customers. That let them impersonate those users, which means acting as if they were the real person. Impersonation was an old feature and has been removed.

Optimizely says that, so far, its investigation shows no passwords or credentials were stolen, no Optimizely administrator account was taken over, and no customer passwords were exposed.

What they changed

Acting as those users, the attacker edited custom JavaScript in a number of customer projects so it loaded a harmful script from a server they controlled. That script then ran in the browsers of people visiting those sites. In some accounts, the attacker also reopened archived projects, so a snippet still sitting on a page could serve code again.

What the malicious script did

The attacker rebuilt the script many times during the day. In the end it did three things:

  1. Swapped crypto wallet addressesWhen a visitor copied or typed a cryptocurrency address, the script replaced it with the attacker's own. When it made a swap, it also sent the page address, a screenshot, and any cookies its scripts could read to the attacker's server.
  2. Skimmed payment cardsFrom about halfway through the attack, a new version also captured card details typed into forms on the page itself: brand, number, expiry date, and security code. Cards entered in iFrames from payment providers such as Stripe or Adyen were not exposed.
  3. Targeted older Apple devicesOn iPhones and iPads running iOS or iPadOS 18.7 and earlier, it loaded a second stage that independent researchers identify as exploit kits, publicly reported as Coruna and DarkSword. Optimizely and its investigators are still checking whether any device was actually compromised, and so far there are no reports of one.

Only Web Experimentation was affected. The attacker tried to change Feature Experimentation settings for some customers but was blocked, and those attempts had no effect on any customer website. Optimizely has seen no sign that other products were touched.

Key moments (all times UTC)

  • Nov. 13: the attacker creates test accounts, which looked like normal sign-ups.
  • Nov. 16, 07:51: the main attack begins and spreads across many customer projects.
  • 13:34: a customer reports a malicious script on its website. This is how Optimizely found out.
  • 16:10: the flaw is fixed. At 16:52 every attacker session is ended.
  • 22:24: malicious code is removed from every affected project.
  • Nov. 17, 00:01: the first notice goes to affected customers.

Was visitor data taken?

Optimizely can see when malicious code was served from each project, but it cannot see what the code captured inside a visitor's browser. Neither could the independent researchers. So the company says it does not know how many cards, wallets, or cookies were accessed.

  • No confirmed card or crypto losses by any customer have been found so far.
  • There is no evidence that customers' experimentation data was involved, and the attacker's goal appears to be only to deliver malicious code.
  • The highest risk is to visitors who typed card details into forms on an affected site, or sent cryptocurrency, while the code was live.
  • Cards entered in payment-provider iFrames and cookies marked HttpOnly were out of reach.
  • Optimizely has found no evidence that data it holds was taken.

How Optimizely says it fixed the problem

  • The flawed sign-up path is fixed and the feature behind it is permanently disabled. Protections on account creation and sign-in are stronger.
  • Every attacker session, identity, and token has been shut down, with no further attacker activity seen since.
  • Controls on internal support tools were tightened.
  • Affected projects were restored to their last clean version by checking each earlier version for the attacker's code. Optimizely's engineers did this without waiting for customer instructions, and the cleanup shows in project history as "Optimizely Support."
  • All current snippets are confirmed clean. Customers do not need a new snippet or to reset passwords or API tokens.
  • A review of sign-in, sessions, permissions, and tokens against the OWASP ASVS 5.0 Level 2 standard has started.

The role of a Content Security Policy

Optimizely's own main website runs the same snippet, and there a Content Security Policy (CSP) blocked the harmful code. A CSP is a set of rules that tells the browser which scripts and servers a page may use. On the login site, though, the policy was only in report-only mode, so the code was served. That policy is now enforced.

Important detail: Optimizely says allowing its whole cdn.optimizely.com domain did not help, because the attacker's code was served from Optimizely's own host. Allow only the exact sources you use.

How Optimizely admits it fell short

The company says it focused first on stopping the attack and removing the code. It sent its first notice to customers only after confirming who was affected and reverting the code. It also says that gap may have been hard for teams deciding what to do about their own sites, and that it could have done better on its public channels.

It thanked the customer who reported the problem first, and independent researchers including Report URI, whose public analysis helped everyone move faster.

What Optimizely plans to change

  • Extra approval: a second person will have to sign off on changes to Project JavaScript and other custom code before it goes live.
  • Native alerts: security contacts will be told right away when code, users, tokens, or webhooks change. Until then, webhooks and scheduled checks can do this job.
  • Better detection: stronger monitoring of account creation and code changes, plus anomaly detection and automatic responses across its systems.
  • AI-assisted code scanning: scanning all its code, including older code, with advanced AI models, with an engineer approving each fix.
  • Stronger identity rules: multifactor sign-in for every system it runs, tests for impersonation, and regular rotation of machine credentials.
  • Clearer guidance: updated documentation on what a "right" CSP looks like.

What It Means for Developers

You do not need to use Optimizely to learn from this. Any third-party script on your site can run with the same power as your own code.

What It Means for Frontend Developers

Frontend developers decide what scripts load on a page, so they are close to this risk.

  • List every third-party script on your site, especially checkout, login, and form pages.
  • Keep tag and testing snippets off payment and login pages unless you are testing there.
  • Use hosted payment fields (iFrames) for card entry, since cards entered in iFrames were out of the attacker's reach.
  • Review your own JavaScript and HTML for scripts or loaders nobody on the team wrote.

What It Means for Web Developers

Web developers can add a protective layer with a Content Security Policy.

  • Start with a CSP in report-only mode, then enforce it after a month of reports that cover checkout, login, and forms.
  • Optimizely says a restrictive script-src blocked the harmful script and a tight connect-src stopped card, cookie, and screenshot theft. It did not stop wallet swapping, which happens inside the page.
  • Allow only the exact script sources you use, not a whole domain.

What It Means for Backend Developers

The entry point here was identity and legacy code, which are backend topics.

  • Shut down old sign-up or trial flows that nobody uses.
  • Be careful with any "impersonation" or support feature, and keep it tightly controlled.
  • Mark your own session cookies HttpOnly, Secure, and SameSite=Lax so page scripts cannot read them.
  • Send security headers from your server, for example with Nginx or Express.

What It Means for DevOps Engineers

Operations teams own access, alerts, and recovery.

  • Limit who can edit custom code, require single sign-on and multifactor sign-in, and remove API tokens nobody can explain.
  • Alert on changes to code, users, tokens, and webhooks, and watch project history until automatic alerts exist.
  • Build a kill switch that turns a third-party snippet off in minutes, one you control yourself, and test it.
  • If you removed a snippet, bring it back in phases: staging first, then low-risk pages, then key flows.
  • Plan a quarterly review of users, roles, tokens, code, integrations, and the sources your policy allows.

What to watch next

The incident is not fully closed. Optimizely points to a few things:

  1. Mandiant's final reportIt is expected in a few weeks, and Optimizely says it will share updates with customers.
  2. Device impactOptimizely and its investigators are still checking whether the iPhone and iPad exploit kits compromised any device.
  3. New product protectionsExtra approval for custom code and native change alerts are planned. The full security plan is due in a separate post in the next few weeks.

Bottom line

An attacker used a forgotten sign-up flaw to edit code that runs on every page of some Optimizely customers' sites. The script swapped wallet addresses, skimmed card details from page forms, and targeted older Apple devices. Optimizely says it fixed the flaw within hours, but it cannot tell how much visitor data the script captured.

For developers, the lesson is clear: treat third-party scripts as part of your attack surface. Review them, limit who can change them, use a strict CSP, keep payment fields in iFrames, and have a kill switch ready.

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author