Feature #105087
open
CSP Header option to disable or reduce amount of reporting-uri requests
Added by Sascha Zander about 2 months ago.
Updated about 1 month ago.
Category:
Content Security Policy
Description
Hi,
I couldn't find a way to render the CSP headers without the reporting-uri.
The problem is that we have a lot of thirdparty javascripts on the page.
As soon as we have a new CSP error, our network load doubles every time due to the reporting request of the clients.
It would be better if the reporting-uri would only be attached for logged in backend users or to have an option to turn it off completely.
How gets that third-party code in? By a tag manager or other loader script which then loads additional code? Then a solution might be to use strict-dynamic:
https://content-security-policy.com/strict-dynamic/
Then the "root script" is always trusted and can load additional scripts from other domains without adjusting your policy.
Please also mind the fallbacks for browsers which does not support strict-dynamic currently (from the major browsers currently only Firefox on Android).
You might also use the PolicyMutatedEvent to adjust your policy:
https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Events/Events/Core/Security/PolicyMutatedEvent.html
This way, you can check the request and set the report-uri accordingly.
The amount of requests cannot be lowered directly, because the requests are send by the browsers. Indirectly with adjusting the report-uri endpoint, for example, by restricting the IP adresses (with the mentioned event).
- Status changed from New to Needs Feedback
You might be able to 'abuse' setting the reportURI like this:
$GLOBALS['TYPO3_CONF_VARS']['BE']['contentSecurityPolicyReportingUrl']
= 'abc:invalid';
$GLOBALS['TYPO3_CONF_VARS']['FE']['contentSecurityPolicyReportingUrl']
= 'abc:invalid';
This should then return a `null` URI (InvalidArgumentException), which in turn would prevent adding a Report-URI.
(Having said that - might still be worth investigating if removing a report-uri could be made easier, as it's an optional argument [and actually deprecated, but report-for seems to not have been widely adopted yet])
- Target version changed from 13 LTS to Candidate for Major Version
Also available in: Atom
PDF