74183[!!!][FEATURE] Introduce CSRF-like request-token handling
Commit message
Review
-
Code review CR +2 Done
- Oliver Hader +2
- Torben Hansen +1
- Stefan Bürk +1
- Benni Mack +1
-
Verified V +2 Done
- Oliver Hader +2
- Torben Hansen +1
- Stefan Bürk +1
- Benni Mack +1
- core-ci +1 CI
Issues 1
Files 30
- typo3/sysext/backend/Classes/Controller/LoginController.php+10 −0
- typo3/sysext/backend/Configuration/RequestMiddlewares.php+9 −0
- typo3/sysext/backend/Resources/Private/Layouts/Login.html+1 −0
- typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php+19 −0
- typo3/sysext/core/Classes/Context/SecurityAspect.php6new+107 −0
- typo3/sysext/core/Classes/Middleware/RequestTokenMiddleware.php10new+163 −0
- typo3/sysext/core/Classes/Security/JwtTrait.phpnew+108 −0
- typo3/sysext/core/Classes/Security/Nonce.phpnew+90 −0
- typo3/sysext/core/Classes/Security/NonceException.phpnew+27 −0
- typo3/sysext/core/Classes/Security/NoncePool.phpnew+168 −0
- typo3/sysext/core/Classes/Security/RequestToken.php4new+120 −0
- typo3/sysext/core/Classes/Security/RequestTokenException.phpnew+27 −0
- typo3/sysext/core/Classes/Security/SecretIdentifier.phpnew+60 −0
- typo3/sysext/core/Classes/Security/SigningProviderInterface.phpnew+41 −0
- typo3/sysext/core/Classes/Security/SigningSecretInterface.phpnew+36 −0
- typo3/sysext/core/Classes/Security/SigningSecretResolver.phpnew+73 −0
- typo3/sysext/core/Documentation/Changelog/12.0/Breaking-97305-IntroduceCSRF-likeLoginToken.rst2new+74 −0
- typo3/sysext/core/Documentation/Changelog/12.0/Feature-97305-IntroduceCSRF-likeRequest-tokenHandling.rstnew+155 −0
- typo3/sysext/core/Tests/Unit/Context/SecurityAspectTest.phpnew+60 −0
- typo3/sysext/core/Tests/Unit/Security/NoncePoolTest.phpnew+135 −0
Show 10 more files
- typo3/sysext/core/Tests/Unit/Security/NonceTest.phpnew+89 −0
- typo3/sysext/core/Tests/Unit/Security/RequestTokenTest.phpnew+131 −0
- typo3/sysext/core/composer.json+1 −0
- typo3/sysext/felogin/Classes/Controller/LoginController.php+2 −0
- typo3/sysext/felogin/Resources/Private/Templates/Login/Login.html+2 −2
- typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php3+50 −0
- typo3/sysext/frontend/Configuration/RequestMiddlewares.php+10 −0
- typo3/sysext/frontend/Tests/Unit/Authentication/FrontendUserAuthenticationTest.php+10 −2
- composer.json+1 −0
- composer.lock+67 −5
Review log 6299
Show 4274 earlier messages
-
Oliver Hader uploaded patch set 1 04/05/22, 15:41
-
core-ci voted on patch set 1 V -1 04/05/22, 15:57 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25533
-
Oliver Hader uploaded patch set 2 05/05/22, 20:19
-
core-ci voted on patch set 2 V -1 05/05/22, 20:35 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26886
-
Oliver Hader uploaded patch set 3 05/05/22, 21:14
-
Oliver Hader uploaded patch set 4 05/05/22, 21:20
-
core-ci voted on patch set 3 V -1 05/05/22, 21:26 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26887
-
core-ci voted on patch set 4 V -1 05/05/22, 21:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26888
-
Oliver Hader uploaded patch set 5 05/06/22, 07:02
-
core-ci voted on patch set 5 V -1 05/06/22, 07:11 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26892
-
Oliver Hader uploaded patch set 6 09/24/22, 10:01
-
core-ci voted on patch set 6 V -1 09/24/22, 10:11 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31499
-
Oliver Hader uploaded patch set 7 09/24/22, 14:24
-
core-ci voted on patch set 7 V -1 09/24/22, 14:36 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31502
-
Oliver Hader uploaded patch set 8 09/25/22, 11:43
-
core-ci voted on patch set 8 V -1 09/25/22, 11:56 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31513
-
Oliver Hader uploaded patch set 9 09/25/22, 12:18
-
core-ci voted on patch set 9 V -1 09/25/22, 12:26 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31514
-
Oliver Hader commented on patch set 9 09/25/22, 12:37
→ PHP 8.2 issue in JWT lib: https://github.com/firebase/php-jwt/issues/459 -
Simon Schaufelberger commented on patch set 9 09/25/22, 13:01
Breaking-97305-IntroduceCSRF-likeLoginToken.rst:71linking between rest files should be done with the identifier in the top of every file. -
Chris Müller uploaded patch set 10 09/25/22, 14:22
-
Chris Müller commented on patch set 10 09/25/22, 14:22
Breaking-97305-IntroduceCSRF-likeLoginToken.rst:71ReplyDone -
core-ci voted on patch set 10 V -1 09/25/22, 14:29 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31515
-
Chris Müller uploaded patch set 11 09/25/22, 16:31
-
core-ci voted on patch set 11 V -1 09/25/22, 16:39 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31516
-
Chris Müller uploaded patch set 12 09/25/22, 17:20
-
core-ci voted on patch set 12 V -1 09/25/22, 17:29 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31517
-
Oliver Hader uploaded patch set 13 09/26/22, 06:31
-
core-ci voted on patch set 13 V -1 09/26/22, 06:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31525
-
Oliver Hader uploaded patch set 14 09/26/22, 06:40
-
core-ci voted on patch set 14 V -1 09/26/22, 06:48 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31526
-
Oliver Hader uploaded patch set 15 09/26/22, 08:28
-
core-ci voted on patch set 15 V +1 09/26/22, 08:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31529
-
Oliver Hader uploaded patch set 16 09/26/22, 09:47
-
core-ci voted on patch set 16 V +1 09/26/22, 09:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31532
-
Oliver Hader uploaded patch set 17 09/26/22, 10:32
-
core-ci voted on patch set 17 V +1 09/26/22, 10:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31534
-
Oliver Hader uploaded patch set 18 09/26/22, 14:46
-
core-ci voted on patch set 18 V -1 09/26/22, 14:55 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31541
-
Oliver Hader uploaded patch set 19 09/26/22, 15:01
-
Oliver Hader commented on patch set 19 09/26/22, 15:08
RequestToken.php:89Ooooh, this actually currently reveals the secret nonce (as b64). -
core-ci voted on patch set 19 V +1 09/26/22, 15:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31542
-
Oliver Hader uploaded patch set 20 09/26/22, 15:31
-
core-ci voted on patch set 20 V -1 09/26/22, 15:41 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31546
-
Oliver Hader uploaded patch set 21 09/26/22, 16:32
-
core-ci voted on patch set 21 V +1 09/26/22, 16:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31547
-
Oliver Hader uploaded patch set 22 09/26/22, 19:21
-
Oliver Hader uploaded patch set 23 09/26/22, 19:24
-
core-ci voted on patch set 22 V -1 09/26/22, 19:24 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31551
-
core-ci voted on patch set 22 V -1 09/26/22, 19:24 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31551
-
core-ci voted on patch set 23 V -1 09/26/22, 19:29 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31552
-
Oliver Hader uploaded patch set 24 09/26/22, 19:33
-
Oliver Hader commented on patch set 24 09/26/22, 19:35
RequestToken.php:89ReplyDone -
core-ci voted on patch set 24 V +1 09/26/22, 19:41 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31554
-
Oliver Hader commented on patch set 24 09/26/22, 19:42
This change is ready for review. -
Stefan Bürk commented on patch set 24 09/27/22, 02:57
Started a nightly on this, after failed "main nightlies": https://git.typo3.org/typo3/CI/cms/-/pipelines/31558 -
core-ci voted on patch set 24 V -1 09/27/22, 03:24 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31558
-
Oliver Hader commented on patch set 24 09/27/22, 05:39
Reply
Fails in "Change inline1n inline input" which seems to be very unrelated... I just restarted the failed jobs, since I could not spot any errors in the artifact files. -
core-ci voted on patch set 24 V +1 09/27/22, 05:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31558
-
Oliver Hader commented on patch set 24 09/27/22, 05:43
Reply
Nightlies are green now -
Oliver Hader uploaded patch set 25 09/27/22, 07:25
-
core-ci voted on patch set 25 V +1 09/27/22, 07:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31565
-
Benni Mack commented on patch set 25 CR -1 09/27/22, 13:46
The changes of composer.json also needs to be added to typo3/sysext/core/composer.json -
Chris Müller uploaded patch set 26 09/27/22, 16:57
-
Oliver Hader commented on patch set 26 CR -2 09/27/22, 17:00
What happened to patchset 26? -
Oliver Hader uploaded patch set 27 09/27/22, 17:05
-
Oliver Hader commented on patch set 27 CR 0 09/27/22, 17:06
I restored patchset 26, adjusted core/composer.json and added test-case for NoncePool -
Oliver Hader uploaded patch set 28 09/27/22, 17:08
-
core-ci voted on patch set 26 V -1 09/27/22, 17:13 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31605
-
core-ci voted on patch set 28 V +1 09/27/22, 17:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31608
-
Oliver Hader uploaded patch set 29 09/27/22, 17:19
-
core-ci voted on patch set 27 V +1 09/27/22, 17:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31607
-
core-ci voted on patch set 29 V +1 09/27/22, 17:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31610
-
Benni Mack commented on patch set 29 09/27/22, 19:10
should we name it CSRFToken instead of RequestToken? I think most devs understand CSRF more than the generic Request TokenRequestTokenMiddleware.php:76use $normalizedParams instead.RequestTokenMiddleware.php:123can use normalizedParams from $request instead.FormViewHelper.php:181should this only be added with method="POST" or should we throw an exception that a nonce is not allowed in combination with GET?
-
Oliver Hader commented on patch set 29 09/27/22, 20:26
Reply
I'd go with `csrf={token}` in Fluid (like in Laravel) and for the class name `CsrfToken`. Fine?RequestTokenMiddleware.php:76ReplyAckRequestTokenMiddleware.php:123ReplyAckFormViewHelper.php:181ReplyThis is checked in that particular method body, currently it's ``` if (strtolower((string)($this->arguments['method'] ?? '')) === 'get') { throw new \LogicException('Cannot apply request token for forms sent via HTTP GET', 1651775963); } ``` -
Oliver Hader uploaded patch set 30 09/28/22, 07:00
-
Oliver Hader rebased onto patch set 31 09/28/22, 07:00
-
Oliver Hader commented on patch set 31 09/28/22, 07:07
Reply
I was half way through renaming variables and classes, then I discovered the term "RequestToken" being used with backend deep-linking, e.g. "MissingRequestTokenException". I'd prefer "RequestToken", otherwise we'd have a bunch of terms for similar concepts: * RequestToken * CSRF/CsrfToken * FormProtectionToken and just $token (and we actually use it most times in URIs, but not in Forms)RequestTokenMiddleware.php:76ReplyDoneRequestTokenMiddleware.php:123ReplyDoneFormViewHelper.php:181ReplyDone -
core-ci voted on patch set 30 V -1 09/28/22, 07:17 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31633
-
core-ci voted on patch set 31 V -1 09/28/22, 07:17 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31634
-
core-ci commented on patch set 31 09/28/22, 07:40 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31634
-
Oliver Hader commented on patch set 31 09/28/22, 08:41
RequestTokenMiddleware.php:148Idiot! -
Oliver Hader uploaded patch set 32 09/28/22, 08:41
-
Oliver Hader commented on patch set 32 09/28/22, 08:43
RequestTokenMiddleware.php:148ReplyDone -
core-ci voted on patch set 32 V +1 09/28/22, 08:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31638
-
Benni Mack commented on patch set 32 09/28/22, 10:41
RequestTokenMiddleware.php:125$normalizedParams please -
Benni Mack uploaded patch set 33 09/28/22, 13:28
-
Benni Mack commented on patch set 33 CR +1 09/28/22, 13:29
RequestTokenMiddleware.php:125ReplyDone -
Benni Mack voted on patch set 33 V +1 09/28/22, 13:30
-
core-ci voted on patch set 33 V +1 09/28/22, 13:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31655
-
Stefan Bürk commented on patch set 33 09/28/22, 14:07
I'm late to the party - but have one question. See comment.SecurityAspect.php:35Do we really need this multi type declation ? If we add a "valid" flag to RequestToken, we can avoid these multitype declarations for the property and the setter/getter below. ``` $noToken = $securtyAspect->get('receivedRequestToken') === null; $tokenValid = ($securtyAspect->get('receivedRequestToken')?->isValid() ?? false); $tokenState = ($securtyAspect->get('receivedRequestToken')?->isValid() ?? null); if ($tokenState === null) { // no token provided } elseif ($tokenState === false) { // token provided, but invalid } else { // token valid } ``` What do you think ? -
Oliver Hader commented on patch set 33 09/28/22, 20:08
SecurityAspect.php:35ReplyHaving a `RequestToken::$valid` would violate the the requirement of this domain object (if there's an instance, it is complete and valid). Having an instance that is invalid requires any consumer to verify again (and again) that a particular object is valid. I personally don't see a problem in union types - which is a specific class-type and two distinct native types in this case. In case the `bool` type shall be avoided, there would be the possibility of having an explicit type for this as well. ``` interface RequestTokenInterface {} class RequestToken implements RequestTokenInterface {} class InvalidRequestToken implements RequestTokenInterface {} class SecurityAspect { protected ?RequestTokenInterface $receivedRequestToken = null; } ``` This way consumers cannot continue with a `InvalidRequestToken` since the type in signatures would be `RequestToken`. Thus, `$requestToken instanceof RequestToken` would be needed as well - like now... -
Stefan Bürk commented on patch set 33 V +1 CR +1 09/28/22, 20:43
SecurityAspect.php:35ReplyDon't like these kind of mixed type, but this should not be about personal taste. Anyway ... ack, the InvalidRequestToken extend is not that nice either. Instead a "RequestTokenResult/State" wrapper class may be more usefull .. with methods etc. Maybe something we may discuss in general some day. Let's keep it as is. -
Oliver Hader commented on patch set 33 09/28/22, 21:14
SecurityAspect.php:35ReplyAck! -
Torben Hansen commented on patch set 33 V +1 CR +1 09/29/22, 06:43
SecurityAspect.php:32Typo: "taken" -> "token"RequestToken.php:54We should move this into the try/catch and then catch the `Firebase\JWT\DomainException` and throw a `RequestTokenException` instead (which just will be logged). In the current state, a `Firebase\JWT\DomainException` is thrown, when a random string is provided as request token (might occur, when a remote user fiddles around with the `__RequestToken` parameter and JSON is malformed) -
Oliver Hader commented on patch set 33 V +2 CR +2 09/29/22, 11:25
Going to tackle Torben's comments in a separate commit... -
Oliver Hader merged patch set 34 09/29/22, 11:25
-
Oliver Hader commented on patch set 34 09/29/22, 11:54
→ the follow-up patch: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75913 -
Oliver Hader commented on patch set 34 09/29/22, 11:54
SecurityAspect.php:32ReplyDoneRequestToken.php:54ReplyDone