Skip to content
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 info on nonces and hashes to CSP test explanation #843

Closed
baknu opened this issue Jan 13, 2023 · 1 comment
Closed

Add info on nonces and hashes to CSP test explanation #843

baknu opened this issue Jan 13, 2023 · 1 comment
Assignees
Milestone

Comments

@baknu
Copy link
Contributor

baknu commented Jan 13, 2023

For orginal implementation details: #325

From a mail response to a question on 13th of January 2023:

Het staat wat onduidelijk in de “NOREA Handreiking ICT-beveiligingsassessment DigiD 3.0”. Ze bedoelen waarschijnlijk het volgende:
“Sta geen onveilige configuratie toe door het gebruik van 'unsafe-eval' of 'unsafe-inline' (in plaats van deze laatste kan gebruik worden gemaakt van een nonce of hash indien inline scripts of styles noodzakelijk zijn).”

Dit staat ook in de CSP-specificatie:
“In either case, developers SHOULD NOT include either 'unsafe-inline', […] When considering 'unsafe-inline', authors are encouraged to consider nonces (or hashes) instead.”

Bij de implementatie van de CSP-subtest in Internet.nl liepen de ontwikkelaars ook aan tegen de onduidelijkheid in het NOREA document en volgden de CSP-specificatie: #325 (comment)

Een en ander blijkt overigens ook uit “FAQ DigiD assessment, 1.4 d.d. 8 november 2021” waarin het volgende staat:
“De CSP directives 'unsafe-eval' en/of 'unsafe-inline' zijn onveilig. Met 'unsafe-eval' kan arbitraire code
worden uitgevoerd. Met 'unsafe-inline' kunnen scripts uitgevoerd worden die potentieel uit
onbetrouwbare bronnen komen. Beide directives zouden daarom niet gebruikt moeten worden.
Om toch gebruik te kunnen maken van inline scripts en stylesheets, moet de 'nonce' directive
gebruikt worden. Met een nonce kunnen specifieke inline script en stylesheet elementen
gewhitelist worden om te voorkomen dat inline scripts of stylesheets buiten eigen beheer
uitgevoerd kunnen worden. Gebruik een sterke random hash als nonce-waarde en zorg er voor dat
deze bij iedere request uniek is.”

Op MDN Web Docs (Mozilla) staat nog het volgende over nonces en hashes:
“Note: Only use nonce for cases where you have no way around using unsafe inline script or style contents.
If you don't need nonce, don't use it. If your script is static, you could also use a CSP hash instead. (See usage notes on unsafe inline script.)
Always try to take full advantage of CSP protections and avoid nonces or unsafe inline scripts whenever possible.”

@baknu baknu added the content label Jan 13, 2023
@baknu baknu added this to the v1.7 milestone Jan 13, 2023
@mxsasha mxsasha removed their assignment Jan 25, 2023
@baknu
Copy link
Contributor Author

baknu commented Mar 24, 2023

Done

@baknu baknu closed this as completed Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants