[php-src] Issue #20566: Heap-use-after-free in Zend/zend_lazy_objects.h
| From: | amrmp | Date: | Sun, 23 Nov 2025 09:44:29 +0000 |
| Subject: | [php-src] Issue #20566: Heap-use-after-free in Zend/zend_lazy_objects.h | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-251287@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/20566
Author: amrmp
### Description
The following code:
```php
class Test {
public function __isset($x) { $GLOBALS["obj"] = 24; return true; }
public function __geo($x) { var_dump($this); return 42; }
}
$obj = new Test;
$name = "foo";
var_dump($obj->$name ??12);
var_dump($obj);
<?php
```
Resulted in this output:
```
SUMMARY: AddressSanitizer: heap-use-after-free php-src/Zend/zend_lazy_objects.h:83:10 in
zend_object_is_lazy
Shadow bytes around the buggy address:
0x0c0c7fffe470: 00 00 00 00 fa fa fa fa 00 00 00 00 00 00 00 00
0x0c0c7fffe480: fa fa fa fa 00 00 00 00 00 00 00 fa fa fa fa fa
0x0c0c7fffe490: 00 00 00 00 00 00 00 fa fa fa fa fa 00 00 00 00
0x0c0c7fffe4a0: 00 00 00 fa fa fa fa fa fd fd fd fd fd fd fd fd
0x0c0c7fffe4b0: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
=>0x0c0c7fffe4c0: fd fd fd fd fd fd fd fa fa fa fa fa fd[fd]fd fd
0x0c0c7fffe4d0: fd fd fd fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c0c7fffe4e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c0c7fffe4f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c0c7fffe500: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c0c7fffe510: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==3991640==ABORTING
```
It may sound relevant to this one: https://github.com/php/php-src/pull/19019, but
it needs triage, of course.
Commit:
```
9cd367362da5442861f30d3b41e967d641b90cbd
```
Build configuration:
```
CC="clang" CXX="clang++" CFLAGS="-fsanitize=address -g -O0"
CXXFLAGS="-fsanitize=address -g -O0" ./configure --enable-debug --enable-address-sanitizer
--disable-shared --with-pic
```
### PHP Version
```plain
PHP 8.6.0-dev (cli) (built: Nov 14 2025 10:37:56) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.6.0-dev, Copyright (c) Zend Technologies
with Zend OPcache v8.6.0-dev, Copyright (c), by Zend Technologies
```
### Operating System
Ubuntu 22.04