test(session): parity guard for regenerate mid-request (tina4-php#253) - #184
Merged
Merged
Conversation
…kie (#253) tina4stack/tina4-php#253 was a PHP-only defect in the native $_SESSION bridge under the socket server: a mid-request session_regenerate_id() rotated the id but never sent the new id to the client, so the session was lost next request. Python's own session subsystem was never affected — core/server._stage_session_save emits a Set-Cookie on every request that saved a session, so a rotated id always reaches the client. A bug reported against one framework almost always exists in the others, so it earns a permanent regression test here too: if the serve path ever stopped propagating a rotated id, this goes red. Proven on the wire against a REAL child server (no mocks), and verified green against a real file store AND real Redis. Co-Authored-By: Claude Opus 4.8 <[email protected]> Co-Authored-By: Tina4 <[email protected]> Signed-off-by: Andre van Zuydam <[email protected]>
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.
Parity guard for tina4stack/tina4-php#253.
The upstream bug (PHP only)
Under
tina4 serve(the socket server), PHP's native$_SESSIONbridge re-emitted the session cookie only when the session was new at the start of the request. A mid-requestsession_regenerate_id()— the standard session-fixation defence on login — rotated the id after that check, so noSet-Cookiewent out and the session was lost on the next request.Why Python was already correct
$_SESSION/session_regenerate_id()are PHP language features with no analog in Python. Python's own session subsystem was never affected:core/server._stage_session_saveemits aSet-Cookieon every request that saved a session, so a rotated id always reaches the client. A bug reported against one framework almost always exists in the others, so it earns a permanent regression test here too — if the serve path ever stopped propagating a rotated id, this goes red.Proof
Wire-level test against a real child server (no mocks): request 1 writes the session and rotates its id via
request.session.regenerate(); request 2 replays the rotated cookie and must find the same data under the new id. Verified green against a real file store and real Redis.Cross-links tina4stack/tina4-php#253.
🤖 Generated with Claude Code