Skip to content

Fix GH-23332: ArrayObject iterator saturation leads to UAF - #23399

Closed
luizmenos wants to merge 1 commit into
php:PHP-8.4from
luizmenos:fix/gh-23332
Closed

Fix GH-23332: ArrayObject iterator saturation leads to UAF#23399
luizmenos wants to merge 1 commit into
php:PHP-8.4from
luizmenos:fix/gh-23332

Conversation

@luizmenos

Copy link
Copy Markdown

This fixes #23332

Before decrementing the iterator count, zend_hash_iterator_pos_ex() checked the overflow state of the wrong hash table. The check used the new hash table (ht), while the count was decremented on the iterator's current hash table (iter->ht).

When the current hash table's iterator count was saturated, this could make the count inconsistent and eventually lead to a use-after-free.

@iliaal

iliaal commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

The fix looks correct, I came up with the same one (iliaal#243)

One bit of feedback is the issue is not SPL specific, so the test can be inside Zend/ and not depend on SPL

Also, this should be based on 8.4 branch not just master

@luizmenos
luizmenos changed the base branch from master to PHP-8.4 August 21, 2026 13:33
@luizmenos

Copy link
Copy Markdown
Author

@iliaal thanks for your feedback! Since your PR iliaal#243 provides a more comprehensive fix i'll just close this 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.

Saturation of ArrayObject iterator leads to UAF

2 participants