Skip to content

Commit 9b711b8

Browse files
committed
[Security] Prevent canceled remember-me cookie from being accepted
1 parent 4b419f2 commit 9b711b8

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

src/Symfony/Bundle/SecurityBundle/Tests/Functional/ClearRememberMeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testUserChangeClearsCookie()
3333
$this->assertNotNull($cookieJar->get('REMEMBERME'));
3434

3535
$client->request('GET', '/foo');
36-
$this->assertSame(200, $client->getResponse()->getStatusCode());
36+
$this->assertRedirect($client->getResponse(), '/login');
3737
$this->assertNull($cookieJar->get('REMEMBERME'));
3838
}
3939
}

src/Symfony/Bundle/SecurityBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"php": "^5.5.9|>=7.0.8",
2020
"ext-xml": "*",
2121
"symfony/config": "~3.4|~4.0",
22-
"symfony/security": "~3.4.36|~4.3.9|^4.4.1",
22+
"symfony/security": "~3.4.37|~4.3.10|^4.4.3",
2323
"symfony/dependency-injection": "^3.4.3|^4.0.3",
2424
"symfony/http-kernel": "~3.4|~4.0",
2525
"symfony/polyfill-php70": "~1.0"

src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ public function getSecret()
9999
*/
100100
final public function autoLogin(Request $request)
101101
{
102+
if (($cookie = $request->attributes->get(self::COOKIE_ATTR_NAME)) && null === $cookie->getValue()) {
103+
return null;
104+
}
105+
102106
if (null === $cookie = $request->cookies->get($this->options['name'])) {
103107
return null;
104108
}

src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ public function testAutoLoginReturnsNullWhenNoCookie()
3939
$this->assertNull($service->autoLogin(new Request()));
4040
}
4141

42+
public function testAutoLoginReturnsNullAfterLoginFail()
43+
{
44+
$service = $this->getService(null, ['name' => 'foo', 'path' => null, 'domain' => null]);
45+
46+
$request = new Request();
47+
$request->cookies->set('foo', 'foo');
48+
49+
$service->loginFail($request);
50+
$this->assertNull($service->autoLogin($request));
51+
}
52+
4253
/**
4354
* @group legacy
4455
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy