-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix #79413: session_create_id() fails for active sessions #5305
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
Conversation
The comment on `PS_VALIDATE_SID_FUNC(files)` is very clear that the function is supposed to return `SUCCESS` if the session already exists. So to detect a collision, we have to check for `SUCCESS`, not `FAILURE`.
If the new SID is invalid, i.e. no such session exists yet, there is no need to create a new SID. On the other hand, if such session already exists, we have to create a new SID to satisfy strict mode (actually, we would have to repeat this until we find an invalid SID).
In my opinion, we should merge this fix ASAP (ideally before the next RCs are tagged tomorrow). See also https://bugs.php.net/bug.php?id=77178#1542784582 for reasons why (function name in the following quote fixed by me):
Also, @remicollet, what do you think about merging this into PHP-7.2. From https://bugs.php.net/bug.php?id=77178#1542803132:
|
There's one more call here: Line 417 in fbe19a6
Does it also need to be flipped? |
No, that call is supposed to check for FAILURE (the session is started, and a SID is given, and this session does not yet exists, in strict mode, a new SID has to be created => prevent session fixation). |
Thanks! Applied as b510250. |
Is this going to be applied to PHP 7.2? |
…(nicolas-grekas) This PR was merged into the 3.4 branch. Discussion ---------- [HttpFoundation] workaround PHP bug in the session module | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Current tests fail after php/php-src#5305 Which itself is a patch for a bug in the session module. This PR works around the issue in older versions of PHP and fixes the tests. Commits ------- 0cbca19 [HttpFoundation] workaround PHP bug in the session module
@nicolas-grekas, that may be something to consider for @remicollet and @sgolemon. |
The comment on
PS_VALIDATE_SID_FUNC(files)
is very clear that thefunction is supposed to return
SUCCESS
if the session already exists.So to detect a collision, we have to check for
SUCCESS
, notFAILURE
.