fix(security): replace CSP unsafe-inline with sha256 script hashes#824
Open
NewCoder3294 wants to merge 1 commit intokoala73:mainfrom
Open
fix(security): replace CSP unsafe-inline with sha256 script hashes#824NewCoder3294 wants to merge 1 commit intokoala73:mainfrom
NewCoder3294 wants to merge 1 commit intokoala73:mainfrom
Conversation
The Content-Security-Policy header in vercel.json used 'unsafe-inline' for script-src, which weakens the security policy by allowing any inline script to execute. Replace it with explicit SHA256 hashes of the known inline scripts, matching the hashes already present in the index.html meta CSP tag. Hashed inline scripts: - Theme/variant init script (FOUC prevention): sha256-LnMFPWZxTgVOr2VYwIh9mhQ3l/l3+a3SfNOLERnuHfY= - Vite module preload polyfill: sha256-+SFBjfmi2XfnyAT3POBxf6JIKYDcNXtllPclOcaNBI0= - Vite build injected scripts: sha256-AhZAmdCW6h8iXMyBcvIrqN71FGNk4lwLD+lPxx43hxg=, sha256-PnEBZii+iFaNE2EyXaJhRq34g6bdjRJxpLfJALdXYt8= Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@NewCoder3294 is attempting to deploy a commit to the Elie Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
'unsafe-inline'in thescript-srcdirective of the Content-Security-Policy header invercel.jsonwith explicit SHA256 hashes of all known inline scriptsindex.html<meta>CSP tag, ensuring consistency between the HTTP header and meta tag policiesInline scripts hashed
sha256-LnMFPWZxTgVOr2VYwIh9mhQ3l/l3+a3SfNOLERnuHfY=sha256-+SFBjfmi2XfnyAT3POBxf6JIKYDcNXtllPclOcaNBI0=sha256-AhZAmdCW6h8iXMyBcvIrqN71FGNk4lwLD+lPxx43hxg=sha256-PnEBZii+iFaNE2EyXaJhRq34g6bdjRJxpLfJALdXYt8=Security benefit
'unsafe-inline'inscript-srceffectively disables one of the most important CSP protections — it allows any inline<script>tag to execute, which is the primary vector for XSS attacks. By replacing it with sha256 hashes, only the exact known inline scripts are permitted. Any injected malicious script will be blocked by the browser.Test plan
npx tsx --test tests/deploy-config.test.mjs— all 13 tests pass, including the specific test "CSP script-src uses hashes instead of unsafe-inline" (line 143-147)🤖 Generated with Claude Code