CVE-2021-41113: Cross-Site Request Forgery (CSRF) (CWE-352)
value: TYPO3 is an open source PHP based web content management system released under the GNU GPL. It has been discovered that the new TYPO3 v11 feature that allows users to create and share deep links in the backend user interface is vulnerable to cross-site-request-forgery. The impact is the same as described in TYPO3-CORE-SA-2020-006 (CVE-2020-11069). However, it is not limited to the same site context and does not require the attacker to be authenticated. In a worst case scenario, the attacker could create a new admin user account to compromise the system. To successfully carry out an attack, an attacker must trick his victim to access a compromised system. The victim must have an active session in the TYPO3 backend at that time. The following Same-Site cookie settings in $GLOBALS[TYPO3_CONF_VARS][BE][cookieSameSite] are required for an attack to be successful: SameSite=strict: malicious evil.example.org invoking TYPO3 application at good.example.org and SameSite=lax or none: malicious evil.com invoking TYPO3 application at example.org. Update your instance to TYPO3 version 11.5.0 which addresses the problem described.
CWE description: The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.
CVSS v3 base score: 8.8
Published: 2021-10-05T18:15Z
Repository: https://github.com/TYPO3/typo3
Language: PHP
Files changed: typo3/sysext/backend/Classes/Routing/RouteRedirect.php, typo3/sysext/backend/Configuration/Backend/Routes.php, typo3/sysext/core/Documentation/Changelog/11.2/Feature-93988-BackendModuleURLsReflectIntoBrowserAddressbar.rst
Commit date: 2021-10-05 13:02:10 +0200
Commit message: [SECURITY] Mitigate CSRF in backend deeplinking

This change adds a "redirect" section to disable
backend deeplinking for non-module routes by default,
and only allows for included / defined GET paramaters
for such routes.

Resolves: #94496
Releases: master
Change-Id: Iab3bcbfe42d44cd12c5748e3b0cddb4478dbe975
Security-Bulletin: TYPO3-CORE-SA-2021-014
Security-References: CVE-2021-41113
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/71437
Tested-by: Oliver Hader <oliver.hader@typo3.org>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>

Diff: diff --git a/typo3/sysext/backend/Classes/Routing/RouteRedirect.php b/typo3/sysext/backend/Classes/Routing/RouteRedirect.php
index 597941ce0c..5ac9cce5ca 100644
--- a/typo3/sysext/backend/Classes/Routing/RouteRedirect.php
+++ b/typo3/sysext/backend/Classes/Routing/RouteRedirect.php
@@ -19,10 +19,11 @@ namespace TYPO3\CMS\Backend\Routing;
 
 use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Backend\Routing\Exception\MethodNotAllowedException;
 use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException;
 use TYPO3\CMS\Backend\Routing\Exception\RouteTypeNotAllowedException;
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 
 /**
  * A value object representing redirects within Backend routing.
  */
 class RouteRedirect
@@ -131,7 +132,20 @@ class RouteRedirect
             throw new MethodNotAllowedException(
                 sprintf('"%s" cannot be redirected as it does not allow GET methods', $this->name),
                 1627407452
             );
         }
+        $settings = $route->getOption('redirect');
+        if (($settings['enable'] ?? false) !== true) {
+            throw new RouteNotFoundException(
+                sprintf('Route "%s" cannot be redirected', $this->name),
+                1627407511
+            );
+        }
+        // Only use allowed arguments, if set, otherwise no parameters are allowed
+        if (!empty($settings['parameters'])) {
+            $this->parameters = ArrayUtility::intersectRecursive($this->parameters, (array)$settings['parameters']);
+        } else {
+            $this->parameters = [];
+        }
     }
 }
