restrict unnecessarily permissive CSP

pull/1/head
ansuz 3 years ago
parent ae84d99af0
commit 29fe4b7223

@ -2,6 +2,7 @@ var Default = module.exports;
Default.commonCSP = function (domain, sandbox) { Default.commonCSP = function (domain, sandbox) {
domain = ' ' + domain; domain = ' ' + domain;
sandbox = (sandbox && sandbox !== domain? ' ' + sandbox: '');
// Content-Security-Policy // Content-Security-Policy
return [ return [
@ -15,19 +16,19 @@ Default.commonCSP = function (domain, sandbox) {
* it is recommended that you configure these fields to match the * it is recommended that you configure these fields to match the
* domain which will serve your CryptPad instance. * domain which will serve your CryptPad instance.
*/ */
"child-src blob: *", "child-src 'self' blob: " + domain + sandbox,
// IE/Edge // IE/Edge
"frame-src blob: *", "frame-src 'self' blob: " + domain + sandbox,
/* this allows connections over secure or insecure websockets /* this allows connections over secure or insecure websockets
if you are deploying to production, you'll probably want to remove if you are deploying to production, you'll probably want to remove
the ws://* directive, and change '*' to your domain the ws://* directive, and change '*' to your domain
*/ */
"connect-src 'self' ws: wss: blob: " + domain + (sandbox && sandbox !== domain? ' ' + sandbox: ''), "connect-src 'self' ws: wss: blob: " + domain + sandbox,
// data: is used by codemirror // data: is used by codemirror
"img-src 'self' data: blob:" + domain, "img-src 'self' data: blob:" + domain,
"media-src * blob:", "media-src blob:",
// for accounts.cryptpad.fr authentication and cross-domain iframe sandbox // for accounts.cryptpad.fr authentication and cross-domain iframe sandbox
"frame-ancestors *", "frame-ancestors *",

Loading…
Cancel
Save