-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add nonces for inline scripts to CSP #2
Comments
We need to create Real Nonces™️, as the spec notes you're not allowed to reuse them; we can't use |
Ah ok, this was more of a quick & dirty approach. They did the job locally at least. |
Wait what does it mean by not reusing them? They're gonna be the same for some length of time. Or is WP's implementation liable to throw back a previously generated one in future? |
WP's nonces rotate every 12 hours, so they don't meet that criteria. |
From the spec:
|
Bleeeurgh. Ok, seems Chrome didn't actually enforce that, I refreshed a bunch of times with the same value. So if we're to use nonces which are the easiest to implement for inline and external scripts then we'd have to go with a Lambda@Edge function. Can't really see a way around it in a CloudFront world. |
I don't think it necessarily has to be unique per request, but rather if the page's content changes, the nonce should change too. I think if it's cached and the same exact page, it's fine to send the same. i.e. I think your approach here is fine, just need to use real nonces instead. |
Hi there, But when I reload the Page the nonce attribute is empty. |
Could this approach be used with hash-based CSP - using the hashes generated for the scripts |
That might be easier yeah. Could actually filter on |
This code works well so far but would be good to figure out some configurability. Also needs a lot of cross browser testing.
The text was updated successfully, but these errors were encountered: