If there is no workaround, please clearly state that this cannot be done as WP needed this CSP script-src : ‘unsafe-inline’ ‘unsafe-eval’
WordPress doesn’t need any particular CSP policy. It just needs to be able to execute its code. Using script-src : 'unsafe-inline' 'unsafe-eval'
is just like disabling your computer’s firewall to get some software to run. The software doesn’t actually need the firewall disabled: it just needs to be whitelisted so it can run without being blocked.
I don’t know your CSP definition and what specific “errors” you’re getting, but the solution to all CSP errors is simply to allow all REQUIRED code to be executed, by whitelisting the origins or domains where those resources are loaded from.
But note that inline scripts are blocked by default, even with scrip-src: self;
. This is according to the CSP standard… and has nothing to do with WordPress.
Meanwhile, WordPress, your theme, and all your plugins will likely generate a ton of inline scripts. So even after allowing self
and all external domains in your policy, your site may very well still break.
There’s no “workaround” or hack per se for this, but there’s a proper, secure way to implement CSP while allowing inline scripts… which is to use either hashes or nonses for your inline scripts.
On a WordPress site where themes and plugins inject inline code all over the place, that’s easier said than done.
There are SEVERAL CSP plugins out there, but I don’t know if any of them properly handles inline scripts or not. You may want to experiment with some of them to find out: https://wordpress.org/plugins/search/csp/
I understand that this is not the simple YAY or NAY response you were hoping for. But very little of technology (and security in particular) can be reduced to a simple YES or NO answer.
Good luck!