Skip to content

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

Open
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/session-cookie-attr-validation
Open

ext/session: reject cookie separators in cookie_path and cookie_domain#22925
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/session-cookie-attr-validation

Conversation

@iliaal

@iliaal iliaal commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

php_session_send_cookie() appends session.cookie_path and session.cookie_domain to the Set-Cookie header verbatim, and neither setting rejects 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, and does it in 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.

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
Sign up for free to 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