-
Notifications
You must be signed in to change notification settings - Fork 653
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SECURITY] Avoid storing plain session identifier in $USER->uc
`AbstractUserAuthentication::$uc['moduleSessionID']` still stored plain session identifier, which has been replaced by corresponding HMAC. Resolves: #93359 Releases: master, 11.1, 10.4, 9.5 Change-Id: I920b8d3b364c249d2ec3a6deb42e141e5a1b8ff7 Security-Bulletin: TYPO3-CORE-SA-2021-006 Security-References: CVE-2021-21339 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/68439 Tested-by: Oliver Hader <oliver.hader@typo3.org> Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
- Loading branch information
Showing
3 changed files
with
141 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
typo3/sysext/core/Tests/Functional/Authentication/AbstractUserAuthenticationTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
namespace TYPO3\CMS\Core\Tests\Functional\Authentication; | ||
|
||
use TYPO3\CMS\Core\Session\UserSession; | ||
use TYPO3\CMS\Core\Tests\Functional\Authentication\Fixtures\AnyUserAuthentication; | ||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; | ||
|
||
class AbstractUserAuthenticationTest extends FunctionalTestCase | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $sessionId; | ||
|
||
/** | ||
* @var AnyUserAuthentication | ||
*/ | ||
private $subject; | ||
|
||
/** | ||
* @var UserSession | ||
*/ | ||
private $userSession; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '12345'; | ||
$this->sessionId = bin2hex(random_bytes(20)); | ||
$this->userSession = UserSession::createNonFixated($this->sessionId); | ||
$this->subject = new AnyUserAuthentication($this->userSession); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
unset($this->sessionId, $this->userSession, $this->subject); | ||
unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']); | ||
parent::tearDown(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function pushModuleDataDoesNotRevealPlainSessionId(): void | ||
{ | ||
$this->subject->pushModuleData(self::class, true); | ||
self::assertNotContains($this->sessionId, $this->subject->uc['moduleSessionID']); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getModuleDataResolvesHashedSessionId(): void | ||
{ | ||
$this->subject->pushModuleData(self::class, true); | ||
self::assertTrue($this->subject->getModuleData(self::class)); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getModuleDataFallsBackToPlainSessionId(): void | ||
{ | ||
$this->subject->uc['moduleData'][self::class] = true; | ||
$this->subject->uc['moduleSessionID'][self::class] = $this->sessionId; | ||
self::assertTrue($this->subject->getModuleData(self::class)); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
typo3/sysext/core/Tests/Functional/Authentication/Fixtures/AnyUserAuthentication.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
namespace TYPO3\CMS\Core\Tests\Functional\Authentication\Fixtures; | ||
|
||
use TYPO3\CMS\Core\Authentication\AbstractUserAuthentication; | ||
use TYPO3\CMS\Core\Session\UserSession; | ||
|
||
class AnyUserAuthentication extends AbstractUserAuthentication | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
public $uc = []; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $loginType = 'ANY'; | ||
|
||
public function __construct(UserSession $userSession) | ||
{ | ||
parent::__construct(); | ||
$this->userSession = $userSession; | ||
} | ||
} |