MocioF / No-unsafe-inline

A wordpress plugin to set Content Security Policy (CSP) without using the 'unsafe-inline' keyword for script-src
https://wordpress.org/plugins/no-unsafe-inline/
GNU General Public License v2.0
12 stars 3 forks source link

Testing csp policy phase is preventing webrowser to load ressources #12

Open Barnoux opened 8 months ago

Barnoux commented 8 months ago

Hello,

I was testing the policy and the product owner notified me that some ressources are not loaded in the browser during the fifth phase that is mentionned in the helper of the plugin

Leaving the tag capture active, activate the policy test (at this stage the plugin will generate some violations of the temporary policy used to record additional values to be included in the directives of your "content security policy").

This is an example found in the browser console with the devtool. image

I thought that during this phase, the policy couldn't impact the client naviguation on the wordpress site. It appeared to me that the testing CSP policy doesn't "always" prevent a loading.

maybe i miss something ?

regards, BBA

MocioF commented 8 months ago

The line you copied reports "Report Only". This should not prevent the script from loading.

Barnoux commented 8 months ago

Ok well i have an issue then... When the test policy is not applied, browser clients correctly load the ressources. How can i troubleshoot this ?

MocioF commented 8 months ago

Sorry, I don't understand. If you don't apply any policy, why browsers should not load whatever they find in the page?

Barnoux commented 8 months ago

My bad i wasn't clear in my statement.

MocioF commented 8 months ago

Is the resource whitelisted? How did you whitelist it? Can you post a link to the page with the problem?

Barnoux commented 8 months ago

i'm testing the plugin in a test environnement so i can't send you a link because you could not have access to the page.

when the pages are not loaded this is the common error that i have in the console : image as we can see in the console log the test policy is activated.

One thing that is als strange, the CSP policy is not always in the HTTP response header.

MocioF commented 8 months ago

Try to use nonces and not hashes. Maybe the CSP generated with hashes is too big to fit the response header size of your server.