#105087CSP Header option to disable or reduce amount of reporting-uri requests
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.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Related issues 1
History 7
-
Chris Müller changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2024-09-23T12:56:58+00:00" > 09/23/24, 12:56 </span> -
Sascha Zander commented <span data-processor="relativetime" data-value="2024-09-25T13:34:54+00:00" > 09/25/24, 13:34 </span>
Chris Müller wrote in #note-1:
> 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).
>
I do not want to allow this, as we cannot trust the scripts well enough for security reasons.
There is a possibility that they could download harmful content in the future.> 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).How exactly can I use the PolicyMutatedEvent to restrict it to certain IP addresses?
When I try to remove the Directive::ReportUri, it is added again due to the code here:
https://github.com/TYPO3/typo3/blob/6b9220ed3f878e8c09f9e1dbb6e058eca8b664f3/typo3/sysext/backend/Classes/Middleware/ContentSecurityPolicyHeaders.php#L67 -
Garvin Hicking commented <span data-processor="relativetime" data-value="2024-09-25T13:45:15+00:00" > 09/25/24, 13:45 </span>
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])
-
Benni Mack changed target version <span data-processor="relativetime" data-value="2024-10-15T09:46:24+00:00" > 10/15/24, 09:46 </span>
-
Oliver Hader changed Related to #105856 <span data-processor="relativetime" data-value="2024-12-24T11:26:34+00:00" > 12/24/24, 11:26 </span>
-
Georg Ringer commented and changed status
Needs FeedbackClosed <span data-processor="relativetime" data-value="2025-04-16T17:06:44+00:00" > 04/16/25, 17:06 </span>this can be fixed with #105856,
The way Content-Security-Policy reporting endpoints are configured has
been enhanced. Administrators can now disable the reporting endpoint
globally or configure it per site as needed.The global scope-specific setting `contentSecurityPolicyReportingUrl` can
be set to zero (‘0’) to disable the CSP reporting endpoint:- :php:`[TYPO3_CONF_VARS][FE][contentSecurityPolicyReportingUrl] = ‘0’`
- :php:`[TYPO3_CONF_VARS][BE][contentSecurityPolicyReportingUrl] = ‘0’`
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).