Repository navigation
Conversation
Contributor
|
On the PR head (ef25b3a) ASan reports a heap-use-after-free here, while the base (fd3a97d) and current master are fine. The outer object has no closing <?php
class T { public function __unserialize(array $data): void {} }
class D { public function __destruct() { var_dump(unserialize('R:2;')); } }
// the closing } of the outer object is missing
var_dump(@unserialize('O:1:"T":2:{i:0;s:5:"hello";i:1;O:1:"D":0:{}'));Run with |
Member
Author
|
Ah, indeed. A failed record's data array now stays in the unserialize context until var_destroy(), like a queued one, so the destructor can no longer reach an element it already released. The same UAF was reachable before this PR when an element after the nested object is malformed; both cases are now in __unserialize_malformed_nested_destructor.phpt. |
Check the closing brace before queuing __unserialize() or __wakeup(). Incomplete object records must use the same cleanup as invalid property data, including destructor suppression. The __unserialize() data array of a failed record now stays in the unserialize context until var_destroy() instead of being released at once, so a destructor of a nested object cannot resolve a back-reference to an element the array already released.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The unserializer now checks each object's closing brace before queuing
__unserialize()or__wakeup(), so incomplete objects skip their callback and destructor. Related to #21716, which changes when already-queued callbacks are drained.