diff --git a/docs/adr/0004-pluggable-storage-backends.md b/docs/adr/0004-pluggable-storage-backends.md index 59a1a29..d5338b6 100644 --- a/docs/adr/0004-pluggable-storage-backends.md +++ b/docs/adr/0004-pluggable-storage-backends.md @@ -88,6 +88,8 @@ not preclude it. so Metadata deliveries carry no `contentType`. It sets `Content-Disposition` on `stream` and `path` deliveries; a redirecting backend bakes `context.contentDisposition` into its URL. +- The library also sets protective headers on `stream`, `path` and `json` + deliveries; see [ADR 0005](0005-library-sandboxes-delivered-bytes.md). - Storage is the source of truth for size, ETag and Last-Modified, so a stale `File.size` can't produce a wrong header. `File.mediaType` is the source of truth for Content-Type, since stored types are often diff --git a/docs/adr/0005-library-sandboxes-delivered-bytes.md b/docs/adr/0005-library-sandboxes-delivered-bytes.md new file mode 100644 index 0000000..c12877a --- /dev/null +++ b/docs/adr/0005-library-sandboxes-delivered-bytes.md @@ -0,0 +1,59 @@ +# 5. The library sandboxes the bytes it delivers + +Date: 2026-10-28 + +## Status + +Accepted + +## Context + +Content and much Metadata come from depositors and nobody vets them. The +library served them on the API's origin under their own Content-Type and with +no other protective headers. So opening a deposited HTML or SVG file ran its +scripts on that origin, where they could reach cookies, same-origin pages and +any sign-in or admin UI the deployment hosts there. + +Browsers render inline PDFs, images and text under the full policy +`default-src 'none'; style-src 'unsafe-inline'; sandbox`. That holds in +current Chrome and Firefox, and in Safari from 18.4; Safari 17.4.1 to 18.3 +won't show a PDF under `sandbox`. Chrome won't play audio or +video opened directly under `sandbox`, because the media document refetches +the file from an opaque origin and fails CORS. It also won't play them under +`default-src 'none'` without `media-src`. A browser can't run script in a +media document, and `