security: isolate artifact documents and default servers to execution-only

This commit is contained in:
2026-10-20 15:36:14 +01:00
parent db88cebd0b
commit f06281db08
10 changed files with 193 additions and 4 deletions
+7
View File
@@ -270,5 +270,12 @@ func (r *runner) serveArtifact(w http.ResponseWriter, req *http.Request) {
http.NotFound(w, req)
return
}
// An artifact is untrusted generated content, not part of the control UI.
// 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")
w.Header().Set("Cache-Control", "private, no-store")
http.ServeContent(w, req, path.Base(name), opened.ModTime(), file)
}