-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Recursion in class constant AST evaluation #10709
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
Labels
Comments
iluuu1994
added a commit
to iluuu1994/php-src
that referenced
this issue
Feb 26, 2023
iluuu1994
added a commit
to iluuu1994/php-src
that referenced
this issue
Feb 26, 2023
iluuu1994
added a commit
to iluuu1994/php-src
that referenced
this issue
Feb 26, 2023
iluuu1994
added a commit
to iluuu1994/php-src
that referenced
this issue
Feb 26, 2023
iluuu1994
added a commit
to iluuu1994/php-src
that referenced
this issue
Feb 27, 2023
iluuu1994
added a commit
to iluuu1994/php-src
that referenced
this issue
Feb 27, 2023
iluuu1994
added a commit
to iluuu1994/php-src
that referenced
this issue
Feb 27, 2023
iluuu1994
added a commit
to iluuu1994/php-src
that referenced
this issue
Feb 27, 2023
iluuu1994
added a commit
that referenced
this issue
Mar 6, 2023
* PHP-8.1: Fix GH-10709: UAF in recursive AST evaluation
iluuu1994
added a commit
that referenced
this issue
Mar 6, 2023
* PHP-8.2: Fix GH-10709: UAF in recursive AST evaluation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
The following code:
https://oss-fuzz.com/testcase-detail/6445949468934144
Resulted in this output:
ASAN output
But I expected this output instead:
new B()
triggers the evaluation of its constants, starting with the binary op AST. That in turn triggers the autoloader forA
, which then dumps theB::HW
constant. At that point, the outer evaluation of the constants hasn't finished, so it will try loadingB
s constants again (because the constantB::HW
still contains a constant AST).A
is now declared, so it can evaluate the constant and store it inB::HW
. When it is done, it frees the constant ASTs and returns back to the first constant evaluation. The outer evaluation continues, trying to access the now freed constant AST.This can be fixed by reusing the
IS_CONSTANT_VISITED
mechanism. That code should probably be moved tozval_update_constant_with_ctx
(or the equivalent for PHP-8.1). The code will then error and complain about recursive class constant declarations which seems reasonable.PHP Version
PHP-8.1
Operating System
No response
The text was updated successfully, but these errors were encountered: