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

CSP from pentests #4123

Merged
merged 63 commits into from
Feb 27, 2024
Merged

CSP from pentests #4123

merged 63 commits into from
Feb 27, 2024

Conversation

himadrisingh
Copy link
Contributor

No description provided.

@himadrisingh himadrisingh self-assigned this Feb 21, 2024
@himadrisingh himadrisingh marked this pull request as draft February 21, 2024 12:34
@github-actions github-actions bot temporarily deployed to production February 21, 2024 12:38 Inactive
@github-actions github-actions bot temporarily deployed to production February 21, 2024 12:42 Inactive
@github-actions github-actions bot temporarily deployed to production February 21, 2024 12:47 Inactive
@github-actions github-actions bot temporarily deployed to production February 21, 2024 12:53 Inactive
@github-actions github-actions bot temporarily deployed to production February 21, 2024 13:00 Inactive
@github-actions github-actions bot temporarily deployed to production February 21, 2024 13:04 Inactive
@github-actions github-actions bot temporarily deployed to production February 21, 2024 13:09 Inactive
@github-actions github-actions bot temporarily deployed to production February 21, 2024 13:19 Inactive
netlify.toml Outdated
[[headers]]
for = "/*"
[headers.values]
Content-Security-Policy = "default-src https:; script-src https: 'unsafe-inline'; style-src https: 'unsafe-inline'; img-src https: data: blob:; frame-ancestors *"
Content-Security-Policy = "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src https:; img-src https: data: blob:; frame-ancestors *; object-src 'none'; connect-src https:; require-trusted-types-for 'script'"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the SvelteKit docs:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is thr a way to generate nonce for the script-src, style 'unsafe-inline' can work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we're building a static site, we should use hashes not nonces. Leaving the blog post I shared with you here for us to come back to later: https://dev.to/askrodney/sveltekit-content-security-policy-csp-for-xss-protection-589k

@github-actions github-actions bot temporarily deployed to production February 22, 2024 10:05 Inactive
@himadrisingh himadrisingh changed the base branch from main to yaml-metrics-editor February 26, 2024 17:43
@github-actions github-actions bot temporarily deployed to production February 26, 2024 17:43 Inactive
@himadrisingh himadrisingh changed the base branch from yaml-metrics-editor to main February 26, 2024 17:43
@github-actions github-actions bot temporarily deployed to production February 26, 2024 17:49 Inactive
Copy link
Contributor

@Kavinjsir Kavinjsir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!
Perhaps in the future we might try adjusting unsafe-inline if necessary.

Copy link
Contributor

@ericpgreen2 ericpgreen2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a couple questions but looks good!

Cross-Origin-Embedder-Policy = "credentialless"
Cross-Origin-Opener-Policy = "unsafe-none"
Cross-Origin-Resource-Policy = "cross-origin"
X-Frame-Options = "allow-from *"
Copy link
Contributor

@ericpgreen2 ericpgreen2 Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this X-Frame-Options? This ChatGPT convo implies allow-from doesn't support wildcards and the Mozilla docs say the allow-from directive is deprecated.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -2,7 +2,11 @@
[[headers]]
for = "/*"
[headers.values]
Content-Security-Policy = "default-src https:; script-src https: 'unsafe-inline'; style-src https: 'unsafe-inline'; img-src https: data: blob:; frame-ancestors *"
Content-Security-Policy = "default-src 'self'; script-src 'self' https: 'unsafe-inline'; style-src https: 'unsafe-inline'; img-src https: data: blob:; frame-src data:; frame-ancestors *; object-src 'none'; connect-src https:;"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of frame-src data:;? What iframe is that meant to accommodate? ChatGPT called it out as being uncommon:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was getting Refused to frame '' because it violates the following Content Security Policy directive
https://serverfault.com/questions/945834/refused-to-frame-because-it-violates-the-following-content-security-policy-di suggested data: and it worked!

@himadrisingh himadrisingh merged commit d2bb6db into main Feb 27, 2024
1 check passed
@himadrisingh himadrisingh deleted the csp branch February 27, 2024 02:48
himadrisingh added a commit that referenced this pull request Mar 1, 2024
* CSP from pentests
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.

3 participants