Skip to content

[session] Close save handler before re-initializing an active session - #261

Open
iliaal wants to merge 1 commit into
PHP-8.4from
fix/session-reset-close-84
Open

[session] Close save handler before re-initializing an active session#261
iliaal wants to merge 1 commit into
PHP-8.4from
fix/session-reset-close-84

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

php_session_initialize() could run with a session already active, through session_reset() or rfc1867 upload progress, invoking the save handler open() again with no intervening close(), leaking the first handler instance and breaking userland handlers that track state per open/close pair. The initialize path now aborts via php_session_abort(), which closes the handler, before reopening. php_session_start() already returns early while active, and the strict-mode create_sid fallback relies on the php_session_reset_id() failure guard. A new test asserts the open/read/close/open/read sequence.

php_session_initialize() now aborts an already-active session (closing
the save handler) before reopening it, so session_reset() no longer
calls open() twice with no close(). Sibling audit: php_session_start()
returns early while a session is active; the strict-mode create_sid
fallback leaves the close to the existing php_session_reset_id()
failure guard, which already calls php_session_abort(); the rfc1867
update/cleanup callbacks are covered by the same new guard.
@iliaal iliaal closed this Aug 24, 2026
@iliaal iliaal reopened this Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant