You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: React 18 renderToPipeableStream missing support for nonce for bootstrapScripts and bootstrapModules #24883
Use server with CSP script-src set to strict-dynamic and with nonce.
Use renderToPipeableStream and add nonce to its options. Pass js client assets through bootstrapScripts.
Launch development server and try to load app.
The current behavior
The renderToPipeableStream nonce is only applied to inline scripts (bootstrapScriptContent) in createResponseState().
The expected behavior
A strict-dynamic script-src CSP applies to both inline scripts and scripts with src. I would expect the nonce to also be applied to scripts with src. The change seems simple enough .The createResponseState() would look like this:
changed the title [-]Bug: React 18 missing support for nonce for bootstrapScripts[/-][+]Bug: React 18 missing support for nonce for bootstrapScripts and bootstrapModules[/+]on Jul 9, 2022
changed the title [-]Bug: React 18 missing support for nonce for bootstrapScripts and bootstrapModules[/-][+]Bug: React 18 renderToPipeableStream missing support for nonce for bootstrapScripts and bootstrapModules[/+]on Jul 9, 2022
To add some context on why this is needed, when you add the strict-dynamic source list keyword, all other non-nonce keywords and sources are ignored, specifically 'self'. This means that scripts that are inserted via <script src=... /> violate the content security policy.
Right now renderToReadableStream and renderToPipeableStream add the nonce attribute to inline scripts set in bootstrapScriptContent, but not src=... scripts via bootstrapScripts and bootstrapModules.
Adding nonce support to those scripts will allow them to pass a content-security-policy that uses strict-dynamic.
Activity
[-]Bug: React 18 missing support for nonce for bootstrapScripts[/-][+]Bug: React 18 missing support for nonce for bootstrapScripts and bootstrapModules[/+][-]Bug: React 18 missing support for nonce for bootstrapScripts and bootstrapModules[/-][+]Bug: React 18 renderToPipeableStream missing support for nonce for bootstrapScripts and bootstrapModules[/+]danieltott commentedon Apr 27, 2023
This is also missing in
renderToReadableStreamdanieltott commentedon Apr 27, 2023
To add some context on why this is needed, when you add the
strict-dynamicsource list keyword, all other non-nonce keywords and sources are ignored, specifically'self'. This means that scripts that are inserted via<script src=... />violate the content security policy.Right now
renderToReadableStreamandrenderToPipeableStreamadd the nonce attribute to inline scripts set inbootstrapScriptContent, but notsrc=...scripts viabootstrapScriptsandbootstrapModules.Adding nonce support to those scripts will allow them to pass a
content-security-policythat usesstrict-dynamic.danieltott commentedon Apr 28, 2023
PR with fix: #26738