-
Notifications
You must be signed in to change notification settings - Fork 102
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
Don't include nonces in default-src when CSP_INCLUDE_NONCE_IN is unset / an empty list #191
Comments
This comment was marked as spam.
This comment was marked as spam.
I agree this is a bug. If the One fix may be to explicitly set this to an empty list in your settings.
Note: This is fixed in my PR 219. I will leave this open until that officially gets merged. |
robhudson
added a commit
to robhudson/django-csp
that referenced
this issue
Jun 6, 2024
This is a backwards incompatible change. Also fixes mozilla#139, mozilla#191
robhudson
added a commit
to robhudson/django-csp
that referenced
this issue
Jun 6, 2024
This is a backwards incompatible change. Also fixes mozilla#139, mozilla#191
robhudson
added a commit
that referenced
this issue
Jun 6, 2024
Fixed in #219 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe adding nonces to the default-src is the intended behavior and not a bug. But it conflicts with a CSP policy like
default-src: 'none'
. That gets converted todefault-src: 'none' 'nonce-1234'
, and the 'none' value is ignored because another value is present.As an example, suppose a library wants to include nonces in a template, so that inline styles can use nonces if they're enabled:
If a user of this library wants to use nonces in their CSP, they can set
CSP_INCLUDE_NONCE_IN
to'style-src'
and the library's template will automatically have its inline styling allowed. The nonce will appear in both the template and the CSP header.If a user doesn't want to use nonces, they should be able to leave
CSP_INCLUDE_NONCE_IN
unset. The nonce could still appear in the template, or it could be set to an empty string. But no nonce values should appear in the CSP header.Currently the nonce ends up in the default-src directive anyway. This breaks the user's CSP if they're relying on 'none' or 'unsafe-inline'. See encode/django-rest-framework#7960 (comment) for a real-world example of a library template that should be able to use nonces lazily, but can't as a result of this bug.
The text was updated successfully, but these errors were encountered: