Issue Bug Closed

#102727CanonicalizationUtility does not remove unknown parameters

Moritz Karbaum 12/29/23, 13:55 updated 04/18/25, 10:24

Description

In TYPO3 11 (and 10), when I request a page with some random parameter, it will be kept in the canonical URL:

I open this URL https://project.ddev.site/some/page/?test=1 and will get a page with the canonical URL https://project.ddev.site/some/page/?test=1&cHash=cd723811a5eabde4293bd326995d91e1

Since test is not a TYPO3 core parameter and was also not added to $GLOBALS['TYPO3_CONF_VARS']['FE']['additionalCanonicalizedUrlParameters'] I would expect it to be dropped from the canonical URL.

As it stands currently, the first request will create the canonical URL with whatever parameters, and all further requests will receive the cached page with the wrong canonical URL.

As far as I can tell, TYPO3\CMS\Frontend\Utility\CanonicalizationUtility is comparing parameters relevant for cHash calculation with the URL parameters – which always match.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 7

  1. Torben Hansen commented and changed status New Needs Feedback 12/30/23, 13:21

    I think this problem has been adressed in TYPO3-PSA-2021-003 – see https://typo3.org/security/advisory/typo3-psa-2021-003

    So most likely, the problem has been fixed in TYPO3 v12 only, since it is a breaking change which might cause unwanted side effects for existing TYPO3 websites. For TYPO3 v11 or below, please use https://extensions.typo3.org/extension/trusted_url_params to mitigate the problem.

    Can you please test and report back, if installing the trusted_url_params extension fixes your problem.

  2. Moritz Karbaum commented 01/05/24, 07:39

    Thank you for the hint!

    I’ve installed trusted_url_params, and it doesn’t seem to have any adverse effects.

  3. Riccardo De Contardi commented 02/09/24, 08:22

    @Moritz Karbaum thank you for your feedback; do you think that this issue could be closed?

    Thanks again

  4. Marco Dinnbier commented 03/14/24, 14:28

    Hi,

    i’ve faced the same issue. In my opinion, the issue is triggered by a wrong comparison in CanonicalizationUtility, see https://github.com/TYPO3/typo3/blob/53024568affb67b551588e66cacbcf0e7cc6245b/typo3/sysext/frontend/Classes/Utility/CanonicalizationUtility.php#L56

    $urlParameters and $cHashArray are both associative arrays and being compared with array_diff, which compares only values. This should be replaced by array_diff_assoc, which compares the whole array or maybe better array_diff_key.

    Best regards,
    Marco

  5. Riccardo De Contardi changed status Needs Feedback New 04/28/24, 20:42

  6. Torben Hansen commented 04/18/25, 10:22

    I’m unable to reproduce the problem in v12 and v13, so the issue can most likely be closed.

  7. Georg Ringer changed status New Closed 04/18/25, 10:24