-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
PersistentRememberMeHandler - race condition in returned cookies #42343
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
Comments
Ok, it looks like it's not exactly what happens, and I need a bit more time to understand before I reopen it again. But something certainly does not work as expected. |
Okay, I found what exactly happens and updated it. |
/cc @wouterj |
Hey, thanks for your report! |
It is still relevant. |
Hey, thanks for your report! |
I have found a workaround, it's explained in the first post. |
We have fixed this issue somehow - not sure if it was done in #46760 or only as a workaround on our end, maybe @heiglandreas knows. |
@Seldaek okay, I personally would prefer solution I provided above (less code and more sense to me), but it's a personal choice, neither is "better" from the technical perspective. Nonetheless I take it as "it's fixed now", thank you for letting me know, I finally can remove the monkey-patch from my projects. |
…the second consequent request Close symfony#42343 Fix symfony#46760
…the second consequent request Close symfony#42343 Fix symfony#46760
…ond consequent request (Ivan Kurnosov) This PR was merged into the 5.4 branch. Discussion ---------- [Security] Fix valid remember-me token exposure to the second consequent request Close #42343 Fix #46760 | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #42343, Fix #46760 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the latest branch. - For new features, provide some code snippets to help understand usage. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> #46760 PR together with a fix produces a security vulnerability when a malicious actor may get a **new and valid** remember me token if makes a request right after the legit user. Commits ------- 62ceded Bug #42343 [Security] Fix valid remember-me token exposure to the second consequent request
* 5.4: [HttpClient] Fix computing retry delay when using RetryableHttpClient [Uid] Fix validating UUID variant bits [Validator][UID] Stop to first ULID format violation [Bridge] Fix mkdir() race condition in ProxyCacheWarmer [Cache] update readme Bug #42343 [Security] Fix valid remember-me token exposure to the second consequent request Prevent exception if request stack is empty Psr18Client ignore invalid HTTP headers skip a transient test on AppVeyor
…ond consequent request Close symfony/symfony#42343 Fix symfony/symfony#46760
* 6.0: [HttpClient] Fix computing retry delay when using RetryableHttpClient [Uid] Fix validating UUID variant bits [Validator][UID] Stop to first ULID format violation [Bridge] Fix mkdir() race condition in ProxyCacheWarmer [Cache] update readme Bug #42343 [Security] Fix valid remember-me token exposure to the second consequent request Prevent exception if request stack is empty Psr18Client ignore invalid HTTP headers skip a transient test on AppVeyor
* 6.1: [HttpClient] Fix computing retry delay when using RetryableHttpClient [Uid] Fix validating UUID variant bits [Validator][UID] Stop to first ULID format violation [Bridge] Fix mkdir() race condition in ProxyCacheWarmer [Cache] update readme Bug #42343 [Security] Fix valid remember-me token exposure to the second consequent request Prevent exception if request stack is empty Psr18Client ignore invalid HTTP headers skip a transient test on AppVeyor
Symfony version(s) affected: 5.3.6
Description
This bug was originally raised at #28314 and (almost) fixed in #41175
The current implementation creates the cookie in this line
symfony/src/Symfony/Component/Security/Http/RememberMe/PersistentRememberMeHandler.php
Line 100 in 4876967
The problem with that line is that it creates a race condition between 2 concurrent requests (which #28314 was originally about):
So the chronology is:
Set-Cookie
Now the browser looks fine, but it contains the remember-me token with not actual value, because the second request, which has lost the race - re-set the cookie value to the old one.
How to reproduce
appendOnly
- ensure you clear it.Now the session is lost and in the logs you can read
This token was already used. The account is possibly compromised
.Possible Solution
The cookie should only be returned if the new token value has been generated.
eg:
Additional context
/cc @Seldaek
The text was updated successfully, but these errors were encountered: