Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WebProfilerBundle] New CSP directives broken with default-src #36641

Closed
Khartir opened this issue Apr 30, 2020 · 3 comments
Closed

[WebProfilerBundle] New CSP directives broken with default-src #36641

Khartir opened this issue Apr 30, 2020 · 3 comments

Comments

@Khartir
Copy link

Khartir commented Apr 30, 2020

WebProfilerBundle version(s) affected: 5.0.8 definitly, I assume 4.4.8 and 3.4.40 are affected as well.

Description
#36315 added support for style-src-elem and script-src-elem. However they are set to both unsafe-inline and nonce-. This is not allowed in Chrome: Refused to apply inline style because it violates the following Content Security Policy directive: "style-src-elem * 'unsafe-inline' 'nonce-597c34dd0a6b70c13de427990c2cfe3f'". Note that 'unsafe-inline' is ignored if either a hash or nonce value is present in the source list.

How to reproduce
Setup a new Smyfony 5 project, add nelmio/security-bundle and configure it to use default-src: *.
Alternatively create a controller that adds a CSP header:
$response->headers->add(['Content-Security-Policy' => 'default-src *']);
Any value other than unsafe-inline for default-src causes the bug.
Note that the incorrect headers are always send, but the error is only triggered if there is an inline style. Rendering the debug-bar will therefore cause the error.

@isofianos-thelist-app
Copy link

isofianos-thelist-app commented May 1, 2020

I am running a project in Symfony 3.4.40 using nelmio/security-bundle.
I also confirm that in Firefox show a warning about style-src-elem and script-src-elem but it works properly, when in Chrome it is not working at all.

Disabling CSP, setting default-src as * or unsafe-inline resolve the issue.
Also if running in production mode the issue is not happening.

@nicolas-grekas
Copy link
Member

Anyone up for a PR to fix this issue?

@nicolas-grekas
Copy link
Member

Actually, I'm closing in favor of #36643 and #36645
Please send a patch to fix these issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants