For git.coop
which is running the CE version I updated /etc/gitlab/gitlab.rb
to contain:
gitlab_rails['content_security_policy'] = {
'enabled' => true,
'report_only' => true,
}
And this resulted in the following HTTP header (additional new lines added to make it more readable):
curl -I https://git.coop/users/sign_in | grep ^content-security-policy-report-only | sed 's/;/;\n/g'
content-security-policy-report-only: base-uri 'self';
child-src https://www.google.com/recaptcha/ https://www.recaptcha.net/ https://content.googleapis.com https://content-compute.googleapis.com https://content-cloudbilling.googleapis.com https://content-cloudresourcemanager.googleapis.com https://www.googletagmanager.com/ns.html https://git.coop/admin/ https://git.coop/assets/ https://git.coop/-/speedscope/index.html https://git.coop/-/sandbox/ https://git.coop/assets/ blob: data:;
connect-src 'self' wss://git.coop https://cdn.cookielaw.org https://*.onetrust.com *.google-analytics.com *.analytics.google.com *.googletagmanager.com;
default-src 'self';
font-src 'self';
form-action 'self' https: http:;
frame-ancestors 'self';
frame-src https://www.google.com/recaptcha/ https://www.recaptcha.net/ https://content.googleapis.com https://content-compute.googleapis.com https://content-cloudbilling.googleapis.com https://content-cloudresourcemanager.googleapis.com https://www.googletagmanager.com/ns.html https://git.coop/admin/ https://git.coop/assets/ https://git.coop/-/speedscope/index.html https://git.coop/-/sandbox/;
img-src 'self' data: blob: http: https: *.google-analytics.com *.googletagmanager.com;
manifest-src 'self';
media-src 'self' data: blob: http: https:;
object-src 'none';
script-src 'strict-dynamic' 'self' 'unsafe-inline' 'unsafe-eval' https://www.google.com/recaptcha/ https://www.recaptcha.net https://apis.google.com https://cdn.cookielaw.org https://*.onetrust.com https://cdn.bizible.com/scripts/bizible.js *.googletagmanager.com 'nonce-i5jZKW5htTIUEA4ui0+Euw==';
style-src 'self' 'unsafe-inline';
worker-src https://git.coop/assets/ blob: data:
I then removed all the 3rd party URLs and generated this configuration:
gitlab_rails['content_security_policy'] = {
'enabled' => true,
'report_only' => true,
'directives' => {
'base_uri' => "'self'",
'child_src' => "https://git.coop/admin/ https://git.coop/assets/ https://git.coop/-/speedscope/index.html https://git.coop/-/sandbox/ https://git.coop/assets/ blob: data:",
'connect_src' => "'self' wss://git.coop",
'default_src' => "'self'",
'font_src' => "'self'",
'form_action' => "'self' https: http:",
'frame_ancestors' => "'self'",
'frame_src' => "https://git.coop/admin/ https://git.coop/assets/ https://git.coop /-/speedscope/index.html https://git.coop/-/sandbox/",
'img_src' => "'self' data: blob: http: https:",
'manifest_src' => "'self'",
'media_src' => "'self' data: blob: http: https:",
'object_src' => "'none'",
'script_src' => nil,
'style_src' => "'self' 'unsafe-inline'",
'worker_src' => "https://git.coop/assets/ blob: data:",
'report_uri' => nil,
}
}
Note that I have kept script_src
as nill
as it contains a nonce, is this approach sensible, or pointless as the headers still contains 3rd party URLs, is the configuration in /etc/gitlab/gitlab.rb
just to add to the default policy rather than replace it?
If that is the case would I be better off with this configuration?
gitlab_rails['content_security_policy'] = {
'enabled' => true,
}
The current headers:
curl -I https://git.coop/users/sign_in | grep ^content-security-policy-report-only | sed 's/;/;\n/g'
content-security-policy-report-only: base-uri 'self';
child-src https://git.coop/admin/ https://git.coop/assets/ https://git.coop/-/speedscope/index.html https://git.coop/-/sandbox/ https://git.coop/assets/ blob: data:;
connect-src 'self' wss://git.coop https://cdn.cookielaw.org https://*.onetrust.com *.google-analytics.com *.analytics.google.com *.googletagmanager.com;
default-src 'self';
font-src 'self';
form-action 'self' https: http:;
frame-ancestors 'self';
frame-src https://git.coop/admin/ https://git.coop/assets/ https://git.coop /-/speedscope/index.html https://git.coop/-/sandbox/;
img-src 'self' data: blob: http: https: *.google-analytics.com *.googletagmanager.com;
manifest-src 'self';
media-src 'self' data: blob: http: https:;
object-src 'none';
script-src 'strict-dynamic' 'self' 'unsafe-inline' 'unsafe-eval' https://www.google.com/recaptcha/ https://www.recaptcha.net https://apis.google.com https://cdn.cookielaw.org https://*.onetrust.com https://cdn.bizible.com/scripts/bizible.js *.googletagmanager.com 'nonce-5TdmOr6eM8mGu9XeUXjxMg==';
style-src 'self' 'unsafe-inline';
worker-src https://git.coop/assets/ blob: data:
Also does anyone have any suggestions regarding how to check that changing report_only
to false
won’t break anything?