[fix] Serve a Content Security Policy on portal responses#410
Open
St4NNi wants to merge 7 commits into
Open
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.
Closes #363
The portal was served without a Content Security Policy or related security headers.
Portal routes now carry a policy derived from what the portal actually loads, verified against the real portal build rather than copied from a template:
plus
X-Content-Type-Options,Referrer-PolicyandCross-Origin-Opener-Policy.'wasm-unsafe-eval'is required and is the only unsafe directive: the profile publisher hashes artifacts with a WebAssembly hashing library. It permits no JavaScript eval. There is nounsafe-inlineand nounsafe-eval.The connect origins are resolved per request from realm state rather than from environment variables, because a joined node serves the portal without any OIDC environment configuration. Extra origins, such as another node's S3 endpoint, come from
PORTAL_CSP_EXTRA_ORIGINS.The headers are scoped to the portal router. API routes stay free of an HTML oriented policy, and the ops probe endpoints are excluded because they serve metrics to scrapers rather than documents to a browser.