Review main Merged Breaking

91419[!!!][BUGFIX] Allow rootless paths in URI implementation

Helmut Hummel CR +2 V +2 Normal +204 −30 updated 11/20/25, 11:18

Commit message

The UriInterface implementation incorporates a flaw, when
creating a string from the complete URI, when it comes
to rootless paths (paths without preceding slash).

Other than stated in the method comment, rootless paths are prefixed
with a slash, even without authority (host name) being present
in the URI. This violates rfc3986.

Additionally, when fixing this, another change is required
to be done and that is prefixing a rootless path with ./
when the first (or only) path segment contains a colon (:).

This is required, so that the colon can not interpreted as
scheme separator.

See:
https://datatracker.ietf.org/doc/html/rfc3986#page-26:~:text=A%20path%20segment%20that%20contains%20a%20colon%20character%20(e.g.%2C%20%22this%3Athat%22)

As the required code changes (not only tests) show, we consider
this to be a breaking change and thus it only is introduced
in TYPO3 v14, despite being a bugfix.

Review

  • Code review CR +2 Done
    • Helmut Hummel +2
    • Benjamin Franzke +1
    • Christian Kuhn +1
    • Benni Mack +1
  • Verified V +2 Done
    • Helmut Hummel +2
    • Benjamin Franzke +1
    • Oliver Klee +1
    • Christian Kuhn +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 13

Review log 2438

Show 713 earlier messages
  1. Helmut Hummel uploaded patch set 1 11/04/25, 09:34

  2. core-ci voted on patch set 1 V -1 11/04/25, 09:51 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/88445

  3. Helmut Hummel uploaded patch set 2 V -1 11/12/25, 22:00

  4. Helmut Hummel marked it work in progress 11/12/25, 22:00

  5. core-ci voted on patch set 2 V -1 11/12/25, 22:14 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89408

  6. Helmut Hummel uploaded patch set 3 V -1 11/12/25, 22:16

  7. Helmut Hummel uploaded patch set 4 11/12/25, 22:25

  8. core-ci voted on patch set 3 V -1 11/12/25, 22:31 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89409

  9. core-ci voted on patch set 4 V -1 11/12/25, 22:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89410

  10. Helmut Hummel uploaded patch set 5 V -1 11/12/25, 23:05

  11. core-ci voted on patch set 5 V -1 11/12/25, 23:18 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89411

  12. Helmut Hummel uploaded patch set 6 V -1 11/12/25, 23:37

  13. core-ci voted on patch set 6 V -1 11/12/25, 23:47 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89412

  1. Helmut Hummel uploaded patch set 7 V -1 11/13/25, 07:52

  2. core-ci voted on patch set 7 V +1 11/13/25, 07:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89431

  3. Helmut Hummel uploaded patch set 8 V +1 11/13/25, 10:17

  4. core-ci voted on patch set 8 V +1 11/13/25, 10:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89458

  5. Helmut Hummel uploaded patch set 9 V +1 11/13/25, 10:32

  6. core-ci voted on patch set 9 V +1 11/13/25, 10:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89462

  7. Helmut Hummel uploaded patch set 10 V +1 11/13/25, 11:10

  8. core-ci voted on patch set 10 V -1 11/13/25, 11:17 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89471

  9. Helmut Hummel uploaded patch set 11 V -1 11/13/25, 11:43

  10. Helmut Hummel marked it ready for review 11/13/25, 11:43

  11. Helmut Hummel uploaded patch set 12 11/13/25, 11:48

  12. core-ci voted on patch set 11 V -1 11/13/25, 11:53 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89477

  13. Helmut Hummel uploaded patch set 13 11/13/25, 11:58

  14. core-ci voted on patch set 12 V -1 11/13/25, 12:00 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89480

  15. core-ci voted on patch set 13 V +1 11/13/25, 12:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89485

  16. Helmut Hummel rebased onto patch set 14 V +1 11/14/25, 07:26

  17. core-ci voted on patch set 14 V +1 11/14/25, 07:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89654

  18. Oliver Klee voted on patch set 14 V +1 11/14/25, 08:57

  19. Benni Mack voted on patch set 14 CR +1 V +1 11/18/25, 18:07

  20. Christian Kuhn voted on patch set 14 CR +1 V +1 11/18/25, 22:49

  21. Benjamin Franzke commented on patch set 14 CR -1 11/19/25, 09:30

    UriTest.php:118

    This comment is still true and must not be removed, please. The assertions are security relevant and were introduced with https://review.typo3.org/c/Packages/TYPO3.CMS/+/87743 Invalid host names that use parser deviation between PHP and Browsers to mimic as a relative path must not be generated rootless – see https://forge.typo3.org/issues/105170 for details. This can't be merged as is, I'm sorry. A possibility would to to assert a relative path ``` ./evil.tld%5C@host.tld ``` instead. I'm currently unsure if we also need `./www.example.com`, maybe @oliver.hader@typo3.org knows. I'm sorry that this is blocking, in general I think it would be better to have a designated API to create relative URIs based on two absolute references, basically like: https://github.com/composer/composer/blob/2.9.1/src/Composer/Util/Filesystem.php#L466 ``` function findShortestUri(UriInterface $from, UriInterface $to): string ``` Which is less surprising and hopefully less prone to errors, because the usage of the API needs to take context into account, *where* this relative reference is used, since it is easy to generate a relative reference, but it becomes combersome if we use them in another path context.
  22. Helmut Hummel commented on patch set 14 11/19/25, 12:41

    UriTest.php:118 Reply

    Hm, ok. While I understand the attack scenario as outlined with the examples in https://forge.typo3.org/issues/105170 I don't see such scenario with "domainalike" relative paths. I tried send a redirect header for Chromium with 'www.example.com' and the browser redirected to https://my-testdomain.test/www.example.com exactly as I would have expected. Do you have more resources than the mentioned ticket that explain attack vectors with such relative URIs that resemble domain names?
  23. Benjamin Franzke commented on patch set 14 CR +1 V +1 11/19/25, 13:33

    UriTest.php:118 Reply

    No other resources that I know of, only a PDF that is attached to the mentioned issue, which is easy to overlook, but I guess you already found that. I've also tried to reproduce the problems and agree with you that there is no issue to be detected for relative redirects, given that you preceded the relative path by a dot-segment when it contains a colon – thanks for that. Since these test assertions for relative URIs were not reported, but derived by us, it seems we did wrong with these test assertion. Sorry for the trouble, I think we're good to merge here. There a "feeling" left, that we could see issues, whenever "evil.tld\@host.tld" would be "autolinked" to "https://evil.tld\@host.tld"; by whatever postprocessing, but I can not imagine/build up a case, so I refrain from seeing that feeling as a blocker.
  24. Helmut Hummel commented on patch set 14 CR +2 V +2 11/20/25, 11:18

    UriTest.php:118 Reply

    > whenever "evil.tld\@host.tld" would be "autolinked" to "https://evil.tld\@host.tld"; I would argue, that "autolinking" would be fine in case the result is represented as URI object again, which would then be caught by our validation code. Using an object representation of an URI, converting it to a string and then manipulating this string, should imho be considered as security flaw in the calling code, not the URI imoplementation. I also triple checked UruValue and could not come up with any issue related to this subclass and will merge now. Thanks for taking a very close look into this and your overall analysis.
  25. Helmut Hummel merged patch set 15 11/20/25, 11:18