Skip to content

fix(web): apply the content security policy to every page path - #1002

Open
Medformatik wants to merge 1 commit into
fix/outbound-url-trustfrom
fix/csp-on-every-page
Open

Medformatik wants to merge 1 commit into
fix/outbound-url-trustfrom
fix/csp-on-every-page

Conversation

@Medformatik

@Medformatik Medformatik commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

The web app sets its Content-Security-Policy in the request proxy. The proxy's matcher skipped every path that ends in an image or font extension, and its prefix exclusions were not anchored, so a path that only starts with api or icons was skipped too. A page under such a path, for example a shared link whose token ends in .png or a not-found page for /x.png, was rendered without any policy.

The matcher now excludes only real static locations: _next/ and api/, the files favicon.ico and sw.js, and the icons/, fonts/, styles/ and attribution/ directories. Nothing is excluded by file extension any more, so a new page route is covered unless someone adds an exception on purpose. The stale manifest.json exclusion is gone; the manifest is served as /manifest.webmanifest and was already covered.

The proxy now also runs for the few image files at the root of public/. A policy header on an image response has no effect in the browser.

Related work

Seventh layer of the stack that starts with #983.

Verification

  • proxy.test.ts passes (24 tests). The 21 new cases check the exported matcher with Next's own matcher helper; run against the previous matcher, 8 of them fail.
  • pnpm -C apps/web check-types and Biome pass.
  • Not done: a production build, and a request against a running server to read the header on the affected paths.

Release and upgrade impact

No operator action and no migration.

@Medformatik Medformatik self-assigned this Nov 16, 2026
@Medformatik
Medformatik added this pull request to stack #985 November 16, 2026 09:30
@Medformatik
Medformatik force-pushed the fix/csp-on-every-page branch from c94931f to 7d626ff Compare November 16, 2026 10:00
The proxy skipped any path ending in an image or font extension and any path
starting with the letters of a static prefix, so a page under such a path was
served without a policy. The exclusions are now anchored to the real static
locations.
@Medformatik
Medformatik force-pushed the fix/csp-on-every-page branch from 7d626ff to b6e655c Compare November 16, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant