-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[WebProfilerBundle] Content-Security-Policy directives "style-src" and "script-src" are misused #22053
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
Comments
The behavior is expected, as you mentioned, and as mentioned here https://csp.withgoogle.com/docs/strict-csp.html
Could you point me where you encounter an issue? Which panel? |
STR:
Actual result: error message from OP. Also, I confirm #20963 isue: hash value in |
Also, a few words about this citate:
A day ago, I experimenting with CSP headers and add
We compared our browsers version, and they are equal (major, minor, build part). But difference is in OS: on Ubuntu I dont see any notices, but QA used Windows 7 and notice is present here. So, I mean, that some undocumented behaviour can also occure in my case with |
Hello, You said that the error that occurs in your console is
Actually, you can not use inline style if your CSP is set to Please try to disable the Symfony web profiler toolbar
and let me know if you got the exact same issue. I'd be glad if you could create a symfony app base on the standard edition that reproduce your issue so I can have a look, see if there's a bug. At the moment, everything looks normal to me. |
Yep, but in
Error is not occured when I disable web profiler toolbar.
Ok, I'll do it tonight. |
If you have a CSP mentioning Where does come from the inline style? Your code? Symfony code? A vendor code? |
When I remove
Mouse click on
but I cant find any |
Waiting for a repository to reproduce the issue |
STR on fresh install of Symfony:
Open http://localhost:8000 - consider that all works good. After change CSP header in The same results can be achieved by adding headers directly to the controller response instead listener usage, but I want to reproduce my current set-up as closer as possible. |
Reproduced, thanks for the report |
I just submitted a patch that fixes your issue. Thanks again for reporting. |
You're welcome :) And thanks for a quick fix. |
…ity in case of a `style-src 'self'` policy (romainneutron) This PR was merged into the 3.2 branch. Discussion ---------- [WebProfilerBundle] Fix Content-Security-Policy compatibility in case of a `style-src 'self'` policy | Q | A | ------------- | --- | Branch? | 3.2 <!-- see comment below --> | Bug fix? | yes | New feature? | no <!-- don't forget updating src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget updating UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | #22053 #20963 | License | MIT This fixes the compatibility of the bundle in case of a `style-src 'self'` policy. This PR must be rebased once #22089 is merged Commits ------- 4acec89 [WebProfilerBundle] Fix content-security-policy compatibility
Uh oh!
There was an error while loading. Please reload this page.
Related to #18568, #20963.
Consider next code in "WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php":
If one of my CSP directives looks like
style-src 'self' 'unsafe-inline';
thannonce-<hash>
is not added. But when I remove the'unsafe-inline'
part, directive transforms tostyle-src 'self' 'unsafe-inline' 'nonce-%hash%';
and this cause CSP violation (Chrome 57.0.2987.110 (64-bit)):Consider last sentence: browser says that
'unsafe-inline'
and'nonce-<hash>'
is incompatible. I looked in the docs: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#Unsafe_inline_script and found next notice:So, it is only allowed to use
'unsafe-inline'
or both nonce and hash, but not all together. The same is applied to'script-src'
.ping @romainneutron
The text was updated successfully, but these errors were encountered: