Repository navigation
feat(nginx): add a Content-Security-Policy to the editor documents - #16
Merged
Merged
Conversation
Harden the editor index.html responses with a script-focused CSP. The editor needs 'unsafe-eval' (eval/Function, WebAssembly) and blob: (Blob-URL Workers), so those stay; restricting script-src to 'self' is defense in depth so the editor context cannot load or dynamically import a script from another origin. A Blob-URL Worker inherits its document's policy, so Workers started from these pages are covered too. Scoped to every editor entry point under web-apps/apps: the main, mobile, embed and forms apps, and the index / index_loader / index_internal / index.reporter variants that getAppPath() can load. The redirector (common/index.html) and the api/documents helper pages are left out, as are all subresource responses. Minimal script/worker policy, not a full editor CSP: img-src, style-src, font-src, connect-src, frame-ancestors and the rest are intentionally left unset. nginx add_header does not merge across levels, so the Cache-Control from the block below is repeated here on purpose. Assisted-by: ClaudeCode:claude-opus-4-8 Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
chrip
marked this pull request as ready for review
October 9, 2026 09:52
juliusknorr
self-requested a review
October 21, 2026 09:37
juliusknorr
reviewed
Oct 21, 2026
Comment on lines
+39
to
+50
| # Harden the editor documents with a script-focused Content-Security-Policy. | ||
| # The editor compiles code at runtime (eval/Function, WebAssembly) and starts | ||
| # Blob-URL Workers, so 'unsafe-eval' and blob: have to stay. Pinning script-src | ||
| # to 'self' means the editor context can neither load nor dynamically import a | ||
| # script from another origin, and a Blob-URL Worker inherits this document's | ||
| # policy, so that restriction reaches those Workers too. This is a deliberately | ||
| # minimal script/worker policy; the other directives (img-src, style-src, | ||
| # font-src, connect-src, frame-ancestors, ...) are intentionally left unset. | ||
| # Covers every editor entry point: main, mobile, embed and forms, and the | ||
| # index/index_loader/index_internal/index.reporter variants getAppPath() loads. | ||
| # nginx add_header does not merge across levels, so the Cache-Control from the | ||
| # block below is repeated here on purpose. |
Member
There was a problem hiding this comment.
Not a blocker, but I find this rather extensive for a config that admins may browse. Could be more compact and the full one may go into the commit message?
Contributor
Author
There was a problem hiding this comment.
I summarized the comment to two lines.
juliusknorr
approved these changes
Oct 21, 2026
Keep only what an admin reading the config needs: why 'unsafe-eval' and blob: are in the policy and why Cache-Control is repeated. The full rationale stays in the commit that added the block. Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
chrip
force-pushed
the
feat/editor-document-csp
branch
from
October 22, 2026 07:41
466cf32 to
32396d0
Compare
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.
Harden the editor index.html responses with a script-focused CSP. The editor needs 'unsafe-eval' (eval/Function, WebAssembly) and blob: (Blob-URL Workers), so those stay; restricting script-src to 'self' is defense in depth so the editor context cannot load or dynamically import a script from another origin. A Blob-URL Worker inherits its document's policy, so Workers started from these pages are covered too.
Scoped to every editor entry point under web-apps/apps: the main, mobile, embed and forms apps, and the index / index_loader / index_internal / index.reporter variants that getAppPath() can load. The redirector (common/index.html) and the api/documents helper pages are left out, as are all subresource responses.
Minimal script/worker policy, not a full editor CSP: img-src, style-src, font-src, connect-src, frame-ancestors and the rest are intentionally left unset. nginx add_header does not merge across levels, so the Cache-Control from the block below is repeated here on purpose.
Assisted-by: ClaudeCode:claude-opus-4-8