Skip to content

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

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

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

Conversation

@iliaal

@iliaal iliaal commented Jun 14, 2026

Copy link
Copy Markdown
Owner

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.
@iliaal

iliaal commented Jun 14, 2026

Copy link
Copy Markdown
Owner Author

Submitted upstream as php#22309.

@iliaal iliaal closed this Jun 14, 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.

1 participant