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

Skip to content

Commit fd19bd7

Browse files
bug #35239 [Security\Http] Prevent canceled remember-me cookie from being accepted (chalasr)
This PR was merged into the 3.4 branch. Discussion ---------- [Security\Http] Prevent canceled remember-me cookie from being accepted | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #35198 | License | MIT | Doc PR | - `RememberMeServices::autoLogin()` only checks that the cookie exists in `$request->cookies` while `loginFail()` only alter `$request->attributes` (which allows child implementations to read the canceled cookie for e.g. removing a persistent one). This makes `autoLogin()` checks for `request->attributes` first, which fixes the linked issue. Failure expected on deps=high build. Commits ------- 9b711b8 [Security] Prevent canceled remember-me cookie from being accepted
2 parents 2f38a5a + 9b711b8 commit fd19bd7

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)