Repository navigation
fix(media): apply CSP to all static asset responses - #49
Closed
Jonas Elfering (keulinho) wants to merge 3 commits into
Closed
Jonas Elfering (keulinho) wants to merge 3 commits into
Jonas Elfering (keulinho) wants to merge 3 commits into
Conversation
3 of 4 tasks
This was referenced Oct 15, 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.
1. Why is this change necessary?
Static asset responses need a Content Security Policy even when served from the reverse-proxy cache. Protecting only particular extensions can leave other active documents in the asset directories without the intended policy.
2. What does this change do, exactly?
Set
Content-Security-Policy: script-src 'none'; object-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'invcl_deliverfor every response under/media/and/thumbnail/in both the 6.7 and 6.8 configurations, without extension or MIME-type filtering. The policy replaces any origin CSP on these responses and applies to cache hits, misses and errors. Responses outside these paths retain their existing policy and caching behavior.Theme and bundle responses retain their origin policy, including bundled HTML applications. Document the media and thumbnail scope in the README.
3. Describe each step to reproduce the issue or behaviour.
/media/and/thumbnail/./admin,/application/rendered.html,/media-other/test.html, a theme asset and a bundled HTML application. Their origin CSP must remain unchanged.Verified both complete VCL configurations with temporary
varnishtestchecks: 12 HTTP requests per version, with an asserted cache hit, query strings, error responses, media-policy replacement and origin-policy preservation for theme, bundle and application responses. These local checks use a fixture origin rather than a full Shopware installation; no test harness is included in this PR. Whitespace checks pass.4. Please link to the relevant issues (if any).
5. Checklist