Эту страницу ещё не перевели, поэтому она на английском. English version →

← Все статьи

A/B testing script security after the Optimizely attack

Автор
Артём Киреев
Читать
6 min
Категория
E-commerce & CRO

On November 16, an attacker used a flaw in Optimizely's Experimentation signup flow to write malicious code into the custom JavaScript field of customer projects. Visitors to sites like the BBC, CNN and IKEA got the code from a CDN their browsers already trusted. Security teams are now arguing about allowlists and hashes.

This piece is for the people who own the experimentation tool: CRO leads, product designers and growth managers. Your A/B testing platform is a code editor with a marketing login, and the fix is mostly about who can edit it, where it runs and how you notice change.

A laptop screen showing lines of code in a dark room
рис. 01 · A laptop screen showing lines of code in a dark room · Фото: Nat на Unsplash

§ 01

What the Optimizely attack actually did

Optimizely lets customers add a "Project JavaScript" field to their experimentation snippet. It is meant for custom variation logic. According to Socket's write-up, the attacker put a loader in that field, and Optimizely confirmed the entry point was a vulnerability in its Experimentation account signup flow.

The affected sites did nothing wrong in the usual sense. They were not breached. Their pages loaded a script from the same Optimizely infrastructure they had loaded for years, and that script now carried extra code. Researcher Scott Helme found 188 infected snippets tied to 178 organizations, and he says the real number is probably higher.

The payloads were practical. A wallet clipper swapped cryptocurrency addresses in copied text, and later variants reportedly skimmed card data. ITPro's summary adds that the attacker revised the malware several times over a few hours on Monday, and that Optimizely has more than 9,000 customers.

Optimizely says the hole is fixed and the injected code is removed. Treat that as a statement about their side only. Whether your project was touched, and what your team does differently now, is your side.

§ 02

Why allowlists and domain trust did not help

The standard answer to third-party script risk is a Content Security Policy. The numbers from this incident are not kind to it. Vendor cside's analysis counts 256 affected sites and says only 24 had a CSP that blocked the payload. Sixty-eight had no CSP at all.

The reason is structural. A script-src allowlist approves hosts, not code. Because the CDN host was already on the list, the loader ran. The address swap also happens entirely in the DOM, with no network request, so rules that restrict where data can be sent do not stop it. cside sells client-side monitoring, so weigh its framing accordingly, but the CSP mechanics are standard.

The same logic breaks vendor review. You approved Optimizely once, at onboarding. The domain, the script URL and the tag never changed. Only the contents of your project did, and the contents are edited by people and API tokens, which is a security question dressed as a marketing one.

I think this is the lesson most teams will miss. They will tighten the CSP, which is worth doing, and leave the actual door open: a long list of accounts that can publish code to every page of the store.

§ 03

The experimentation tool is a production deploy path

Ask who can ship code to your checkout. Engineering will name the repository, the review rules and the CI pipeline. Then ask who can publish an experiment with custom JavaScript. The list is usually longer, with fewer controls: designers, agency contractors, a growth hire from two years ago, and API tokens nobody remembers creating.

Experiment code skips most of the safeguards, and it does so by design. The point of a visual editor is that a non-engineer can change a page in an afternoon. That speed is why teams buy the tool, and it is also why one stolen login can reach every page the snippet loads on.

Treat the platform as a deploy target. Enforce SSO and two-factor authentication. Remove collaborators who no longer need access. List API tokens and delete the ones without an owner. Then decide who is allowed to write custom JavaScript at all, as opposed to using the visual editor's built-in changes. For most stores that group should be two or three named people.

Review the change history for the days around November 16 and 17, and look for collaborators or tokens you do not recognize. This takes an hour. It is probably the most useful hour you will spend on this problem.

§ 04

Keep experiments off the pages that handle money

Most conversion tests do not need to run on payment, account or login pages. Socket's advice to site owners makes the same point: ask whether experimentation and personalization scripts need to run on sensitive pages at all, because a script with page access can read whatever the page shows.

Platforms differ here. On Shopify, scripts can no longer be dropped into checkout freely. Shopify's pixel documentation says pixels run in a sandbox, and that sandboxes cannot render interface elements such as buttons, forms, banners or modals. That limit is annoying for testers and good for security. A tool that cannot touch the DOM cannot clip a wallet address from it.

If you run your own stack, you can copy the principle. Scope the experimentation snippet to catalog and cart pages by default. Put checkout tests through the same review as any other code change. The test you lose is usually a small one, since the large gains in a checkout come from fewer fields and clearer errors, not from a variant injected at runtime.

There is a compliance angle if you take cards on your own pages. Adyen's PCI DSS guidance describes requirement 6.4.3, which asks for a method to confirm each payment page script is authorized, a way to assure its integrity, and a written inventory with a justification for each script. Requirement 11.6.1 asks for tamper detection on payment page scripts as the browser receives them. Adyen notes that merchants eligible for SAQ A are outside this scope, so check which form you file.

§ 05

Watch what scripts do, not where they load from

Hash pinning sounds like the obvious fix, and for most experimentation tools it does not work. cside points out that hashes break whenever an experiment changes, which for an active program is several times a week. A control that fails every Tuesday gets switched off.

The workable middle is cheaper. Record a hash of each third-party script as served and alert when it changes, rather than blocking. Run your CSP in report-only mode first and read the reports before you enforce anything. Watch for new outbound hosts, reads from payment fields and unexpected DOM rewrites on the pages that matter. None of this stops a determined attacker, and I would not claim otherwise, but it turns a silent change into an alert.

Add a pre-flight step to your own release habits too. If your team already freezes risky changes before peak season, as in the Black Friday code freeze checklist, put the experimentation platform inside the freeze. An experiment launched on the Wednesday before Black Friday is a production change like any other.

§ 06

A checklist you can run this week

Start with access. Pull the list of everyone with edit rights in your experimentation tool and cut it to the people who ran an experiment in the last 90 days. Turn on SSO and two-factor authentication if either is missing. Revoke API tokens that have no named owner.

Next, inspect the code. Open every custom JavaScript field in every project and read it. Look for base64 strings, URLs on domains you do not recognize, and code that touches clipboard events or form fields. Compare the change history against November 16 and 17.

Then reduce exposure. List the pages the snippet loads on and remove it from checkout, login and account pages unless a live test truly requires it. Write the names of the two or three people allowed to publish custom code, and tell the agency that their logins no longer do.

Finally, add detection. Switch on CSP report-only mode, log script hash changes for every third-party script on cart and checkout, and decide who gets the alert. If a payment team exists, tell them what the snippet can reach.

Do the same for tag managers, personalization tools and chat widgets. They share the property that made this attack work: a trusted host, a marketing login, and no code review.

// заметки читателей

Было полезно?

Отметьте или оставьте заметку ниже. Я читаю каждую.

Появится с вашим именем и ролью, когда я её прочитаю. Почта остаётся скрытой.

// новые статьи на почту

Следующая статья придёт вам на почту.

Примерно раз в неделю, о продуктовом дизайне для SaaS и e-commerce. Письма на английском, отписаться можно в любой момент.

Мои проекты избранное
/01 2025
Microsoft Copilot

Microsoft Copilot

Продуктовый дизайн

/02 2026
Pagedeck: редизайн no-code конструктора страниц

Pagedeck: редизайн no-code конструктора страниц

Продуктовый дизайн