Skip to content

ext/session: reject cookie separators in cookie_path and cookie_domain - #199

Closed
iliaal wants to merge 3 commits into
masterfrom
fix/session-cookie-attr-validation
Closed

ext/session: reject cookie separators in cookie_path and cookie_domain#199
iliaal wants to merge 3 commits into
masterfrom
fix/session-cookie-attr-validation

Conversation

@iliaal

@iliaal iliaal commented Jul 29, 2026

Copy link
Copy Markdown
Owner

php_session_send_cookie() appends session.cookie_path and session.cookie_domain to the Set-Cookie header verbatim, and neither setting rejected the characters that terminate a cookie attribute, so an application can append its own Domain, Path, HttpOnly, Secure or SameSite. session_set_cookie_params(['path' => '/; Domain=evil.example']) emits Set-Cookie: PHPSESSID=<id>; path=/; Domain=evil.example. This applies the byte set setcookie() already enforces on its $path and $domain options, through the ini handler so that both session_set_cookie_params() and a direct ini_set() are covered.

Master only, since it starts rejecting configuration that is accepted today. UPGRADING carries a note next to the existing entry about NUL bytes in the same two settings. session.cache_limiter keeps the old handler, as separators are not meaningful there.

Report UTF-8/UTF-16 conversion failures from Collator sort comparisons through
the intl error mechanism.

Previously, these paths emitted a warning and continued with an empty string.

Keep the input array unchanged when sorting cannot complete, preserve the
active collator state across nested sorts, and stop invoking further
comparisons after a conversion failure.

Co-authored-by: David CARLIER <devnexen@gmail.com>
@iliaal
iliaal force-pushed the fix/session-cookie-attr-validation branch from 25abbb5 to d44ce46 Compare July 29, 2026 16:47
@iliaal
iliaal force-pushed the fix/session-cookie-attr-validation branch from d44ce46 to 8404a77 Compare July 29, 2026 18:00
php_session_send_cookie() appends session.cookie_path and
session.cookie_domain to the Set-Cookie header verbatim, and neither
setting rejected the separators that terminate a cookie attribute. An
application could therefore append its own Domain, Path, HttpOnly,
Secure, or SameSite attribute through either value. Apply the character
set setcookie() already enforces on its $path and $domain options.

Closes phpGH-22925
@iliaal
iliaal force-pushed the fix/session-cookie-attr-validation branch from 8404a77 to 54a0a18 Compare July 29, 2026 18:02
@iliaal

iliaal commented Jul 29, 2026

Copy link
Copy Markdown
Owner Author

Promoted upstream as php#22925.

@iliaal iliaal closed this Jul 29, 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.

2 participants