I’m getting heat from a client, complaining that my application’s CSP is too permissive.
I don’t use custom view tags like maps or youtube, but I do use Google Authenticator for 2FA.
I know I can change the CSP adding code like this to the global code:
Config()->append("CSP.[directive]", "[value]");
But I can’t find information on what is required by which feature.
So, how can the CSP be more restrictive? What is the minimum required for Google Authenticator, for instance? Can some of those wildcards be removed? Can some of those ‘unsafe’ settings be disabled?
Right now, Config(“CSP”) in config.php is:
"CSP" => [
"font-src" => [
"self" => true,
"data" => true,
"allow" => [
"https://fonts.gstatic.com",
],
],
"form-action" => [
"self" => true,
],
"object-src" => [
"self" => true,
],
"frame-ancestors" => [
"self" => true,
],
"frame-src" => [
"self" => true,
"allow" => [
"*.google.com",
"*.youtube.com",
],
],
"script-src" => [
"self" => true,
"unsafe-inline" => true,
"unsafe-eval" => true,
"blob" => true,
"allow" => [
"https://www.google-analytics.com",
"https://*.googleapis.com",
"https://*.gstatic.com",
"*.google.com",
"https://*.ggpht.com",
"*.googleusercontent.com",
"https://js.pusher.com",
"https://cdn.tiny.cloud",
"https://*.youtube.com",
],
],
"connect-src" => [
"self" => true,
"blob" => true,
"data" => true,
"allow" => [
"https://*.googleapis.com",
"https://*.gstatic.com",
"*.google.com",
],
],
"style-src" => [
"self" => true,
"unsafe-inline" => true,
"allow" => [
"https://*.gstatic.com",
"https://*.googleapis.com",
],
],
"style-src-attr" => [
"unsafe-inline" => true,
],
"img-src" => [
"self" => true,
"blob" => true,
"data" => true,
"allow" => [
"https://*.googleapis.com",
"https://*.gstatic.com",
"https://*.openstreetmap.org",
"https://api.mapbox.com",
"*.google.com",
"*.googleusercontent.com",
],
],
"worker-src" => [
"self" => true,
"blob" => true,
],
]
Hoping someone can shed some light on this. Thanks!