Review main Merged

86524[TASK] Don't execute PHP for URIs starting with /_assets/

Christoph Lehmann CR +2 V +2 Normal +52 −1 updated 03/29/25, 09:54

Commit message

Such URIs normally point to asset files (images, js or css).
In the case they don't exist it is not necessary to execute PHP.

At the same time, "uploads" is removed as it has no effect
anymore in current versions of TYPO3.

This only affects new installations, so a Important.rst is
added for upgrades.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Garvin Hicking +1
    • Andreas Kienast +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Garvin Hicking +1
    • Andreas Kienast +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 2735

Show 910 earlier messages
  1. Christoph Lehmann uploaded patch set 1 10/09/24, 07:46

  2. core-ci voted on patch set 1 V +1 10/09/24, 07:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67413

  3. Mathias Brodala commented on patch set 1 10/09/24, 09:33

    IMO we should add an Important RST for this for two reasons: 1. People upgrading TYPO3 should be notified that they should adjust their .htaccess 2. People intentionally handling calls to "_assets" via PHP (middleware, etc.) may see change of behavior if the .htaccess is adjusted.
  4. Garvin Hicking commented on patch set 1 10/09/24, 09:40

    Reply

    Hhhm, stopping the rewrite processing would not prevent accessing the PHP file though, or what am I missing?! Stopping the rewrite for the directory like that only prevents that no rules for missing files/dirs would be executed? (IMO while putting a PHP File in Resources/Public is something that can be dangerous, I don't think it should be prevented? It definitely would be a BC in that case IMO, not just an "Important").
  5. Mathias Brodala commented on patch set 1 10/09/24, 09:45

    Reply

    TBH I don't understand what you mean. My remarks refer strictly to the suggested change. Currently you could add e.g. a custom middleware to handle requests to "_assets". Of course, this implies that there is no physical directory with that name. After this change, requests to "_assets" are handled exclusively by Apache. If resources exist, they are delivered, if not, one will get a 404/403 from Apache. PHP/TYPO3 is not involved anymore.
  6. Garvin Hicking commented on patch set 1 10/09/24, 09:59

    Reply

    Sorry, my remark was more generally and not specifically aimed at you. I was misled by the phrasing of the patch to think that it would prevent executing .php files in the _assets/ directory. Reading it now, I can spot the difference (but it may mislead others). I personally think that for non-existing files to route back to TYPO3 has benefits, if only to trigger the custom 403/404 handling. But that's probably a matter of taste. I would just suggest to maybe adapt the title to something like: [TASK] Disable RewriteHandling for missing files in /_assets/ URIs because it's really more about disabling rewrites than "don't execute PHP"?
  7. Garvin Hicking commented on patch set 1 10/09/24, 09:59

    Reply

    (Also I agree we should add an Important RST in the case this gets applied)
  8. Stefan Bürk commented on patch set 1 CR -2 10/09/24, 10:51

    14.0 breaking. Not yet (at in no way for 12.4). Also needs auto update (silence upgrade) wth proper checks. See other comment chain for details.

    Reply

    This thange prevents that a request with a not existing resource reaches TYPO3. However, it does not prevent execution of php files within that folder in any case. That means, if a php exists and is directly executed it will still work. I would not make this change for the same reasons @mbrodala@pagemachine.de already mentioned. > Note that this change prevents reaching TYPO3 for `_assets/` in any cases, even if not existing or found It's a used practice to rewrite eventually resources (image links) in css files etc on the fly by replaceing some place holder or EXT syntax with real resolved paths. Additionally, it may make the static asset route configuration use-less if matching url has been configured with `_assets/` prefix because TYPO3 is not reached anylonger, same goes for using EXT:redirects (like custom middlewares) for it. Beside removing that ability, it does nothing really usefull. I would move that to 14.0 as part of breaking change, along with adding proper htaccess update detection/replacement (silence upgrade thing) and having a dedicated rest file for it. Would not change that now on the last days before 13LTS release - and in no way as backport for v14. In early v12 we playaed around removing the fileadmin part and allowing to let reach it TYPO3 but delayed that as that would need some other changes in FAL to be usefull. Can be added however manually on instances/deployement if really needed, but would stay away to remove this now with that "breaking" flavour.
  9. Rémy DANIEL commented on patch set 1 10/11/24, 13:30

    Adding my 2 cents here. Before TYPO3 12 and the new _assets directory, any non existing ressource triggered the Apache error page. IMHO this behavior was very good in a performance way, because php was not involved when serving the error page. Now, triggering php and TYPO3 url/error handling for a non existing _assets ressource is a new vector for DoS attack. I would love to add _assets to the RewriteRule (as typo3conf) because I don't expect anything else than serving static objects from _assets.
  10. Mathias Brodala commented on patch set 1 10/11/24, 15:23

    Reply

    I agree that it would be a sane DEFAULT shipped with TYPO3. Everyone is free to adjust his .htaccess afterwards, if he actually needs PHP/TYPO3 processing for the "_assets" URL path.
  1. Stefan Bürk commented on patch set 1 10/11/24, 16:36

    Reply

    As already said. We can discuss/make that in v14, but not yet 4 days before lts and not as v12 backport. Thus, -2 until v14 branching after lts release.
  2. Oliver Hader updated the commit message in patch set 2 V +1 10/18/24, 13:58

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  3. core-ci voted on patch set 2 V +1 10/18/24, 19:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68092

  4. Benni Mack updated the commit message in patch set 3 V +1 03/25/25, 15:31

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  5. Benni Mack commented on patch set 3 03/25/25, 15:31

    I'm fine with 13.4 - as this only affects new installations
  6. core-ci voted on patch set 3 V -1 03/25/25, 15:46 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76279

  7. Benni Mack rebased onto patch set 4 V -1 03/25/25, 16:16

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  8. core-ci voted on patch set 4 V +1 03/25/25, 16:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76293

  9. Benni Mack commented on patch set 4 CR -1 03/26/25, 12:32

    will add a RST
  10. Benni Mack uploaded patch set 5 CR -1 V +1 03/26/25, 12:55

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  11. Benni Mack uploaded patch set 6 03/26/25, 12:55

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  12. core-ci voted on patch set 5 V +1 03/26/25, 13:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76377

  13. core-ci voted on patch set 6 V +1 03/26/25, 13:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76378

  14. Georg Ringer voted on patch set 6 CR +1 V +1 03/26/25, 13:15

  15. Garvin Hicking commented on patch set 7 CR +1 V +1 03/26/25, 13:16

    Published edit on patch set 6. Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  16. Garvin Hicking commented on patch set 7 CR +1 V +1 03/26/25, 13:17

    Reply

    Done

    Reply

    I agree,
    Thanks for the RST file (applied some minor formatting and rephrasing)
  17. Benni Mack commented on patch set 7 03/26/25, 13:21

    Reply

    As discussed earlier today. It's not breaking (IMHO). If some person has a middleware fiddling around with frontend assets somewhere else, this does not break anything. Also not during upgrading, as it only touches new installations. If somebody has some custom shizzle AND upgrade to v14, nothing will happen, everything stay. Good people could read Important.rst - for this reason, I added one.
  18. Benni Mack updated the commit message in patch set 8 CR +1 V +1 03/26/25, 13:21

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  19. core-ci voted on patch set 7 V +1 03/26/25, 13:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76380

  20. Andreas Kienast voted on patch set 8 CR +1 V +1 03/26/25, 13:30

  21. Garvin Hicking voted on patch set 8 CR +1 V +1 03/26/25, 13:30

  22. core-ci voted on patch set 8 V +1 03/26/25, 13:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76382

  23. Stefan Bürk commented on patch set 8 CR +2 V +2 03/26/25, 13:56

    Reply

    Thanks for taking care of it.
  24. Stefan Bürk merged patch set 9 03/26/25, 13:57

  25. Lina Wolf commented on patch set 9 03/29/25, 09:54

    Where should this be documented? Security chapters? https://github.com/TYPO3-Documentation/Changelog-To-Doc/issues/1224