Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd test to exercise override opting out without default_src #444
Conversation
On secure_headers 5.x it was possible to override the CSP directives when optin out without having to define a default_src. Now on 6.x it is required to set the default_src when overriding other directives. It is not clear in the CHANGELOG/upgrade guide if this change is by design or if it is just a side effect of other changes. I could not find anyting in the spec that says that default_src is required or not, so I decided to open a PR with a test to get feedback on that. If this is undesirable behavior I'm willing to change this PR to fix the problem. Let me know what are the next steps. Thanks.
It appears to have been fixed as a side effect of other changes, not exactly sure when. |
That makes sense. So maybe |
I think that behavior would be a little surprising. Declaring This feels a bit edge casey so I'm trying to keep an open mind. It seems in the example provided, the "fix" to get the desired policy isn't too burdensome to add and would be obvious/self-documenting. I'd be curious to see what others think. |
I think the problem with asking the override the define This requires your code to have to check if In other words, my method call in the app needs now to be something like: if SecureHeaders.config_for(request).csp['default_src']
SecureHeaders.override_content_security_policy_directives(request, { frame_ancestors: %w('none') }, :enforced)
else
SecureHeaders.override_content_security_policy_directives(request, { frame_ancestors: %w('none'), default_src: %w('self' https:), script_src: %w(https:) }, :enforced)
end |
Interesting! I see your point. Can you describe your use a little more? Or does this about sum it up:
That's an interesting strategy and but I will not say it's wrong. That being said, I still don't think adding the surprise default CSP that can change over time is the right answer. I'll have to think on it some more but I'm not seeing an obvious path forward. Did you have anything in mind? |
rafaelfranca commentedAug 19, 2020
On secure_headers 5.x it was possible to override the CSP directives when optin out without having to define a default_src.
Now on 6.x it is required to set the default_src when overriding other directives.
It is not clear in the CHANGELOG/upgrade guide if this change is by design or if it is just a side effect of other changes.
I could not find anything in the spec that says that default_src is required or not, so I decided to open a PR with a test to get feedback on that.
If this is undesirable behavior I'm willing to change this PR to fix the problem.
Let me know what are the next steps.
Thanks.