| ▲ | Jach a day ago | ||||||||||||||||
Besides specifying scripts by hashes, you can also whitelist various domains: https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP (and https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/...) Feels nice knowing several years ago I worked on forcing CSP (including removing unsafe-eval) on some customers for a site builder product, as they have to manually whitelist domains which limits the impact of these sorts of attacks... This writeup https://blog.report-uri.com/worlds-largest-brands-infected-w... has a section on how CSP helped (or didn't) in this attack. | |||||||||||||||||
| ▲ | horsawlarway a day ago | parent [-] | ||||||||||||||||
Yeah, honestly I wish they'd move that section higher up - it's probably he most genuinely useful tidbit in the article. 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. | |||||||||||||||||
| |||||||||||||||||