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

Inline script verification using nonce attribute #106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stani-m
Copy link

@stani-m stani-m commented Nov 13, 2024

This pull request enables inline html scripts generated by this library to be loaded when Content Security Policy is enabled by allowing user to specify a nonce attribute through the RecaptchaSettings class.

Inline html scripts are not loaded when content security policy is enabled unless they have a nonce attribute containing a unique identifier included in the CPS header or you calculate their hash beforehand and include it in the CPS header or enable inline scripts by adding 'unsafe-inline' value to the CPS header.

Hashing is not very practical when the inline scripts contain a unique ID like they do in this case and using 'unsafe-inline' turns off much of CPS defeating its purpose.

The RecaptchaSettings class currently contains a ContentSecurityPolicy property that might have been intended for solving this issue but at the moment it just adds script-src and frame-src attributes to script tags that do not contain inline javascript but are loaded through src attribute which I believe does nothing because the script tag does not even have script-src or frame-src attributes and non-inline scripts can be loaded with CSP enabled by adding the url they are loaded from to the CSP header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant