fix: reset session state when session ext is not linked at build time - #2523
Merged
Conversation
frankenphp_reset_session_state() clears PS(id) between worker requests so a session id cannot bleed across concurrent clients. That function is guarded by HAVE_PHP_SESSION, defined only when the session extension is visible at FrankenPHP compile time. When PHP ships session as a shared or out-of-tree module, HAVE_PHP_SESSION is undefined and the reset is compiled out. Session still works at runtime, but PS(id) survives the request boundary. Since session_start() reads the request cookie only when PS(id) is NULL, a worker reuses the previous request's id and can hand one client another client's session id. Fall back to resetting the session module through the module registry in that build configuration so the per-request cleanup always runs. Fixes GHSA-v3ph-cgqh-r8p5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resets the PHP
sessionmodule between worker requests when the session extension is not visible at FrankenPHP compile time (i.e. loaded as a shared module), so a session id cannot bleed across concurrent clients.When
HAVE_PHP_SESSIONis undefined,frankenphp_reset_session_state()is compiled out andPS(id)survived the request boundary;session_start()then ignored the request cookie and reused the previous id. The module is now reset through the registry in that build configuration. Statically-linked builds are unchanged.See GHSA-v3ph-cgqh-r8p5.