Quick recap if you missed it. On 16 Nov researchers found malicious JavaScript injected into scripts served by Optimizely's Experimentation platform. Optimizely says an unauthorised party exploited a vulnerability, and they've fixed it and removed the injected code. Newsweek counts 178 major sites that loaded it. The payload went after card details, redirected crypto payments and grabbed browser-stored data.
None of those sites were hacked directly. They loaded a trusted vendor's script, and the vendor got hit. That's the part worth thinking about, because almost every site does this.
Here's what actually helps, from most to least impactful:
- Know what scripts you load.
List every third-party script on your site, especially on checkout and login pages. Tag managers make this easy to lose track of. Remove anything you don't use. Fewer scripts means fewer ways in.
2. Keep third-party scripts off payment pages.
Use hosted payment fields or a hosted checkout, so card numbers are typed into the payment provider's iframe, not your page. A compromised analytics or A/B script on your page can't read inside that iframe.
3. Content Security Policy
Set script-src to an allowlist of the domains you expect, and connect-src to the domains your page should be talking to. Even if a script gets swapped, it has a harder time sending stolen data to a new domain. Start with Content-Security-Policy-Report- Only so you see violations before you break anything.
4. Subresource Integrity where it works
For fixed, versioned files from a CDN, add an integrity hash so the browser refuses a modified file. Honest caveat: this doesn't work for scripts like A/B testing snippets that change on purpose, which is exactly the Optimizely case. That's why 1 to 3 matter more.
5. Watch for script changes.
Monitor the scripts on your payment pages and get alerted when one changes. If you take cards, PCI DSS 4.0 now asks for this anyway (requirements 6.4.3 and 11.6.1: script inventory, justification and change detection on payment pages).
6. Lock down vendor accounts
MFA and least access on your tag manager, A/B testing and analytics accounts. A lot of script injections start with a stolen login, not a vendor bug.
If you use Optimizely, check their status page and your project's custom JavaScript, and talk to your payment provider if you take cards on pages that loaded it.
Curious how people here handle it. Does anyone actually run CSP in enforce mode with a tag manager, or does it break too much?