Skip to content

Fix GH-12392: Segmentation fault on SoapClient::__getTypes #12409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Oct 10, 2023

There are two issues:

  • UAF because the hashmap resized while being iterated over, yet the local variables used internally in the macros are not updated.
  • The hashmap being iterated over is modified: entries are deleted after other entries have been added. This causes the deletion to fail sometimes because indices of buckets have shifted.

Fix it by using a while loop iteration and HashPosition position tracker instead.

NOTE Issue exists on PHP 8.1 too, I got a segfault too. But is much harder to trigger. The test file reproduces the issue reliably on PHP 8.2 and up. If you can't reproduce, try 8.2 with ASAN.

@nielsdos nielsdos linked an issue Oct 10, 2023 that may be closed by this pull request
There are two issues:
- UAF because the hashmap resized while being iterated over, yet the local
  variables used internally in the macros are not updated.
- The hashmap being iterated over is modified: entries are deleted after
  other entries have been added. This causes the deletion to fail sometimes
  because indices of buckets have shifted.

Fix it by using a while loop iteration and HashPosition position tracker
instead.
Issue exists on PHP 8.1 too, but is much harder to trigger.
The test file reproduces the issue reliably on PHP 8.2 and up.
@nielsdos nielsdos force-pushed the soap-segfault-1-8.1 branch from 2b9b67b to cca9385 Compare October 10, 2023 22:19
@nielsdos nielsdos requested a review from dstogov October 10, 2023 22:26
@nielsdos nielsdos closed this in 7e4a323 Oct 11, 2023
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.

Segmentation fault on SoapClient::__getTypes
2 participants