90814[BUGFIX] Avoid applying CSP nonce sources when not required
Commit message
Review
-
Code review CR +2 Done
- Oliver Hader +2
- Christian Kuhn +1
- Benni Mack +1
-
Verified V +2 Done
- Oliver Hader +2
- Christian Kuhn +1
- Benni Mack +1
- core-ci +1 CI
Issues 1
Files 24
- typo3/sysext/adminpanel/Classes/Controller/MainController.php+3 −2
- typo3/sysext/backend/Classes/Middleware/ContentSecurityPolicyHeaders.php+25 −11
- typo3/sysext/core/Classes/Http/Security/ReferrerEnforcer.php+2 −1
- typo3/sysext/core/Classes/Page/AssetRenderer.php+13 −7
- typo3/sysext/core/Classes/Page/ImportMap.php+1 −1
- typo3/sysext/core/Classes/Page/JavaScriptRenderer.php+2 −1
- typo3/sysext/core/Classes/Page/PageRenderer.php+10 −9
- typo3/sysext/core/Classes/Security/ContentSecurityPolicy/Configuration/Behavior.phpnew+26 −0
- typo3/sysext/core/Classes/Security/ContentSecurityPolicy/Event/PolicyPreparedEvent.phpnew+31 −0
- typo3/sysext/core/Classes/Security/ContentSecurityPolicy/Middleware/PolicyBag.phpnew+65 −0
- typo3/sysext/core/Classes/Security/ContentSecurityPolicy/Middleware/ResponseService.phpnew+53 −0
- typo3/sysext/core/Classes/Security/ContentSecurityPolicy/ConsumableNonce.php2+72 −7
- typo3/sysext/core/Classes/Security/ContentSecurityPolicy/Policy.php+29 −4
- typo3/sysext/core/Classes/Security/ContentSecurityPolicy/PolicyProvider.php2+38 −8
- typo3/sysext/core/Documentation/Changelog/13.4.x/Important-107062-AvoidApplyingContent-Security-PolicyNonceSourcesWhenNotRequired.rst13new+94 −0
- typo3/sysext/core/Tests/Functional/Security/ContentSecurityPolicy/PolicyTest.php+21 −0
- typo3/sysext/core/Tests/Unit/Security/ContentSecurityPolicy/ConsumableNonceTest.php+16 −2
- typo3/sysext/extbase/Classes/Utility/DebuggerUtility.php+8 −3
- typo3/sysext/fluid/Classes/ViewHelpers/Security/NonceViewHelper.php+2 −1
- typo3/sysext/frontend/Classes/Cache/NonceValueSubstitution.php1+1 −1
Show 4 more files
- typo3/sysext/frontend/Classes/EventListener/AvoidContentSecurityPolicyNonceEventListener.phpnew+115 −0
- typo3/sysext/frontend/Classes/Http/RequestHandler.php7+36 −13
- typo3/sysext/frontend/Classes/Middleware/ContentSecurityPolicyHeaders.php+18 −9
- typo3/sysext/frontend/Tests/Functional/SiteHandling/RequestHandlerTest.php+121 −2
Review log 5181
Show 3356 earlier messages
-
Oliver Hader uploaded patch set 1 09/26/25, 15:44
-
Oliver Hader uploaded patch set 2 09/26/25, 15:56
-
core-ci voted on patch set 1 V -1 09/26/25, 15:57 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85616
-
core-ci voted on patch set 2 V +1 09/26/25, 16:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85619
-
Oliver Hader uploaded patch set 3
V +109/28/25, 18:34 -
core-ci voted on patch set 3 V -1 09/28/25, 18:40 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85666
-
Oliver Hader rebased onto patch set 4
V -109/29/25, 07:45 -
core-ci voted on patch set 4 V +1 09/29/25, 07:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85683
-
Oliver Hader uploaded patch set 5
V +110/06/25, 16:43 -
Oliver Hader commented on patch set 5 10/06/25, 16:44
-
core-ci voted on patch set 5 V +1 10/06/25, 16:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86087
-
Oliver Hader uploaded patch set 6
V +110/07/25, 19:16 -
core-ci voted on patch set 6 V -1 10/07/25, 19:37 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86181
-
Oliver Hader uploaded patch set 7
V -110/07/25, 19:41 -
core-ci voted on patch set 7 V -1 10/07/25, 19:54 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86183
-
Oliver Hader uploaded patch set 8
V -110/07/25, 20:00 -
core-ci voted on patch set 8 V -1 10/07/25, 20:11 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86184
-
Oliver Hader uploaded patch set 9
V -110/07/25, 20:49 -
core-ci voted on patch set 9 V +1 10/07/25, 20:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86188
-
Oliver Hader uploaded patch set 10
V +110/07/25, 21:17 -
core-ci voted on patch set 10 V +1 10/07/25, 21:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86190
-
Oliver Hader uploaded patch set 11
V +110/07/25, 22:04 -
Oliver Hader marked it ready for review 10/07/25, 22:04
-
core-ci voted on patch set 11 V +1 10/07/25, 22:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86191
-
Garvin Hicking commented on patch set 11 10/08/25, 04:54
Important-107062-AvoidApplyingContent-Security-PolicyNonceSourcesWhenNotRequired.rst:87Could you describe more distinction of "allow" and "avoid"? I don't understand what would trigger a nonce in "default" that would not get triggered in "avoid". the example of "strict-dynamic" would trigger an nonce in both allow and avoid, so a "negative" example would help for distinction?Important-107062-AvoidApplyingContent-Security-PolicyNonceSourcesWhenNotRequired.rst:90Could you also mention in which situations a dropped nonce even though required would be useful? I wonder how a site would work then on a client. Is this about being "lax" to violations, so if you only use nonce protected assets like CSS/JS that is optional and ok to not be shown? Or is this about things like edge caches / proxies which should ignore them? -
Garvin Hicking commented on patch set 11 10/08/25, 05:09
Important-107062-AvoidApplyingContent-Security-PolicyNonceSourcesWhenNotRequired.rst:15Do you mean performance by allowing reverse proxies and such? or client rendering performance? Maybe we should drop this "nonce are nasty for caching (client-side and for proxies" keyword? -
Oliver Hader commented on patch set 11 10/08/25, 08:21
Important-107062-AvoidApplyingContent-Security-PolicyNonceSourcesWhenNotRequired.rst:15ReplyYepp. When nonce sources are used, a page is not fully cached in TYPO3 (it behaves like when using `USER_INT` or `COA_INT` in TypoScript), plus HTTP cache headers are set to private. This has a negative impact on proxies, and e.g. for extensions like `staticfilecache`.Important-107062-AvoidApplyingContent-Security-PolicyNonceSourcesWhenNotRequired.rst:87Reply(see below) - `allow` as the default case represents the current behavior (without this patch) - it also could be named `auto` or just `null` (in terms of undefined)Important-107062-AvoidApplyingContent-Security-PolicyNonceSourcesWhenNotRequired.rst:90Reply`drop` focusses on fully cached pages and sending proper cache-headers (which is not possible when nonce sources are used). These enum cases are a preparation for introducing hash sources (as alternative to nonce values). Maybe the values should be: * `true` - use it (without enforcing) * `null` - let the system detect & decide * `false` - drop it (incl. constraints like for strict-dynamic) I also could make the event `@internal`, since it's not useful yet, without having the possibility to use hash sources. -
Oliver Hader uploaded patch set 12
V +110/08/25, 08:55 -
Oliver Hader commented on patch set 12 10/08/25, 08:57
Important-107062-AvoidApplyingContent-Security-PolicyNonceSourcesWhenNotRequired.rst:15ReplyI've adjusted this section to mention HTTP cache headers, as well as the performance topic.Important-107062-AvoidApplyingContent-Security-PolicyNonceSourcesWhenNotRequired.rst:90ReplyI've now adjusted the whole section and removed the `UseType` enum from the code. -
core-ci voted on patch set 12 V +1 10/08/25, 09:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86212
-
Oliver Hader commented on patch set 11 10/08/25, 09:14
Stream.php:229→ extracted to https://review.typo3.org/c/Packages/TYPO3.CMS/+/90949 -
Garvin Hicking commented on patch set 12 10/08/25, 12:07
ConsumableNonce.php:28This is a small goose chase ;), maybe directly refer to consumeInline/consumeStatic here?Important-107062-AvoidApplyingContent-Security-PolicyNonceSourcesWhenNotRequired.rst:15ReplyMuch better to understand, thanks!Important-107062-AvoidApplyingContent-Security-PolicyNonceSourcesWhenNotRequired.rst:19```suggestion This change aims for having fully cached pages and tries to avoid nonce sources ```Important-107062-AvoidApplyingContent-Security-PolicyNonceSourcesWhenNotRequired.rst:87ReplyAcknowledgedImportant-107062-AvoidApplyingContent-Security-PolicyNonceSourcesWhenNotRequired.rst:90ReplyI also think this makes it better readable and has less overhead. -
Oliver Hader uploaded patch set 13
V +110/08/25, 13:53 -
Oliver Hader commented on patch set 13 10/08/25, 13:53
Stream.php:229ReplyDoneConsumableNonce.php:28ReplyDoneImportant-107062-AvoidApplyingContent-Security-PolicyNonceSourcesWhenNotRequired.rst:19ReplyDone -
core-ci voted on patch set 13 V +1 10/08/25, 14:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86236
-
Oliver Hader uploaded patch set 14
V +110/08/25, 23:19 -
core-ci voted on patch set 14 V +1 10/08/25, 23:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86257
-
Oliver Hader rebased onto patch set 15
V +110/09/25, 18:28 -
core-ci voted on patch set 15 V +1 10/09/25, 18:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86336
-
Oliver Hader commented on patch set 16
V +110/13/25, 07:33Published edit on patch set 15. -
core-ci voted on patch set 16 V +1 10/13/25, 07:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86519
-
Oliver Hader rebased onto patch set 17
V +110/14/25, 11:56 -
core-ci voted on patch set 17 V +1 10/14/25, 12:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86622
-
Oliver Hader rebased onto patch set 18
V +110/14/25, 20:52 -
core-ci voted on patch set 18 V -1 10/14/25, 21:00 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86661
-
core-ci commented on patch set 18 10/14/25, 21:10 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86661
-
Oliver Hader uploaded patch set 19
V -110/15/25, 09:41 -
core-ci voted on patch set 19 V +1 10/15/25, 09:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86707
-
Oliver Hader commented on patch set 19 CR -1 10/19/25, 09:09
-
Oliver Hader uploaded patch set 20
CR -1V +110/19/25, 17:15 -
core-ci voted on patch set 20 V +1 10/19/25, 17:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87019
-
Oliver Hader rebased onto patch set 21
V +110/23/25, 11:25 -
Oliver Hader commented on patch set 21 10/23/25, 11:25
Reply
Done -
core-ci voted on patch set 21 V +1 10/23/25, 11:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87412
-
Oliver Hader uploaded patch set 22
V +110/27/25, 16:06 -
core-ci voted on patch set 22 V +1 10/27/25, 16:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87679
-
Oliver Hader uploaded patch set 23
V +110/27/25, 16:32 -
core-ci voted on patch set 23 V +1 10/27/25, 16:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87681
-
Oliver Hader uploaded patch set 24
V +110/27/25, 16:40 -
core-ci voted on patch set 24 V +1 10/27/25, 16:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87684
-
Christian Kuhn uploaded patch set 25
V +110/28/25, 13:20 -
core-ci voted on patch set 25 V -1 10/28/25, 13:28 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87825
-
Christian Kuhn commented on patch set 25 10/28/25, 13:39
PolicyProvider.php:45the final is removed here only for unit RequestHandlerTest to mock it. i'll have a look at that test case now, it needs a refactoring anyway. -
Christian Kuhn uploaded patch set 26
V -110/28/25, 13:41 -
core-ci voted on patch set 26 V +1 10/28/25, 13:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87826
-
Oliver Hader uploaded patch set 27
V +110/28/25, 19:49 -
Oliver Hader rebased onto patch set 28 10/28/25, 19:52
-
core-ci voted on patch set 27 V -1 10/28/25, 19:52 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87876
-
Oliver Hader commented on patch set 29 10/28/25, 19:53
Published edit on patch set 28. -
Oliver Hader commented on patch set 29 10/28/25, 19:55
PolicyProvider.php:45ReplyAwesome, thx! I re-added `final` (and kept the `readonly` change for that `@internal` class). -
core-ci voted on patch set 29 V +1 10/28/25, 20:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87878
-
Christian Kuhn commented on patch set 29 10/30/25, 13:09
RequestHandler.php:137skip. frontend.page.parts must be set at this point, and if someone managed to make it something different than PageParts, it could please just fatal. maybe just expect if you insist on testing for it here. PrepareTypoScriptFrontendRendering tests for some attributes and excepts as well already.RequestHandler.php:179let's do the bugfix, but i think we should model this differently and more explicit in main afterwards, to separate it from casual "int" handling. -
Christian Kuhn uploaded patch set 30
V +110/30/25, 13:12 -
Christian Kuhn commented on patch set 29 10/30/25, 13:12
RequestHandler.php:137ReplyDoneRequestHandler.php:179ReplyDone -
Christian Kuhn commented on patch set 30 CR +1 V +1 10/30/25, 13:20
RequestHandler.php:180the main issue is that registering the pseudo INT makes core never send client cache headers, right? it stems from the mix up with "casual" INT objects here, if i understand this correctly and leads to issues with tsfe->getCacheHeaders() (i'm rewriting the method in https://review.typo3.org/c/Packages/TYPO3.CMS/+/91332 and will move it soon). so we could potentially simplify this area if we separate int/non-cached element and nonce handling in a better way? -
core-ci voted on patch set 30 V +1 10/30/25, 13:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/88141
-
Benni Mack voted on patch set 30 CR +1 V +1 10/30/25, 14:22
-
Oliver Hader voted on patch set 30 CR +2 V +2 10/30/25, 15:52
-
Oliver Hader merged patch set 31 10/30/25, 16:20
-
Oliver Hader commented on patch set 31 10/30/25, 16:24
RequestHandler.php:180ReplyCorrect, nonces must not be cached ("number used *once*"), that's why it was added as pseudo `INT` object here. When rewriting this (CSP) part, it would require an indicator, that the nonce needs to be regenerated in the next request and the corresponding post-processing. -
Christian Kuhn commented on patch set 31 10/30/25, 18:13
RequestHandler.php:180Replyi see. thx. i'll keep that in mind with current refactoring loops and may come back to it.
NonceValueSubstitution.php:23