#93100ExtbasePluginEnhancer produces unnecessary cHash
Description
The ExtbasePluginEnhancer produces a cHash parameter, besides that it is not needed, because all parameters have been mapped.
I think the issue lies in the inflateParameters function, that is setting an empty namespace parameter before the check, if the enhancer is needed at all, leading to a garbage value that messes up the remainingQueryParameters check later on.
Reviews 2
Related issues 2
History 1324
-
Gerrit Code Review pushed patch set 1 for master to change 67176 status
NewUnder Review 12/17/20, 15:11 -
Jonas Eberle commented 12/17/20, 15:20
-
B. Kausch commented 01/07/21, 10:09
I would like to see that fixed soon. These hashes does not look good in a prod environment ;)
Here is an example for an routeEnhancer, which will produce a cHash:
routeEnhancers: EventForm: type: Extbase extension: SomeExtension plugin: Eventform routes: - routePath: '/edit/{editCode}' _controller: 'Event::edit' _arguments: {'editCode': 'editCode'} defaultController: 'Event::new' requirements: editCode: '[A-Z0-9]{15}'When I build an Uri for the edit action with a correct editCode, an cHash is prepended. I don’t see any reason why…
-
Jonas Eberle commented 01/07/21, 13:51
B. Kausch wrote in #note-3:
> I would like to see that fixed soon. These hashes does not look good in a prod environment ;)You could help by testing the patch linked in the first post.
> When I build an Uri for the edit action with a correct editCode, an cHash is prepended. I don’t see any reason why…
Maybe this is to be expected if the value space is as big as yours (34^15). There is a limit somewhere of 10000, at least for the StaticRangeMapper (https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/core/Classes/Routing/PageRouter.php#L566) – does it apply here, too?
-
Michael Stopp commented 03/31/21, 09:20
> Maybe this is to be expected if the value space is as big as yours (34^15). There is a limit somewhere of 10000, at least for the StaticRangeMapper (https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/core/Classes/Routing/PageRouter.php#L566) – does it apply here, too?
Well, does it? Can someone with in-depth knowledge shed light on this? Because if it were true, it would explain many similar cases I had, where I just couldn’t get rid of the cHash parameter. For example if you have a personalized token in the URL, it is by definition unique and adding an extra cHash just makes the URL ugly.
I always found the official documentation lacking in specificity:
> If the requirements are too loose, a URL signature parameter (“cHash”) is added to the end of the URL which cannot be removed.
Ok, but when are the requirements “too loose”? If the 10000 limit applies here as well, it would be a very helpful information and should be mentioned in the documentation. And if not: there must be some criteria that defines, whether a cHash gets added or not.
-
Gerrit Code Review pushed patch set 2 for master to change 67176 10/08/21, 07:58
-
Oliver Hader commented 10/20/21, 09:22
Can those having problems with it please share their configuration (partially available already) AND some examples of how links are build, what are the input parameters/values? Only this way it would be possible to see how it’s used and understand the problem. Thanks.
Besides that, the configuration provided at https://forge.typo3.org/issues/93100#note-3 does not contain any “static aspect mapper” (see https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Routing/AdvancedRoutingConfiguration.html#aspects) to avoid cache-flooding – for instance
[A-Z0-9]{15}is 36^15 combinations and possible cache entries for that – which is a lot more than default limit of 10,000. In order to avoid cache-flooding, the cHash parameter is added.As an alternative I see two possibilities – given that
editCodeis somehow a random (PRNG) value:a) Find a way to ensure
editCodevalue has been generated by the system (and was not injected from the outside)+ actual editCode: 0123456789abcde + extend with signature: 691e962069233fe1cbaf1618e49fb287f1f001a4 + new signed editCode: 0123456789abcde691e962069233fe1cbaf1618e49fb287f1f001a4
- create new aspect mapper (example https://github.com/TYPO3/typo3/blob/master/typo3/sysext/core/Classes/Routing/Aspect/StaticValueMapper.php)
- that static(!) mapper shall ensure that the first 15 characters in
editCodehave a valid signature
// !!! UNTESTED SOURCE CODE !!! class MyEditCodeMapper implements StaticMappableAspectInterface, \Countable { public function __construct(array $settings) {} public function count(): int { return 1; // use this with care and only if your application can verify the parameter signature!!! } public function generate(string $value): ?string { // appends HMAC-SHA1 to given plain value // when generation a route return $value . GeneralUtility::hmac($value, __CLASS__); } public function resolve(string $value): ?string { if (!preg_match('#^(.+{15})(.+{40})$#', $value, $matches) { // did not match expected format (15 chars + 40 chars signature) return null; } $expectedHash = GeneralUtility::hmac($matches[1], __CLASS__); if ($expectedHash === $matches[2]) { // signature is valid, return/extract first 15 characters (the initial payload) return $matches[1]; } // signature did not match, return nothing (`null`) return null; } }b) disable cache & use custom mapper
- not the suggested way, but simpler
- still: it’s dirty, a hack, a work-around, you don’t win any price with that, it’s ugly
- disable cache for page holding the application (the plugin)
- use custom static aspect mapper (like above) that just pass the values (and tricks the system)
public function count(): int { return 1; }(this disables the cache-flooding protection mechanism – be aware of that)public function generate(string $value): ?string { return $value; }public function resolve(string $value): ?string { return $value; }
-
Oliver Hader changed status
Under ReviewNeeds Feedback Tags pending-close 10/20/21, 11:33 -
Oliver Hader commented 01/10/22, 19:42
Just came to this issue again… it seems this actual can be a feature, that allows to declare a particular route variable is “static”.
e.g.
... routes: - routePath: '/edit/{editCode}' _controller: 'Event::edit' _arguments: {'editCode': 'editCode'} # in case requirement for a particular variable is defined, # allow to declare it as "static" as well... # (avoiding to use a superfluous mapper for that) isStatic: editCode: true requirements: editCode: '[A-Z0-9]{15}' -
Oliver Hader changed tracker
BugFeature TYPO3 Version10Tagspending-close03/21/22, 14:15 -
Gerrit Code Review pushed patch set 1 for main to change 74016 status
Needs FeedbackUnder Review 03/22/22, 12:50 -
Oliver Hader changed Related to #92355 11/03/22, 14:21
-
Gerrit Code Review pushed patch set 2 for main to change 74016 11/10/22, 12:16
-
Oliver Hader changed assigned to Oliver Hader 11/12/22, 09:52
-
Gerrit Code Review pushed patch set 3 for main to change 74016 03/14/24, 20:40
-
Gerrit Code Review pushed patch set 4 for main to change 74016 03/14/24, 20:47
-
Gerrit Code Review pushed patch set 5 for main to change 74016 03/14/24, 20:52
-
Gerrit Code Review pushed patch set 6 for main to change 74016 03/15/24, 08:29
-
Oliver Hader changed Related to #103844 05/15/24, 16:46
-
Gerrit Code Review pushed patch set 7 for main to change 74016 08/06/24, 12:37
-
Gerrit Code Review pushed patch set 8 for main to change 74016 08/06/24, 15:43
-
Gerrit Code Review pushed patch set 9 for main to change 74016 08/06/24, 19:29
-
Oliver Hader commented and changed status
Under ReviewResolved done0 %100 % 08/06/24, 20:20Applied in changeset commit:973015bc20f5c9ba7189a9b693fc2cdc8de2df97.
-
Benni Mack changed status
ResolvedClosed 10/15/24, 09:30
Could you add an example on how to test? It doesn’t seem to happen in all circumstances, does it?