Skip to content

ext/spl: SplDoublyLinkedList::serialize() use-after-free on element r… - #23388

Closed
devnexen wants to merge 1 commit into
php:masterfrom
devnexen:gh23385
Closed

ext/spl: SplDoublyLinkedList::serialize() use-after-free on element r…#23388
devnexen wants to merge 1 commit into
php:masterfrom
devnexen:gh23385

Conversation

@devnexen

Copy link
Copy Markdown
Member

…emoval.

Fix #23385

The serialization loop passed php_var_serialize() a pointer into the list element itself, so a userland __serialize() unsetting that entry freed both the element and its payload while the serializer was still walking them. Serialize a copy of the element data instead, which outlives the callback.

…emoval.

Fix php#23385

The serialization loop passed php_var_serialize() a pointer into the list
element itself, so a userland __serialize() unsetting that entry freed both
the element and its payload while the serializer was still walking them.
Serialize a copy of the element data instead, which outlives the callback.
@LamentXU123

Copy link
Copy Markdown
Member

@devnexen There are already a PR #23387 :)

@devnexen

devnexen commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

I saw it but I assigned it to myself prior but also his fix is not correct (spl part at least).

@ndossche ndossche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit unfortunate, re-entrancy is always annoying in PHP, but it is what it is...
Fix is fine. Please deal with closing the other PR upon merging, thx.

@devnexen devnexen closed this in daf0765 Sep 12, 2026
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.

Use-after-free in SplDoublyLinkedList::serialize()

3 participants