Skip to content

Fix zend_string leak on case-variant duplicate setcookie() options#22309

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/setcookie-option-leak
Open

Fix zend_string leak on case-variant duplicate setcookie() options#22309
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/setcookie-option-leak

Conversation

@iliaal

@iliaal iliaal commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

php_head_parse_cookie_options_array() matches option keys case insensitively, but array keys are case sensitive, so an option given twice differing only in case ('path' and 'Path') fetched the second string over the first without releasing it, leaking a zend_string per call. Release any value already stored before fetching the next one.

setcookie('n', 'v', ['path' => '/a', 'Path' => '/b']); // leaks one zend_string; same for domain/Domain, samesite/SameSite

php_head_parse_cookie_options_array() matches option keys case
insensitively, but array keys are case sensitive, so a duplicate
differing only in case (e.g. "path" and "Path") overwrote the
previously fetched path/domain/samesite string without releasing it.
Release any value already stored before fetching the next one.
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