Skip to content

[session] abort strict-mode re-creation when create_sid fails - #286

Open
iliaal wants to merge 2 commits into
PHP-8.4from
fix/session-strict-recreate-abort-84
Open

[session] abort strict-mode re-creation when create_sid fails#286
iliaal wants to merge 2 commits into
PHP-8.4from
fix/session-strict-recreate-abort-84

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

When session_start() runs in strict mode and the save handler's validateId() rejects the incoming ID, the re-creation branch released PS(id) and called s_create_sid(), but on failure it silently substituted a freshly generated internal ID instead of aborting like the primary no-ID branch does; if that fallback generation also failed, PS(id) stayed NULL and initialization continued with it, skipping s_close(). Even in the recoverable case, reset_id() already ran side effects such as the Set-Cookie header and the SID constant for a session that then failed to start because the pending exception broke s_read(). This makes handler create_sid() failures fatal in strict-mode re-creation, mirroring the primary branch's php_session_abort()/error/FAILURE handling, and adds a regression test asserting that no SID artifact survives a failed start. Sibling call sites audited: session_regenerate_id() and session_create_id() already NULL-check with their own error paths, mod_mm's strict re-create returns FAILURE into the initialize abort path.

iliaal added 2 commits August 24, 2026 13:30
When a save handler rejects the session ID in strict mode, the
re-created ID must be non-NULL or initialization must fail; previously a
failing s_create_sid() was silently papered over by generating a fresh
internal ID and continuing, running reset_id() side effects (Set-Cookie,
SID constant) for a session that then failed to start, and proceeding
with a NULL PS(id) if the fallback generation also failed. Mirror the
primary no-ID branch's abort/error handling; sibling call sites audited:
session_regenerate_id() collision loop and session_create_id() already
NULL-check with their own error paths, mod_mm's strict re-create returns
FAILURE into the initialize abort path.
After the successful s_close()/s_open() pair, a failing s_create_sid()
reset the status and threw without closing the freshly opened handler,
leaving mod_data open until request shutdown and double-opening it on
the next start; the collision-retry failure path in the same function
already closes. Mirror that close on the null-id path. Sibling audit:
session_create_id() breaks out to its own error path, mod_mm's strict
re-create returns FAILURE into the initialize abort path, and the
strict-mode re-create branch of php_session_initialize() now aborts via
the preceding commit.
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