Sandbox home and artifact files served on the app origin (H1)

GET /files and /artifacts/ now send the artifact sandbox CSP and nosniff
through one helper, and /files serves HTML, XHTML, SVG, XML, XSL,
JavaScript and multipart/x-mixed-replace as attachments, including when
the type is sniffed from an extensionless file. The web proxy adds the same
headers to every proxied /files and /artifacts/ response (defence in depth
against an older server), and the peer relay shares the helper.

show_html previews are unchanged by operator decision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 23:16:46 +00:00
parent 806b5eca46
commit e39a9560ba
9 changed files with 233 additions and 21 deletions
+1 -2
View File
@@ -291,8 +291,7 @@ func (r *runner) serveArtifact(w http.ResponseWriter, req *http.Request) {
// Enforce the boundary on the response itself: opening the raw HTML/SVG in
// a new tab must be as safe as the embedded sandboxed preview. No scripts,
// network calls, forms, same-origin authority or top-level navigation.
w.Header().Set("Content-Security-Policy", "sandbox; default-src 'none'; script-src 'none'; connect-src 'none'; style-src 'unsafe-inline'; img-src 'self' data:; media-src 'self' data:; base-uri 'none'; form-action 'none'; frame-ancestors 'self'")
w.Header().Set("X-Content-Type-Options", "nosniff")
setUntrustedContentHeaders(w.Header())
w.Header().Set("Cache-Control", "private, no-store")
http.ServeContent(w, req, path.Base(name), opened.ModTime(), file)
}