CSP
#45
Replies: 1 comment 1 reply
-
I didn't know, that inlined styles are forbidden by CSP. Therefore it's probably mandatory to add Can you please point out what is insecure about this approach? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello out there! :)
While trying to implement django-formset with CSP headers enabled (I used django-csp), django-formset CSS does not load correctly due to CSP rejections. The only way I seem to be able to make this to work is to enable unsafe-inline's, which isn't a good thing.
Error from JS Console:
django-formset.js:25 Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self' 'nonce-WkX35IJFaVtppxeyuhA45g=='". Either the 'unsafe-inline' keyword, a hash ('sha256-vpHft275yvNumbvZFlPdo4goDdB7Nnyeok2p1H6UBLk='), or a nonce ('nonce-...') is required to enable inline execution.
Checking line 25 of django-formset, I see it does indeed try to use inline styles within js, but there's no way down there that I can see to pass the nonce to authorise it to do so?
I can include a nonce, which allows the first js to load, but this then imports more inline styles. Any inline styles need to include a nonce.
Config to django-csp make work (but insecure):
How do I make django-formset play nice with CSP enabled? :)
Many thanks!
Beta Was this translation helpful? Give feedback.
All reactions