]> granicus.if.org Git - php/commitdiff
Fix for bug #68710 (Use After Free Vulnerability in PHP's unserialize())
authorStanislav Malyshev <stas@php.net>
Fri, 2 Jan 2015 00:19:05 +0000 (16:19 -0800)
committerStanislav Malyshev <stas@php.net>
Fri, 2 Jan 2015 00:19:05 +0000 (16:19 -0800)
NEWS
ext/standard/tests/strings/bug68710.phpt [new file with mode: 0644]
ext/standard/var_unserializer.c
ext/standard/var_unserializer.re

diff --git a/NEWS b/NEWS
index fa57ef3161c3d77d060bbb8ec5414c80bc618045..f789a9258e356ff59600cf6425690b2d21b1a821 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,10 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 20?? PHP 5.4.37
+- Core:
+  . Fix bug #68710 (Use after free vulnerability in unserialize(), incomplete
+    fix for #68594). (Stefan Esser)
+
 - CGI:
   . Fix bug #68618 (out of bounds read crashes php-cgi). (Stas)
 
diff --git a/ext/standard/tests/strings/bug68710.phpt b/ext/standard/tests/strings/bug68710.phpt
new file mode 100644 (file)
index 0000000..729a120
--- /dev/null
@@ -0,0 +1,25 @@
+--TEST--
+Bug #68710 Use after free vulnerability in unserialize() (bypassing the
+CVE-2014-8142 fix)
+--FILE--
+<?php
+for ($i=4; $i<100; $i++) {
+    $m = new StdClass();
+
+    $u = array(1);
+
+    $m->aaa = array(1,2,&$u,4,5);
+    $m->bbb = 1;
+    $m->ccc = &$u;
+    $m->ddd = str_repeat("A", $i);
+
+    $z = serialize($m);
+    $z = str_replace("aaa", "123", $z);
+    $z = str_replace("bbb", "123", $z);
+    $y = unserialize($z);
+    $z = serialize($y);
+}
+?>
+===DONE===
+--EXPECTF--
+===DONE===
index a12d2fa24e35fd474e1440682ee49411d9ce38a9..f114080b86e5c7e05746f03457b0a2d9245d5c6b 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.7.5 on Thu Dec 11 19:26:19 2014 */
+/* Generated by re2c 0.13.7.5 on Thu Jan  1 14:43:18 2015 */
 #line 1 "ext/standard/var_unserializer.re"
 /*
   +----------------------------------------------------------------------+
@@ -343,7 +343,7 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long
                } else {
                        /* object properties should include no integers */
                        convert_to_string(key);
-                       if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
+                       if (zend_hash_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
                                var_push_dtor(var_hash, old_data);
                        }
                        zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data,
index 4cf1d1083286ab6c10d65c548770bfdeec83944c..f04fc74c312e82823f3c7ebb51178c3b74250d2c 100644 (file)
@@ -347,7 +347,7 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long
                } else {
                        /* object properties should include no integers */
                        convert_to_string(key);
-                       if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
+                       if (zend_hash_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
                                var_push_dtor(var_hash, old_data);
                        }
                        zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data,