Security: plain-mode public links serve HTML and SVG inline on the Cairn origin (stored XSS) #1139

Closed
opened 2026-11-06 23:55:32 +00:00 by Cordy · 1 comment
Owner

Found in the #1105 research (2026-11-07), checked at 78c814d7 (v0.6.401).

  • internal/share/public.go:378-382: for a non-strong (plain-mode) link, the file is served with its stored Content-Type (on POSIX from the extension, internal/storage/posix/posix.go:239) and Content-Disposition: inline. There is no X-Content-Type-Options: nosniff and no Content-Security-Policy on this path (other user-content paths have them: preview.go:34, avatars.go:143, dataexport_admin.go:467-468).
  • internal/api/shares.go:487-501: the comment calls "plain" "the policy-gated legacy escape hatch", but the handler accepts "mode":"plain" from any signed-in user with no policy check.

Effect (INFERRED, not exploited): any user can upload x.html or an .svg with script, create a plain-mode link and send it; the page runs on the Cairn origin, so a signed-in visitor's session can be used for same-origin API calls.

Fix to design (research first, small): serve all public-link content with nosniff and a sandboxing CSP (sandbox; default-src 'none' style), force attachment (or a safe type) for active types (HTML, SVG, XML, JS), and either gate plain behind the admin policy or retire it for new links. Check the signed-in download paths for the same pattern. Tests for each type. Ships before launch.

Found in the #1105 research (2026-11-07), checked at 78c814d7 (v0.6.401). - `internal/share/public.go:378-382`: for a non-strong (plain-mode) link, the file is served with its stored `Content-Type` (on POSIX from the extension, `internal/storage/posix/posix.go:239`) and `Content-Disposition: inline`. There is no `X-Content-Type-Options: nosniff` and no `Content-Security-Policy` on this path (other user-content paths have them: `preview.go:34`, `avatars.go:143`, `dataexport_admin.go:467-468`). - `internal/api/shares.go:487-501`: the comment calls `"plain"` "the policy-gated legacy escape hatch", but the handler accepts `"mode":"plain"` from any signed-in user with no policy check. Effect (INFERRED, not exploited): any user can upload `x.html` or an `.svg` with script, create a plain-mode link and send it; the page runs on the Cairn origin, so a signed-in visitor's session can be used for same-origin API calls. Fix to design (research first, small): serve all public-link content with `nosniff` and a sandboxing CSP (`sandbox; default-src 'none'` style), force `attachment` (or a safe type) for active types (HTML, SVG, XML, JS), and either gate `plain` behind the admin policy or retire it for new links. Check the signed-in download paths for the same pattern. Tests for each type. Ships before launch.
Cordy closed this issue 2026-11-07 03:24:42 +00:00
Author
Owner

Fixed in v0.6.402 (PR #1141), live on both dogfoods (ready, no restarts, no new warnings). Research: scratch/b7e/backlog/research-1139.md (Seafile had the same bug, CVE-2025-65516; Nextcloud an SVG XSS, CVE-2025-66512).

  • Every route that returns stored file bytes now goes through one helper: nosniff, default-src 'none'; img-src 'self' data:; media-src 'self'; style-src 'unsafe-inline'; sandbox allow-downloads, active types (HTML, XHTML, SVG, XML, JavaScript, MHTML) always as attachment with application/octet-stream; passive PDFs inline without the sandbox. Includes the second route the sweep found: WebDAV GET with the browser session.
  • New keyless (plain) links need shareLinksPlainAllowed (API-only, off): 403 link-mode-plain-disabled. Existing plain links keep working with the safe headers.
  • Review found no blockers; Chromium checked (top-level image, audio, text still work). Safari and Firefox are on the #1005 list. Follow-up idea (not filed): serving user content from a separate domain, as Google and GitHub do, would be a stronger layer.
Fixed in **v0.6.402** (PR #1141), live on both dogfoods (ready, no restarts, no new warnings). Research: `scratch/b7e/backlog/research-1139.md` (Seafile had the same bug, CVE-2025-65516; Nextcloud an SVG XSS, CVE-2025-66512). - Every route that returns stored file bytes now goes through one helper: `nosniff`, `default-src 'none'; img-src 'self' data:; media-src 'self'; style-src 'unsafe-inline'; sandbox allow-downloads`, active types (HTML, XHTML, SVG, XML, JavaScript, MHTML) always as attachment with `application/octet-stream`; passive PDFs inline without the sandbox. Includes the second route the sweep found: WebDAV GET with the browser session. - New keyless (plain) links need `shareLinksPlainAllowed` (API-only, off): 403 `link-mode-plain-disabled`. Existing plain links keep working with the safe headers. - Review found no blockers; Chromium checked (top-level image, audio, text still work). Safari and Firefox are on the #1005 list. Follow-up idea (not filed): serving user content from a separate domain, as Google and GitHub do, would be a stronger layer.
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Cordy/Cairn#1139
No description provided.