78002[BUGFIX] Properly escalate if a form HMAC fails to decode
Commit message
Review
-
Code review CR +2 Done
- Benjamin Franzke +2
- Oliver Klee +1
- Garvin Hicking +1
- Torben Hansen +1
-
Verified V +2 Done
- Benjamin Franzke +2
- Oliver Klee +1
- Garvin Hicking +1
- Torben Hansen +1
- core-ci +1 CI
Issues 1
Files 3
Review log 4654
Show 2329 earlier messages
-
Thomas Hohn uploaded patch set 1 03/02/23, 09:15
-
core-ci voted on patch set 1 V +1 03/02/23, 09:22 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/38295
-
Oliver Klee voted on patch set 1 CR +1 03/02/23, 09:38
-
Christian Kuhn commented on patch set 1 03/02/23, 17:13
-
Christian Kuhn commented on patch set 1 CR -1 03/02/23, 17:17
MvcPropertyMappingConfigurationService.php:142Replyactually, i'll -1 this for now - we need a satisfying answer on who/why a valid hmac'ed payload does not decode as expected. -
Nikita Hovratov uploaded patch set 2
CR +1V +103/02/23, 17:33 -
Nikita Hovratov commented on patch set 2 03/02/23, 17:36
MvcPropertyMappingConfigurationService.php:142ReplyHey, I just added another patchset with a test. You are right, finding the origin of the issue is important to understand better what is going on. The issue speaks of "attacks", so it looks like "__trustedProperties" are altered with. -
core-ci voted on patch set 2 V +1 03/02/23, 17:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/38316
-
Thomas Hohn commented on patch set 2 03/02/23, 17:53
MvcPropertyMappingConfigurationService.php:142ReplyMaybe the correct behaviour would indeed be to throw an exception instead. If the encryptionKey has been exposed or reused for several sites I guess you would be able to come by the first checks and decoding the data could fail if the payload isn't correct? -
Thomas Hohn commented on patch set 2 03/02/23, 18:26
MvcPropertyMappingConfigurationService.php:142ReplyI has asked for more information.. -
Christian Kuhn voted on patch set 2 CR -1 03/02/23, 19:21
-
Thomas Hohn rebased onto patch set 3
CR -1V +103/06/23, 05:41 -
core-ci voted on patch set 3 V +1 03/06/23, 05:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/38510
-
Benni Mack updated the commit message in patch set 4
V +105/03/23, 09:33 -
core-ci voted on patch set 4 V +1 05/03/23, 10:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41429
-
Oliver Klee commented on patch set 4 07/16/23, 08:34
How should we continue here? -
Thomas Hohn commented on patch set 4 07/16/23, 16:32
Reply
We never received any feedback on the case. Based on the comment from @lolli - I suggest we abandon the patch and close the ticket -
Oliver Klee commented on patch set 4 07/17/23, 07:17
Reply
Yeah, makes sense. I'd still like to keep the new test, maybe in a separate change. What do you think, @Nikita? -
Benjamin Franzke commented on patch set 4 07/17/23, 08:51
MvcPropertyMappingConfigurationService.php:142ReplyThe issue was reported against TYPO3 v10, which uses json encoded trusted properties. TYPO3 v9 used (un)serialized content for extbase trusted properrties. In combination with stuff like config.sendCacheHeaders it is likely that warning occured after the update, when a (user)cached page has been visited that contained serialized trusted properties. json_decoding the output of unseralize leads to NULL, so I guess this is the most likely case how an "invalid" payload got signed. And yes, throwing an exception would be appropriate. -
Oliver Klee commented on patch set 4 07/17/23, 10:57
MvcPropertyMappingConfigurationService.php:142ReplyI agree. Throwing an exception looks like the cleanest solution to me. -
Oliver Klee uploaded patch set 5
V +108/05/23, 20:32 -
Oliver Klee commented on patch set 5 V +1 CR +1 08/05/23, 20:32
MvcPropertyMappingConfigurationService.php:142ReplyDone -
Oliver Klee commented on patch set 5 08/05/23, 20:33
Reply
(Resolving as we now at least have a proper exception if the decoding fails.) -
core-ci voted on patch set 5 V +1 08/05/23, 20:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45127
-
Torben Hansen uploaded patch set 6
CR +1V +108/06/23, 17:26 -
Torben Hansen commented on patch set 6 08/06/23, 17:29
I updated the patch, so the new exception code is in IGNORED_EXCEPTION_CODES, since we do not want the sys_log to be filled with exceptions caused by scenarios, which are caused due to external modification or other behavior, a TYPO3 administrator has no influence on. -
Oliver Klee commented on patch set 6 V +1 CR +1 08/06/23, 17:29
Thanks, Torben! -
core-ci voted on patch set 6 V +1 08/06/23, 17:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/45155
-
Markus Klein voted on patch set 6 V +1 CR +1 09/22/23, 08:44
-
Guido Schmechel voted on patch set 6 CR +1 09/28/23, 19:27
-
Garvin Hicking commented on patch set 6 10/11/23, 13:56
My personal gut feeling is to better gate/harden such a check, even if superflous, than to let it stand and follow function flow, if/when json_decode could fail. However, I'm not sure if there's a way to have a valid hmac with an empty trustedProperties string, which would be json_decoded to an empty response, and not an empty array, and thus halt the function flow. Other than that I added a note about whether the exception should be unique, or not (currently it's a bit of both).MvcPropertyMappingConfigurationService.php:147I'd suggest to either use the same Exception code AND description at this point (if it's about security, to not reveal to an attacker, that they have progressed on step further). OR to actually rename the content of the Exception, if it shall be unique, to something like "The HMAC of the form could not be utilized.", so that it can be better distinguished. -
Torben Hansen commented on patch set 6 10/11/23, 14:09
MvcPropertyMappingConfigurationService.php:147ReplyAttacker will only see the exception code/message, if website runs in debug mode (which it should not). We should use different codes here, so it is clear from the log files, which error occurred. -
Garvin Hicking commented on patch set 6 10/11/23, 14:41
MvcPropertyMappingConfigurationService.php:147ReplyOf course, you're right. I usually work in development so I forget that "normal people" don't see this ;-) However, if there's any chance that a developer will see this exception without malicious intent, it would help to make the error message unique, not only the exception code. To make it easier to google. Hey, maybe those people end up reading this review, Hi! -
Thomas Hohn uploaded patch set 7
CR +1V +110/12/23, 04:03 -
Thomas Hohn commented on patch set 7 10/12/23, 04:05
MvcPropertyMappingConfigurationService.php:147ReplyDone -
core-ci voted on patch set 7 V +1 10/12/23, 04:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47698
-
Garvin Hicking voted on patch set 7 V +1 CR +1 10/12/23, 05:21
-
Torben Hansen voted on patch set 7 V +1 CR +1 10/12/23, 06:05
-
Oliver Klee voted on patch set 7 V +1 CR +1 10/12/23, 08:11
-
Markus Klein voted on patch set 7 V +1 CR +1 10/12/23, 12:48
-
Benjamin Franzke uploaded patch set 8
CR +1V +111/10/23, 09:14 -
Benjamin Franzke commented on patch set 8 11/10/23, 09:14
MvcPropertyMappingConfigurationService.php:147ReplyThanks Torben, but we only want the error to be log-skipped if it is actually old-data, not new-invalid-structure. I've added a heuristic to detect old serialized input. -
Benjamin Franzke voted on patch set 8 V +1 CR +1 11/10/23, 09:15
-
core-ci voted on patch set 8 V +1 11/10/23, 09:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48783
-
Oliver Klee voted on patch set 8 V +1 CR +1 11/10/23, 09:33
-
Torben Hansen voted on patch set 8 V +1 CR +1 11/10/23, 09:38
-
Garvin Hicking voted on patch set 8 V +1 CR +1 11/10/23, 10:31
-
Oliver Klee voted on patch set 8 V 0 CR 0 11/10/23, 12:04
-
Oliver Klee commented on patch set 8 11/10/23, 12:05
MvcPropertyMappingConfigurationService.php:147I think we also need to have an `is_string` check to avoid type errors if e.g., the trusted properties JSON fails to decode for some reason (which would result in `null`). -
Benjamin Franzke commented on patch set 8 11/10/23, 12:20
MvcPropertyMappingConfigurationService.php:147Reply`str_starts_with` is performed on `$encodedTrustedProperties`, not on the json result. That means it is guaranteed to be a `string` (that's the return type of `validateAndStripHmac()`) -
Benjamin Franzke voted on patch set 8 V +2 CR +2 11/10/23, 12:48
-
Benjamin Franzke merged patch set 9 11/10/23, 12:48
-
Oliver Klee commented on patch set 9 11/10/23, 12:56
MvcPropertyMappingConfigurationService.php:147ReplyAh, I see. Thanks! -
Oliver Klee commented on patch set 9 V +1 CR +1 11/10/23, 12:56
(Post +1s)
MvcPropertyMappingConfigurationService.php:142