by horsawlarway · 1w ago · 0 comments
As an aside - I'm rabidly against "analytics" companies that come in and suggest that the right "getting started" choice is to drop untrusted JS they own (and can update at any time) onto your site.
It's "easy", but it completely breaks your security model.
If I were a lawyer... I'd be taking a serious look at putting optimizely into the meat grinder for recommending 'unsafe-eval' as a script source... it literally has "unsafe" in the fucking name for a reason. This alone should end the company. It won't, because this space is absolutely FILLED with scummy behavior, but it should.
---
A strict CSP is one of the most meaningful ways you have right now as a web developer to reduce attack surface. People should take advantage of it.
There's a reason browser vendors now force basically all extensions into a strict CSP by default... https://developer.chrome.com/docs/extensions/reference/manif... They won't even let you manually relax it anymore.
So are equivalent companies that recommend similar strategies. Sprig, segment, amplitude, launchdarkly, heap, full story, etc...
It's a very long list.
They all operate on the same strategy. Pitch to execs that they solve real problems and they have basically no eng cost to implement.
All you need to do is inject them into your page with absolutely no restrictions and let them run any scripts they'd like.
Softer questions might be: why is eval (still) being used for any inputs at all; and to the extent that it is used, why did¹ the docs not concede the breadth of CSP unsafe-eval (which allows eval in all scripts, not just Optimizely's), and why do the docs actively discourage attempts to enable Trusted Types (which includes the much narrower CSP trusted-types-eval²) instead of actively facilitating its use?
And needless to say, a more direct question would be: why should customers use a class of product that is so powerful that unsafe-eval doesn't increase its capabilities at all?
¹ cf. https://web.archive.org/web/20260810141143/https://support.o... vs. https://docs.optimizely.com/web-experimentation/docs/update-... (updated yesterday).
² ~84% browser support, per https://caniuse.com/mdn-http_headers_content-security-policy...