Review main Merged

67655[FEATURE] Restrict Backend Routes to specified HTTP methods

Benni Mack CR +2 V +2 Normal +218 −7 updated 02/08/21, 21:16

Commit message

Because TYPO3 Backend is based on the symfony/routing
components, it is now possible to also limit a route to only
e.g. a POST request by defining allowed methods in the
route registration.

This allows for more secure route behaviour, e.g. routes
that update the system, should semantically using POST requests.

Similarly this way, future non-HTML-routes in the TYPO3 Backend
could be set up (e.g. for REST APIs), utilizing the BE routing
directly.

For the time being, the password-forgot form
is now only allowed for POST methods, effectively
hardening this feature.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Oli Bartsch +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Oli Bartsch +1
    • TYPO3com +1 CI
    • core-ci +1 CI

Issues 1

Files 9

Review log 1325

  1. Benni Mack uploaded patch set 1 02/05/21, 20:19

  2. TYPO3com voted on patch set 1 V -1 02/05/21, 20:26 Completed build in 07m 15s on Fri, 5 Feb, 08:26 PM Test Summary: 32585 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9318

  3. Benni Mack updated the commit message in patch set 2 02/06/21, 21:56

  4. TYPO3com voted on patch set 2 V -1 02/06/21, 22:04 Completed build in 07m 49s on Sat, 6 Feb, 10:04 PM Test Summary: 4 of 32826 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9338

  5. Benni Mack uploaded patch set 3 02/06/21, 22:22

  6. TYPO3com voted on patch set 3 V +1 02/06/21, 22:30 Completed build in 08m 39s on Sat, 6 Feb, 10:30 PM Test Summary: 32597 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9339

  7. core-ci voted on patch set 3 V +1 02/06/21, 22:32 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/454

  8. Benni Mack uploaded patch set 4 02/08/21, 06:45

  9. TYPO3com voted on patch set 4 V -1 02/08/21, 06:52 Completed build in 07m 36s on Mon, 8 Feb, 06:52 AM Test Summary: 4 of 32838 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9341

  10. core-ci voted on patch set 4 V +1 02/08/21, 06:55 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/470

  11. TYPO3com commented on patch set 4 02/08/21, 06:59 Completed build in 22m 01s on Mon, 8 Feb, 06:59 AM Test Summary: 4 of 32838 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9341

  12. TYPO3com commented on patch set 4 02/08/21, 09:51 Completed build in 3h 28m 04s on Mon, 8 Feb, 09:51 AM Test Summary: 5 of 32838 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9341

  13. Benni Mack rebased onto patch set 5 02/08/21, 16:41

  14. TYPO3com voted on patch set 5 V +1 02/08/21, 16:49 Completed build in 07m 54s on Mon, 8 Feb, 04:49 PM Test Summary: 32587 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9356

  15. core-ci voted on patch set 5 V +1 02/08/21, 16:52 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/487

  16. Benjamin Franzke commented on patch set 5 CR -1 02/08/21, 17:01

    Route.php:92

    Let's just use `array $methods` here. The caller can easily call `setMethods([$method])`. (Yea I know, symfony allows this as well, but I guess they also already regret that).
  17. Benjamin Franzke commented on patch set 5 02/08/21, 17:38

    If we trust the router, we should remove conditions [1] that are (now) always false in the (now) restricted actions in ./typo3/sysext/backend/Classes/Controller/LoginController.php [1] something like: $request->getMethod() !== 'POST'

    Router.php:136

    I think, for example a GET call to /typo3/login/password-reset/initiate-reset, should *not* result in a 500 HTTP response code (because of TYPO3\CMS\Backend\Routing\Exception\MethodNotAllowedException) when called via GET, but rather be translated that into a 400 Bad Request. That means we need to catch this exception in the BackendRouteInitialization middleware.
  18. Benjamin Franzke commented on patch set 5 02/08/21, 17:44

    ServiceProvider.php:115

    We should also unset $options['methods']. I guess it was not intended to push the methods into options, right? (that would be redundant)
  19. Benjamin Franzke uploaded patch set 6 02/08/21, 17:50

  20. Benjamin Franzke commented on patch set 6 02/08/21, 17:50

    Reply

    Done

    Route.php:92 Reply

    Done

    Router.php:136 Reply

    Done

    ServiceProvider.php:115 Reply

    Done
  21. TYPO3com voted on patch set 6 V +1 02/08/21, 17:59 Completed build in 08m 19s on Mon, 8 Feb, 05:59 PM Test Summary: 32587 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9357

  22. core-ci voted on patch set 6 V +1 02/08/21, 18:01 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/492

  23. Oli Bartsch voted on patch set 6 V +1 CR +1 02/08/21, 21:10

  24. Benjamin Franzke voted on patch set 6 V +2 CR +2 02/08/21, 21:15

  25. Benjamin Franzke merged patch set 7 02/08/21, 21:16