Built-in error pages don't carry the request's CSP nonce, so a strict policy blocks their styles and script
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 45/100
Research direction
Start with crates/http/src/errors/page.rs and crates/http/src/errors/renderer/page.html, where the built-in pages are rendered. Check how view::use_csp_nonce exposes the request nonce and how vite() applies it; done when both error pages include the nonce on inline style and script tags when set, and remain unchanged without one. The issue author says a PR is ready.
Written by the indexing model from the issue text.
Description
The problem
view::use_csp_nonce gives every tag that vite() and vite_react_refresh() render the request's nonce (#374), and the templates guide shows a middleware that sends script-src 'nonce-…' 'strict-dynamic'; style-src 'nonce-…'. The built-in error pages don't use that nonce:
- The debug page inlines two
<style>tags and one<script>tag with nononceattribute (crates/http/src/errors/renderer/page.htmlL7–L8, L58, filled in bypage::debug). - The plain status page (
404,419,500outside debug mode) inlines one<style>tag the same way (page::simple).
So with the policy from the guide, any error that reaches the built-in pages renders as unstyled HTML, and the debug page's highlighting script is blocked. The application can't fix it from outside: the page is rendered by the framework, and the only way around it is to drop the policy for error responses.
To reproduce, add the middleware from the templates guide ("Content Security Policy nonces") to a new app with APP_DEBUG=true, and return Err(laravel::Error::msg("boom")) from a handler. The browser blocks the page's three inline tags, so it shows unstyled markup and no highlighting.
Proposal
Render the request's nonce on the inline <style> and <script> tags of both built-in pages when one is set, the same way vite() does, and leave the pages unchanged when no nonce is set. Error responses already pass back through the middleware that set the nonce and adds the header, so the nonce and the policy match.
Laravel Classic's renderer inlines its CSS and JS without a nonce too (Renderer::css() and Renderer::js()), but here the nonce is already request-scoped and available where the page is rendered, so the fix is small.
Use case
An operations dashboard or any app that ships a strict CSP in every environment, so that a policy violation shows up during development rather than in production. Today such an app has to exempt error responses from its policy, or accept unreadable error pages while developing.
I have a PR ready for this.
- Dominant language
- Rust
- Stars
- 847
- Forks
- 174
- Avg merge
- 5h 40m
- Merged PRs (30d)
- 167
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from laravel/rust-framework
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
laravel/rust-framework#864 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
laravel/rust-framework#876 ·
Maintainers usually reply within 1 day
-
Case-sensitive contains, starts_with and ends_with that match % and _ literally on every databaseOpen
Difficulty 4/5 3-5 days Newbie friendliness 58/100
laravel/rust-framework#874 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
laravel/rust-framework#873 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 58/100
laravel/rust-framework#872 ·
Maintainers usually reply within 1 day
All issues in laravel/rust-framework
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
neuralmagic/crucible#579 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
eclipse-score/kyron#249 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
seanmonstar/reqwest#3157 ·
Maintainers usually reply within 2 days