# Script integrity

Double Agent's script runs on every page of your site, so you should know exactly what can change it. This page is for
security reviews: how the script is delivered, how to pin it so it cannot change without you, and what we do on our
side.

## Why it matters

On 16 November 2026 attackers added malicious code to the A/B-testing scripts of 178 organisations through a flaw in
Optimizely's Experimentation platform. The code was served from Optimizely's own CDN with its own certificate, so
allowing that CDN in a Content Security Policy did not help. It skimmed cards, swapped crypto wallet addresses and
stole cookies. Any third-party script that can change after you install it carries this kind of risk, ours included.
Double Agent does not inspect other scripts, so it would not have caught that attack. What you can control is how
much each script you load is allowed to change.

## What can change, and what cannot

| You load | Can it change? | Who can change it |
|---|---|---|
| `https://cdn.doubleagent.so/v1/doubleagent.js` | Yes, on every release | Double Agent, through a reviewed release |
| `https://cdn.doubleagent.so/v<version>/doubleagent.js` with `integrity` | No. A changed file is refused by the browser | Nobody |

- **No per-site code.** The script is the same file for every customer. Nothing in the dashboard or the API adds
  code to it: the API only ever returns data, such as a verdict. There is no place to paste custom JavaScript into a
  project.
- **No `eval`.** The SDK does not use `eval` or `new Function`, so your policy does not need `unsafe-eval` for it.
- **Released files are immutable.** A version is published once at its own address and cached as immutable. A build
  that would change a released version's bytes stops, so the version has to be bumped instead.
- **Hashes for every release** are published at [sri.json](https://cdn.doubleagent.so/sri.json).
- **The lazily loaded file is pinned too.** `doubleagent.content.js` comes from the same release as the script and is
  checked against its own hash.
- **Open source.** The detection engine is [public](/docs/agent-detector), so anyone can read what the script decides
  and how.

## Pin a release

```html
<script>window.doubleagent=window.doubleagent||{q:[],push(){this.q.push(arguments)}};</script>
<script async src="https://cdn.doubleagent.so/v0.14.1/doubleagent.js"
  integrity="sha384-64D3NQ5i38e2pw/X2G9+OphRsB5mTU41rv3JLltL6+xbGPIvWmOGoNuzq5/uCvhA"
  crossorigin="anonymous" data-profile="auto"></script>
```

To move to a newer release, take its version and `doubleagent.js` hash from
[sri.json](https://cdn.doubleagent.so/sri.json), review it, and change both attributes together. A pinned release
keeps working, but gets no fixes or new detections until you update it. Every attribute and option works the same
on a pinned release: see [Script tag](/docs/script-tag).

## A Content Security Policy that holds

A policy only protects you if it is narrow. For Double Agent:

```text
script-src  https://cdn.doubleagent.so
connect-src https://api.doubleagent.so
worker-src  blob:
```

The queue line is an inline script, so give it a nonce or a hash rather than allowing `unsafe-inline`. Check every
other script on the page the same way: a vendor that needs `unsafe-eval`, or a tag manager that can add any script
from a web dashboard, can run code you never reviewed.

## Check your own site

The free [Store bot check](/tools/store-bot-check/) reads your home page and shows its Content Security Policy and the
third-party scripts it loads, including the ones whose code can be changed remotely.

## Reporting a problem

Email [support@doubleagent.so](mailto:support@doubleagent.so) if you find a way to change what our script runs.
