Review main Merged

64492[BUGFIX] Allow multiple referrer types in backend main route

Oliver Hader CR +2 V +2 Normal +238 −8 updated 05/18/20, 08:09

Commit message

With TYPO3-CORE-SA-2020-006 (SSRF via XSS) a strict referrer handling
has been introduced to avoid the TYPO3 backend being called from other
non same-origin locations. In case a HTTP referrer header was empty
the system tried to refresh the view - otherwise the request was
denied completely.

It turned out that this scenario was probably too strict, disabling
feature `security.backend.enforceReferrer` was the only work-around
for site administrators.

This change adds new options for handling referrers in backend routes:
* refresh-empty (existed already): refresh in case referrer is empty
* refresh-same-site: refresh in case referrer is on same site, like
  `https://example.org/?eID=auth` calling `https://example.org/typo3/`
* refresh-always: refresh always in case there is not valid referrer

TYPO3's main backend route is using `refresh-always` now to be more
relaxed on handling same-site and cross-site referrers as well.

The term "refreshing" relates to trigger a reload in the browser to
get the referrer of the current location. This still block direct
CSRF/SSRF requests since the refreshing HTML instructions are
delivered back to the client. Besides that, cross-site requests are
covered by the `same-site` cookie policy, and existing CSRF tokens.

Review

  • Code review CR +2 Done
    • Richard Haeser +2
    • Susi Moog +1
  • Verified V +2 Done
    • Richard Haeser +2
    • Susi Moog +1
    • TYPO3com +1 CI

Issues 1

Files 3

Review log 2023

  1. Oliver Hader uploaded patch set 1 05/14/20, 15:04

  2. TYPO3com voted on patch set 1 V +1 05/14/20, 15:15 Completed build in 11m 28s on Thu, 14 May, 03:15 PM Test Summary: 73780 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3378

  3. Markus Klein updated the commit message in patch set 2 05/14/20, 15:25

  4. TYPO3com voted on patch set 2 V +1 05/14/20, 15:37 Completed build in 12m 53s on Thu, 14 May, 03:37 PM Test Summary: 73780 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3380

  5. Oliver Hader commented on patch set 2 05/15/20, 08:40

    When testing, please make sure clear route caches (either "clear all caches" or "typo3temp/var/cache/")
  6. Susi Moog commented on patch set 2 05/15/20, 09:30

    ReferrerEnforcer.php:72

    should we add additional braces here? from reading alone I'm not sure whether that's meant as || ... whole line or || ( ... ) && ( .. ) || (...
  7. Susi Moog commented on patch set 2 05/15/20, 09:56

    ReferrerEnforcerTest.php:58

    and is "exmaple" on purpose or by accident? ;)
  8. David Rellstab voted on patch set 2 CR +1 05/15/20, 10:00

  9. Susi Moog voted on patch set 2 V +1 CR +1 05/15/20, 11:16

  10. Susi Moog commented on patch set 2 05/15/20, 11:16

    aside from the "readability remarks" it's working as expected.
  11. Oliver Hader commented on patch set 2 05/15/20, 11:19

    ReferrerEnforcer.php:72 Reply Unresolved

    I'm fine with adding braces here - see https://www.php.net/manual/en/language.operators.precedence.php `($referrerType & self::TYPE_REFERRER_EMPTY && in_array('refresh-empty', $flags, true))`
  12. Riny van Tiggelen voted on patch set 2 V +1 05/15/20, 12:08

  13. Richard Vollebregt commented on patch set 2 CR +1 05/15/20, 12:08

    > Patch Set 2: > > (1 comment)
  14. Richard Vollebregt wrote 05/15/20, 12:08

    Removed Code-Review+1 by Richard Vollebregt <richard.vollebregt@maxserv.com>
  15. Richard Vollebregt voted on patch set 2 V +1 05/15/20, 12:09

  16. Susi Moog commented on patch set 2 CR -1 05/15/20, 13:35

    will add the braces and correct the typo - just a minute :)
  17. Susi Moog uploaded patch set 3 05/15/20, 13:37

  18. Susi Moog voted on patch set 3 V +1 CR +1 05/15/20, 13:38

  19. Richard Haeser voted on patch set 3 V +1 CR +1 05/15/20, 13:40

  20. Oliver Hader commented on patch set 3 05/15/20, 13:48

    ReferrerEnforcerTest.php:58 Reply Unresolved

    Accident... should be "example", but in since I copied it correctly, the tests are at least correct ;-)
  21. TYPO3com voted on patch set 3 V +1 05/15/20, 13:53 Completed build in 15m 40s on Fri, 15 May, 01:53 PM Test Summary: 73781 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3394

  22. Richard Haeser voted on patch set 3 V +2 CR +2 05/18/20, 08:09

  23. Richard Haeser merged patch set 4 05/18/20, 08:09