feat(core): nonce-based CSP for all HTML responses#1
Open
all3f0r1 wants to merge 2 commits into
Open
Conversation
Generate a cryptographic nonce per request in the runtime init middleware and use it for script-src/style-src on all HTML responses (admin + public). Post-process final HTML to inject nonce attributes into any <script>/<style> tags that don't already have one. In dev mode, 'unsafe-inline' is kept alongside the nonce for Vite HMR compatibility. In production, strict nonce-only. Removes the old admin-only CSP from auth middleware in favor of centralized handling in finalizeResponse. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
PR template validation failedPlease fix the following issues by editing your PR description:
See CONTRIBUTING.md for the full contribution policy. |
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
The field editor modal was closing immediately after clicking save, before the mutation completed. This caused the UI to not refresh and show no feedback that the save succeeded. The data was saved to the DB, but the user couldn't see the result. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
This PR has been inactive for 14 days. It will be closed automatically in 7 days if there is no further activity. If you're still working on this, please push an update or leave a comment. |
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 CSP with per-request cryptographic nonces on all HTML responses (admin + public)locals.cspNonce+EmDashRequestContext.nonce(ALS)nonce=attributes into all<script>/<style>tags (idempotent regex, skips tags already having a nonce)Content-Security-Policyheader centrally infinalizeResponsefor HTML responses'unsafe-inline'alongside the nonce for Vite HMR compatibilityauth.tsmiddlewareTest plan
<script>and<style>tags in rendered HTML havenonce=attributespnpm testpnpm typecheck🤖 Generated with Claude Code