From 4f49b16079b27d7ce633619e4cddfdf2bffbc952 Mon Sep 17 00:00:00 2001 From: cashmere Date: Fri, 4 Sep 2026 09:05:24 +0200 Subject: initial commit --- www/defcsp.md | 490 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 490 insertions(+) create mode 100644 www/defcsp.md (limited to 'www/defcsp.md') diff --git a/www/defcsp.md b/www/defcsp.md new file mode 100644 index 0000000..0e61fda --- /dev/null +++ b/www/defcsp.md @@ -0,0 +1,490 @@ +# The Default Content Security Policy (CSP) + +When Fossil’s web interface generates an HTML page, it normally includes +a [Content Security Policy][csp] (CSP) in the ``. The CSP specifies +allowed sources for external resources such as images, +CSS, javascript, and so forth. +The purpose of CSP is to provide an extra layer of protection against +[cross-site scripting][xss] (XSS) and code injection +attacks. Compatible web browsers will not use external resources unless +they are specifically allowed by the CSP, which dramatically reduces +the attack surface of the application. + +Fossil does not rely on CSP for security. +A Fossil server should be secure from attack even without CSP. +Fossil includes built-in server-side content filtering logic. +For example, Fossil purposely breaks ` + +That script can then do anything allowed in JavaScript to *any other* +Chisel repository your browser can access. The possibilities for mischief +are *vast*. For just one example, if you have login cookies on four +different Chisel repositories, your attacker could harvest the login +cookies for all of them through this path if we allowed Fossil to serve +JavaScript files under the same CSP policy as we do for CSS files. + +This is why the default configuration of Fossil has no way for [embedded +docs][ed], [wiki articles][wiki], [tickets][tkt], [forum posts][fp], or +[tech notes][tn] to automatically insert a nonce into the page content. +This is all user-provided content, which could link to user-provided +JavaScript via check-in rights, effectively giving all such users a +capability that is usually reserved to the repository’s administrator. + +The default-disabled [TH1 documents feature][edtf] is the only known +path around this restriction. If you are serving a Fossil repository +that has any user you do not implicitly trust to a level that you would +willingly run any JavaScript code they’ve provided, blind, you **must +not** give the `--with-th1-docs` option when configuring Fossil, because +that allows substitution of the [pre-defined `$nonce` TH1 +variable](./th1.md#nonce) into [HTML-formatted embedded docs][hfed]: + + + +Even with this feature enabled, you cannot put `