fix(boardwalk): add form-action and frame-src to the admin CSP
- form-action 'self': injected markup cannot post a native form off-origin - frame-src 'none': no framed content; a sandboxed srcdoc preview is not fetched and still renders - header tests, README and admin-spa docs name the directives
This commit is contained in:
@@ -28,8 +28,11 @@ var distFS embed.FS
|
||||
const BaseToken = "__SUMMER_ADMIN_BASE__"
|
||||
|
||||
// contentSecurityPolicy keeps the admin out of frames and allows scripts
|
||||
// only from its own origin; the build contains no inline script.
|
||||
const contentSecurityPolicy = "frame-ancestors 'none'; base-uri 'none'; object-src 'none'; script-src 'self'"
|
||||
// only from its own origin; the build contains no inline script. Injected
|
||||
// markup can neither post a native form off-origin (form-action 'self') nor
|
||||
// frame fetched content (frame-src 'none'); a sandboxed srcdoc preview is not
|
||||
// fetched, so it still renders.
|
||||
const contentSecurityPolicy = "frame-ancestors 'none'; base-uri 'none'; object-src 'none'; script-src 'self'; form-action 'self'; frame-src 'none'"
|
||||
|
||||
var contentTypes = map[string]string{
|
||||
".js": "text/javascript; charset=utf-8",
|
||||
@@ -164,7 +167,8 @@ func ContentType(name string) string {
|
||||
|
||||
// SetSecurityHeaders sets the admin response headers: nosniff, a same-origin
|
||||
// referrer policy, no framing, the admin Content-Security-Policy
|
||||
// (script-src 'self') and noindex.
|
||||
// (script-src 'self', form-action 'self', frame-src 'none': no native form
|
||||
// post off-origin, no framed content) and noindex.
|
||||
func SetSecurityHeaders(h http.Header) {
|
||||
h.Set("X-Content-Type-Options", "nosniff")
|
||||
h.Set("Referrer-Policy", "same-origin")
|
||||
|
||||
Reference in New Issue
Block a user