docs: explain the CSP nonce model across client-router soft navigations#1055
Merged
Conversation
Add a 'CSP and the client router' subsection to the security docs page and a paragraph to the built-ins reference: enforcement is the HTTP header (not a meta http-equiv tag), the meta name=csp-nonce is a client-side carrier, and on a soft navigation the original page-load nonce stays authoritative and is re-stamped onto every dynamically-inserted script/preload (#1049/#1052). Gives users setting up strict CSP the why behind the model.
Review: 'the ORIGINAL nonce stays authoritative for the whole session' overstated. It holds for the life of the current document. A hard reload or full page load creates a new document with the response's own fresh nonce. Reword and add the harmless-full-load case so soft-nav vs hard-reload is clear (the built-ins reference already stated this conservatively).
vivek7405
commented
Jul 22, 2026
vivek7405
left a comment
Collaborator
Author
There was a problem hiding this comment.
Checked the prose against the code, all the mechanism claims hold. One overstatement: it said the original nonce stays authoritative for the whole session, which reads as if it survives a reload. It only holds for the life of the current document. Fixed, and added the harmless full-load case so the soft-nav vs hard-reload line is explicit.
vivek7405
commented
Jul 22, 2026
vivek7405
left a comment
Collaborator
Author
There was a problem hiding this comment.
Re-read the soft-nav paragraph after the rewording. The document-scoped claim is accurate, the full-load case is spelled out, and it is consistent with the built-ins reference. Good to go.
vivek7405
marked this pull request as ready for review
July 22, 2026 19:50
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.
Closes #1054
Documents the one genuinely subtle, security-relevant part of the CSP story that the docs skipped: how the nonce behaves across a client-router soft navigation.
What's added
docs/app/docs/security/page.ts: a "CSP and the client router" subsection under the existing CSP section, covering (a) enforcement is the HTTPContent-Security-Policyheader, not a<meta http-equiv>tag (soframe-ancestors/report-uriwork), and the<meta name="csp-nonce">is only a client-side carrier; (b) on a soft nav the original page-load nonce stays authoritative and the router re-stamps every dynamically-inserted script/preload with it viagetCspNonce()(fix: view-transition soft-nav meta leak and stuck Suspense skeleton #1049/fix: preserve csp-nonce on mergeHead, warn on dropped streamed resolve #1052); (c) no user config needed, and CSP pages are cache-excluded so a nonce is never replayed stale..agents/skills/webjs/references/built-ins.md: a matching paragraph in the CSP section.Grew out of an analysis of whether the meta csp-nonce approach needed changes. It does not, the code was already correct, only the docs were silent.
Definition of done
/docs/securityserves 200 with the new subsection present.csp.jsbuildCspHeader; the carrier meta is emitted inssr.js; the client re-stamps viagetCspNonce()/cloneScriptWithCorrectNonce/reactivateScripts; cache-excluded inhtml-cache.js).