-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Allow Gatsby to run with a CSP without unsafe-inline. #3758
Comments
There are some related issues which go in the 2. direction:
Ideally the CSP should be opt-out, the 2. way does not require http/2 to be efficient. |
Would it be terribly difficult to make option 1 work? From my (very limited) perspective it would seem the easier route, at the expense of a few requests more. |
Due to the high volume of issues, we're closing out older ones without recent activity. Please open a new issue if you need help! |
The only problem with option 2 is it will not work with other deployments. In my opinion there should be an option for having zero inlined scripts/code. Option 2 is favorable however if you do have a supported host. |
In order to use Gatsby with a CSP, the inline CSS and JavaScript it produces requires it to be run with
unsafe-inline
, which renders it vulnerable to a broad swath of attacks and generally makes the CSP worthless.There are two ways to permit this:
strict-dynamic
and hashes of the content of each generated file or inline resource. This provides slightly better security, but is also more complex and rigid. Ideally in this case, the generated CSP is inserted as a<meta>
tag and the same CSP is inserted intogatsby-plugin-netlify
's generated_headers
file.I'd favor #1 as opt-in behavior for its flexibility. It would require more requests, but H/2's multiplexing reduces the penalty for that.
The text was updated successfully, but these errors were encountered: