How to detect Content Security Policy (CSP)

You can try to catch a CSP violation error using an event “securitypolicyviolation” From: https://developer.mozilla.org/en-US/docs/Web/API/SecurityPolicyViolationEvent example: document.addEventListener(“securitypolicyviolation”, (e) => { console.log(e.blockedURI); console.log(e.violatedDirective); console.log(e.originalPolicy); });

Content Security Policy: Couldn’t parse invalid source chrome-extension

I solved this same problem for myself after recently posting it as a Facebook bug on https://developers.facebook.com/x/bugs/729597157070762/ With FB’s help I noticed the following unwanted browser extensions in Firefox: Searchme, Slick Savings, Amazon Shopping Assistant, and Ebay Shopping Assistant. Turns out these are essentially malware that effected Firefox, Safari, and Chrome on my Mac. They’re … Read more

Does a *.example.com for a content security policy header also match example.com?

*.example.com for a CSP header doesn’t also match example.com, per the current CSP spec. That text cited from the (old) CSP spec is wrong (now fixed). The other sources cited are right. But that https://www.w3.org/TR/CSP/#source-expression section cited, which defines what a CSP source expression is, isn’t actually stating the relevant normative requirements. Instead the section … Read more

What is happening when I have two CSP (Content Security Policies) policies – header & meta?

If you have CSP directives specified both in a Content-Security-Policy HTTP header and in a meta element, the browser uses the most-restrictive CSP directives, wherever specified. See the details on multiple polices at https://w3c.github.io/webappsec-csp/#multiple-policies and details on using the meta element at https://w3c.github.io/webappsec-csp/#meta-element: A policy specified via a meta element will be enforced along with … Read more

How to fix chrome-extension inline JavaScript invocation error?

By default Content Security Policy, inline scripts won’t be loaded and only local script can be loaded. You could relax the default policy by: Inline Script. Take a look at Official Guide, inline scripts can be whitelisted by specifying the base64-encoded hash of the source code in the policy. See Hash usage for elements for … Read more

Cordova – refuse to execute inline event handler because it violates the following content Security policy

Check this link, it says: Inline JavaScript will not be executed. This restriction bans both inline <script> blocks and inline event handlers (e.g. button onclick=”…”). To avoid cross-site scripting issues like below specified one.app#/home:1 Refused to execute inline event handler because it violates the following Content Security Policy directive: “script-src ‘self’ ‘nonce-d452460d-e219-a6e5-5709-c8af6ca82889’ chrome-extension: ‘unsafe-inline’ ‘unsafe-eval’ … Read more