Introduce image and CSS CSP controls#6071
Open
Zhey-on wants to merge 1 commit intoBookStackApp:developmentfrom
Open
Introduce image and CSS CSP controls#6071Zhey-on wants to merge 1 commit intoBookStackApp:developmentfrom
Zhey-on wants to merge 1 commit intoBookStackApp:developmentfrom
Conversation
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
This PR introduces CSP controls for image and CSS sources.
In line with the issue intent, the defaults are kept relatively permissive to prevent breaking changes on existing instances, while still providing clear options to tighten policies where needed.
Changes
img-srcandstyle-srcdirectives to CSP handling.ALLOWED_IMAGE_SOURCESALLOWED_CSS_SOURCESSecurityHeaderTestfor:.env.example.completeentries and examplesWhy this approach
The implementation is intentionally conservative by default, especially compared to JS/iframe controls, so instances do not unexpectedly break after upgrade. At the same time, admins can now explicitly restrict allowed sources as part of their hardening process.
Testing
docker compose run --rm app php artisan test tests/SecurityHeaderTest.php --filter="style src|img src|csp"Closes #6033.