You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
implode() / join(): Use-After-Free via Stringable::__toString() Array Mutation #23204
implode() iterates over an array's arData using ZEND_HASH_FOREACH_VAL without incrementing the array's reference count. When a Stringable object's __toString() is called during iteration, it can nullify the array, freeing arData while the loop pointer still references it.
==641665==ERROR: AddressSanitizer: heap-use-after-free on address 0x7ab10ede4640 at pc 0x55fdef4aa314 bp 0x7ffc139481d0 sp 0x7ffc139481c8
READ of size 1 at 0x7ab10ede4640 thread T0
#0 0x55fdef4aa313 in zval_get_type /home/ilutov/Developer/php-src/Zend/zend_types.h:685
#1 0x55fdef4bfd8b in php_implode /home/ilutov/Developer/php-src/ext/standard/string.c:946
#2 0x55fdef4c20db in zflf_implode_2 /home/ilutov/Developer/php-src/ext/standard/string.c:1088
#3 0x55fdefc87f4c in ZEND_FRAMELESS_ICALL_2_SPEC_HANDLER /home/ilutov/Developer/php-src/Zend/zend_vm_execute.h:3899
#4 0x55fdeff006fa in execute_ex /home/ilutov/Developer/php-src/Zend/zend_vm_execute.h:110924
Activity
Credit the reporter in the phpGH-23204 test
Credit e1abrador and assert the exception class in the phpGH-23204 test
Fix GH-23204: use-after-free when __toString() destroys an array argu…
Merge branch 'PHP-8.5'
Merge branch 'PHP-8.4' into PHP-8.5
Merge pull request #1 from digitsflow/tests/frameless-implode-mutation