security: isolate artifact documents and default servers to execution-only
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user