[8.4-stable] feat(csp): send a Content Security Policy with admin responses - #4238
Merged
Conversation
Alchemy now sends a Content Security Policy with its own admin responses, so a mistake that renders content unescaped stays a display bug instead of becoming script execution in an editor's session. It is on by default, for new installations and for upgrading applications alike, because the admin surface Alchemy ships works under it entirely. The option is documented in the configuration template, so it reaches existing applications through alchemy:upgrade:config, and the upgrader raises a todo pointing at it for the rare application that does have inline scripts in admin views of its own. The policy is built by a configurable class. Alchemy fills in the host dependent sources from what it already knows: the asset host, the preview hosts the page editor loads into an iframe, admin stylesheets served from another host, and modules pinned to a CDN. Anything beyond that is a subclass away. It only applies to Alchemy's own controllers, never to host application controllers inheriting from the admin base class, and it is skipped entirely when the host has configured a policy of its own. The csp-nonce meta tag is added unconditionally because Turbo reads the nonce from it to authorize the style element it injects for the progress bar. It renders nothing when no policy is configured. (cherry picked from commit f0c2ff9)
3 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 8.4-stable #4238 +/- ##
==============================================
+ Coverage 98.36% 98.37% +0.01%
==============================================
Files 360 361 +1
Lines 9580 9644 +64
==============================================
+ Hits 9423 9487 +64
Misses 157 157
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
tvdeyen
approved these changes
Sep 8, 2026
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.
Backport
This will backport the following commits from
mainto8.4-stable:Questions ?
Please refer to the Backport tool documentation