php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80072 Cyclic unserialize in TMPVAR operand may leak
Submitted: 2020-09-07 08:53 UTC Modified: 2021-07-02 08:38 UTC
From: nikic@php.net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 8.0Git-2020-09-07 (Git) OS:
Private report: No CVE-ID: None
 [2020-09-07 08:53 UTC] nikic@php.net
Description:
------------
<?php
$s = 'O:8:"stdClass":1:{s:1:"x";r:1;}';
unserialize($s) % gc_collect_cycles();

This leaks the cyclic object, as we destroy TMPVAR operands with zval_ptr_dtor_nogc(). The unserialize() implementation manually registers a GC root for the return value, but the gc_collect_cycles() call here drops it again, because the cycle is not dead at the time of the call yet.

This is oss-fuzz #25441.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-02 08:38 UTC] nikic@php.net
Another reproducer without unserialize():

$a[]=&$a == $a=&$b > gc_collect_cycles();
 [2021-07-02 13:30 UTC] git@php.net
Automatic comment on behalf of nikic
Revision: https://github.com/php/php-src/commit/52cf7ab8a27ace6fbff60674d7aeecf4adec1bc8
Log: Fix bug #80072: Root live tmpvars after GC
 [2021-07-02 13:30 UTC] git@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Nov 28 09:03:14 2021 UTC