Skip to content

Commit 6735df1

Browse files
smalyshevJulien Pauli
authored andcommitted
Fix for bug #68710 (Use After Free Vulnerability in PHP's unserialize())
Conflicts: ext/standard/var_unserializer.c
1 parent c8bef57 commit 6735df1

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Bug #68710 Use after free vulnerability in unserialize() (bypassing the
3+
CVE-2014-8142 fix)
4+
--FILE--
5+
<?php
6+
for ($i=4; $i<100; $i++) {
7+
$m = new StdClass();
8+
9+
$u = array(1);
10+
11+
$m->aaa = array(1,2,&$u,4,5);
12+
$m->bbb = 1;
13+
$m->ccc = &$u;
14+
$m->ddd = str_repeat("A", $i);
15+
16+
$z = serialize($m);
17+
$z = str_replace("aaa", "123", $z);
18+
$z = str_replace("bbb", "123", $z);
19+
$y = unserialize($z);
20+
$z = serialize($y);
21+
}
22+
?>
23+
===DONE===
24+
--EXPECTF--
25+
===DONE===

ext/standard/var_unserializer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long
343343
} else {
344344
/* object properties should include no integers */
345345
convert_to_string(key);
346-
if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
346+
if (zend_hash_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
347347
var_push_dtor(var_hash, old_data);
348348
}
349349
zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data,

ext/standard/var_unserializer.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long
347347
} else {
348348
/* object properties should include no integers */
349349
convert_to_string(key);
350-
if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
350+
if (zend_hash_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
351351
var_push_dtor(var_hash, old_data);
352352
}
353353
zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data,

0 commit comments

Comments
 (0)