diff --git a/typo3/sysext/backend/Configuration/Backend/Routes.php b/typo3/sysext/backend/Configuration/Backend/Routes.php
index 75ce4351b9..a11fdbd303 100644
--- a/typo3/sysext/backend/Configuration/Backend/Routes.php
+++ b/typo3/sysext/backend/Configuration/Backend/Routes.php
@@ -131,15 +131,27 @@ return [
 
     // Register new record
     'db_new' => [
         'path' => '/record/new',
         'target' => Controller\NewRecordController::class . '::mainAction',
+        'redirect' => [
+            'enable' => true,
+            'parameters' => [
+                'id' => true,
+            ],
+        ],
     ],
 
     'db_new_pages' => [
         'path' => '/record/new-page',
         'target' => Controller\NewRecordController::class . '::newPageAction',
+        'redirect' => [
+            'enable' => true,
+            'parameters' => [
+                'id' => true,
+            ],
+        ],
     ],
 
     // Register sort pages
     'pages_sort' => [
         'path' => '/pages/sort',
@@ -148,10 +160,16 @@ return [
 
     // Register create multiple pages
     'pages_new' => [
         'path' => '/pages/new',
         'target' => Controller\Page\NewMultiplePagesController::class . '::mainAction',
+        'redirect' => [
+            'enable' => true,
+            'parameters' => [
+                'id' => true,
+            ],
+        ],
     ],
 
     // Register new content element module (used in a modal)
     'new_content_element_wizard' => [
         'path' => '/record/content/wizard/new',
@@ -206,10 +224,16 @@ return [
      * which allows the user to edit the content of one or more database records.
      */
     'record_edit' => [
         'path' => '/record/edit',
         'target' => Controller\EditDocumentController::class . '::mainAction',
+        'redirect' => [
+            'enable' => true,
+            'parameters' => [
+                'edit' => true,
+            ],
+        ],
     ],
 
     // Thumbnails
     'thumbnails' => [
         'path' => '/thumbnails',
diff --git a/typo3/sysext/core/Documentation/Changelog/11.2/Feature-93988-BackendModuleURLsReflectIntoBrowserAddressbar.rst b/typo3/sysext/core/Documentation/Changelog/11.2/Feature-93988-BackendModuleURLsReflectIntoBrowserAddressbar.rst
index c4369fb394..3d268335da 100644
--- a/typo3/sysext/core/Documentation/Changelog/11.2/Feature-93988-BackendModuleURLsReflectIntoBrowserAddressbar.rst
+++ b/typo3/sysext/core/Documentation/Changelog/11.2/Feature-93988-BackendModuleURLsReflectIntoBrowserAddressbar.rst
@@ -23,6 +23,18 @@ components to be used as future iframe module alternatives.
 Impact
 ======
 
 Editors can share links to certain records or include these in bug reports.
 
+This feature is enabled for all modules. For non-module routes this feature
+will only work if configured via `Routes.php` by adding a `redirect` section:
+
+:php:
+    'redirect' => [
+        'enable' => true,
+        // Transferred parameters when redirecting
+        'parameters' => [
+            'my-parameter-name' => true
+        ]
+    ],
+
 .. index:: Backend, JavaScript, ext:backend

Fixed code: use TYPO3\CMS\Core\Utility\ArrayUtility;
        $settings = $route->getOption('redirect');
        if (($settings['enable'] ?? false) !== true) {
            throw new RouteNotFoundException(
                sprintf('Route "%s" cannot be redirected', $this->name),
                1627407511
            );
        }
        // Only use allowed arguments, if set, otherwise no parameters are allowed
        if (!empty($settings['parameters'])) {
            $this->parameters = ArrayUtility::intersectRecursive($this->parameters, (array)$settings['parameters']);
        } else {
            $this->parameters = [];
        }
        'redirect' => [
            'enable' => true,
            'parameters' => [
                'id' => true,
            ],
        ],
        'redirect' => [
            'enable' => true,
            'parameters' => [
                'id' => true,
            ],
        ],
        'redirect' => [
            'enable' => true,
            'parameters' => [
                'id' => true,
            ],
        ],
        'redirect' => [
            'enable' => true,
            'parameters' => [
                'edit' => true,
            ],
        ],
This feature is enabled for all modules. For non-module routes this feature
will only work if configured via `Routes.php` by adding a `redirect` section:

:php:
    'redirect' => [
        'enable' => true,
        // Transferred parameters when redirecting
        'parameters' => [
            'my-parameter-name' => true
        ]
    ],