-
Notifications
You must be signed in to change notification settings - Fork 252
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
Filtering CSP entries to prevent bypassing rules #418
Comments
Thanks for the report @mvgijssel. This is something @gregose had brought up a loooong time ago wrt to policy "injection" via semicolons. I think the better approach would be to escape or raise errors upon seeing a semicolon mid-directive. I believe it would be better to raise an error but that could be breaking change, requiring a deprecation and major version bump. It's easy to say "don't do that" but what you appear to be doing is absolutely supported. Accepting user input into a policy seems to bypass the whole point of CSP, but sometimes a single non-perfect opt-out can help make the other 99% of the application safer until things can be rearchitected. I should have fixed this a looooooong time ago, tech debt! |
This might be worth a security advisory as well. |
In the end your call, but it's surprising to me to be able to set a different CSP directive when you are explicitly stating |
I 💯 agree that this behavior should be fixed. There's no legitimate reason that I can think of. |
I'm just waiting on the backport to finish building. I'll push the fixed versions for 3.x, 5.x, and 6.x and issue an advisory after. |
Thanks for jumping on this fix so fast @oreoshake! 🎊 |
I published two advisories today. One for this, and one for newline injections https://github.com/twitter/secure_headers/security/advisories |
Thanks @oreoshake! |
Consider the following Rails controller action which overwrites the frame ancestors based on some user input:
This results into the following response header:
This shows unexpected output, because by setting the frame ancestors the user is able to change the
script-src
opening possibilities for XSS.One solution to this would be to filter out the CSP rules inside of specific CSP rules:
The text was updated successfully, but these errors were encountered: