Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6dadb96

Browse filesBrowse files
committed
bug #47368 [Security] Count remember me cookie parts before accessing the second (MatTheCat)
This PR was merged into the 5.4 branch. Discussion ---------- [Security] Count remember me cookie parts before accessing the second | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #47362 | License | MIT | Doc PR | N/A Commits ------- 90562e4 Count cookie parts before accessing the second
2 parents d70c53c + 90562e4 commit 6dadb96
Copy full SHA for 6dadb96

File tree

2 files changed

+11
-3
lines changed
Filter options

2 files changed

+11
-3
lines changed

‎src/Symfony/Component/Security/Http/RememberMe/RememberMeDetails.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/RememberMe/RememberMeDetails.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ public function __construct(string $userFqcn, string $userIdentifier, int $expir
3737
public static function fromRawCookie(string $rawCookie): self
3838
{
3939
$cookieParts = explode(self::COOKIE_DELIMITER, base64_decode($rawCookie), 4);
40-
if (false === $cookieParts[1] = base64_decode($cookieParts[1], true)) {
41-
throw new AuthenticationException('The user identifier contains a character from outside the base64 alphabet.');
42-
}
4340
if (4 !== \count($cookieParts)) {
4441
throw new AuthenticationException('The cookie contains invalid data.');
4542
}
43+
if (false === $cookieParts[1] = base64_decode($cookieParts[1], true)) {
44+
throw new AuthenticationException('The user identifier contains a character from outside the base64 alphabet.');
45+
}
4646

4747
return new static(...$cookieParts);
4848
}

‎src/Symfony/Component/Security/Http/Tests/Authenticator/RememberMeAuthenticatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Tests/Authenticator/RememberMeAuthenticatorTest.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,12 @@ public function testAuthenticateWithoutOldToken()
8989
$request = Request::create('/', 'GET', [], ['_remember_me_cookie' => base64_encode('foo:bar')]);
9090
$this->authenticator->authenticate($request);
9191
}
92+
93+
public function testAuthenticateWithTokenWithoutDelimiter()
94+
{
95+
$this->expectException(AuthenticationException::class);
96+
97+
$request = Request::create('/', 'GET', [], ['_remember_me_cookie' => 'invalid']);
98+
$this->authenticator->authenticate($request);
99+
}
92100
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.