Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Security] Avoid failing when PersistentRememberMeHandler handles a malformed cookie #60379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,12 @@ public function clearRememberMeCookie(): void
return;
}

$rememberMeDetails = RememberMeDetails::fromRawCookie($cookie);
try {
$rememberMeDetails = RememberMeDetails::fromRawCookie($cookie);
} catch (AuthenticationException) {
// malformed cookie should not fail the response and can be simply ignored
return;
}
[$series] = explode(':', $rememberMeDetails->getValue());
$this->tokenProvider->deleteTokenBySeries($series);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ public function testClearRememberMeCookie()
$this->assertNull($cookie->getValue());
}

public function testClearRememberMeCookieMalformedCookie()
{
$this->tokenProvider->expects($this->exactly(0))
->method('deleteTokenBySeries');

$this->request->cookies->set('REMEMBERME', 'malformed');

$this->handler->clearRememberMeCookie();

$this->assertTrue($this->request->attributes->has(ResponseListener::COOKIE_ATTR_NAME));

/** @var Cookie $cookie */
$cookie = $this->request->attributes->get(ResponseListener::COOKIE_ATTR_NAME);
$this->assertNull($cookie->getValue());
}

public function testConsumeRememberMeCookieValid()
{
$this->tokenProvider->expects($this->any())
Expand Down