Skip to content

Honor use_strict_mode for SessionHandler without validateId - #23071

Open
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/session-strict-validate-master
Open

Honor use_strict_mode for SessionHandler without validateId#23071
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/session-strict-validate-master

Conversation

@iliaal

Copy link
Copy Markdown
Contributor

SessionHandler implements neither SessionUpdateTimestampHandlerInterface nor a validateId() method, so registering it leaves ps_validate_sid undefined and PS_VALIDATE_SID_FUNC(user) falls through to php_session_validate_sid, which returns SUCCESS for every id. With session.use_strict_mode=1 and session_set_save_handler(new SessionHandler, true), an attacker-supplied id is adopted instead of regenerated. Exact SessionHandler instances now delegate validation to the module they already wrap for read, write and destroy. The check is deliberately on the exact class. A subclass can override read() and write() with its own storage while inheriting the rest, and validating those against the files module is what regressed in GH-9583.

SessionHandler does not expose validateId(), so strict mode fell back to
php_session_validate_sid() and accepted unknown IDs. Delegate validation
for exact SessionHandler instances to the wrapped module. Keep the
historical behavior for subclasses, which may implement custom storage.
ClosesphpGH-23071
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@iliaal