Content-Security-Policy error in google chrome extension making

One of the consequences of “manifest_version”: 2 is that Content Security Policy is enabled by default. And Chrome developers chose to be strict about it and always disallow inline JavaScript code – only code placed in an external JavaScript file is allowed to execute (to prevent Cross-Site Scripting vulnerabilities in extensions). So instead of defining … Read more

How to override content security policy while including script in browser JS console?

You can turn off the CSP for your entire browser in Firefox by disabling security.csp.enable in the about:config menu. If you do this, you should use an entirely separate browser for testing. For example, install Firefox Developer Edition alongside your normal browser and use that for testing (and not normal Web use). As an alternative, … Read more

What’s the purpose of the HTML “nonce” attribute for script and style elements?

The nonce attribute lets you to “whitelist” certain inline script and style elements, while avoiding use of the CSP unsafe-inline directive (which would allow all inline script and style), so you still retain the key CSP feature of disallowing inline script/style in general. So the nonce attribute is way to tell browsers the inline contents … Read more

Console shows error about Content Security policy and lots of failed GET requests

Let’s start with the easiest problem: Refused to execute inline script because … $(‘div’, this) selects all <div> elements within a <td>. In the source code you provided, the following event handler can be found: <div class=”smallfont”> <span style=”cursor:pointer” onclick=”window.open(‘member.php?u=47995’, ‘_self’)”>K4raMong</span> </div> By the default Content Security policy, this is forbidden. To get rid off … 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

Content Security Policy: The page’s settings blocked the loading of a resource

You have said you can only load scripts from your own site (self). You have then tried to load a script from another site (www.google.com) and, because you’ve restricted this, you can’t. That’s the whole point of Content Security Policy (CSP). You can change your first line to: <meta http-equiv=”Content-Security-Policy” content=”default-src *; style-src ‘self’ ‘unsafe-inline’; … Read more