The instance Iâm testing with is not ssl-enabled, thatâs probably why http is added implicitely. When specifying $csp->addAllowedScriptDomain("https://maps.googleapis.com")
, this changes to https in the server request as well. I upgraded my developer instance to https, and now the content-security-policy contains maps.googleapis.com only.
Investigating my environments further, things get more confusing. I have three installations, all having the very same Debian, Apache and NC30.0.2.
Developer and Test site both deliver the very same response header (less the nonce), but the browser will the CSP error âblocked maps.googleapis.com, violating script-src-elemâ as mentioned above for the dev site only. Both sites show a warning âContent-Security-Policy: Ignorieren von âhttps://maps.googleapis.comâ innerhalb script-src-elem: âstrict-dynamicâ angegebenâ and do not load the google script.
The production site generates a slightly different CSP:
default-src 'none';base-uri 'none';manifest-src 'self';
script-src 'nonce-+pDb78qEyNosQaXVyHue3nDs2ceeaB3G/b/g6o5Clkw=' blob: maps.googleapis.com developers.google.com;
script-src-elem 'strict-dynamic' 'nonce-+pDb78qEyNosQaXVyHue3nDs2ceeaB3G/b/g6o5Clkw=' blob: maps.googleapis.com developers.google.com;(...)
and another warning is logged on the console:
Content-Security-Policy: Ignorieren von âblob:â innerhalb script-src-elem: âstrict-dynamicâ angegeben
This tests were performed with Firefox. Using Chrome, thereâs one additional helpful message: âNote that âstrict-dynamicâ is present, so host-based allowlisting is disabled.â which does explain, why m.g.c isnât loaded.
With this new insight, I tried $csp->useStrictDynamic()
and $csp->useStrictDynamicOnScripts()
with false
and with true
argument, but the CSP is always generated with strict-dynamic.
Finally, instead of loading from the main.html via script tag, I load from a script now, which does work correctly.
Lesson learned: ContentSecurityPolicy:addAllowedScriptDomain() isnât working for external domains any more.