|
|
af9dc8 |
From b585a3aed7880a5fa5c18e2b838fc96f40e075bd Mon Sep 17 00:00:00 2001
|
|
|
af9dc8 |
From: Stanislav Malyshev <stas@php.net>
|
|
|
af9dc8 |
Date: Thu, 1 Jan 2015 16:19:05 -0800
|
|
|
af9dc8 |
Subject: [PATCH] Fix for bug #68710 (Use After Free Vulnerability in PHP's
|
|
|
af9dc8 |
unserialize())
|
|
|
af9dc8 |
|
|
|
af9dc8 |
---
|
|
|
af9dc8 |
NEWS | 4 ++++
|
|
|
af9dc8 |
ext/standard/tests/strings/bug68710.phpt | 25 +++++++++++++++++++++++++
|
|
|
af9dc8 |
ext/standard/var_unserializer.c | 4 ++--
|
|
|
af9dc8 |
ext/standard/var_unserializer.re | 2 +-
|
|
|
af9dc8 |
4 files changed, 32 insertions(+), 3 deletions(-)
|
|
|
af9dc8 |
create mode 100644 ext/standard/tests/strings/bug68710.phpt
|
|
|
af9dc8 |
|
|
|
af9dc8 |
diff --git a/ext/standard/tests/strings/bug68710.phpt b/ext/standard/tests/strings/bug68710.phpt
|
|
|
af9dc8 |
new file mode 100644
|
|
|
af9dc8 |
index 0000000..729a120
|
|
|
af9dc8 |
--- /dev/null
|
|
|
af9dc8 |
+++ b/ext/standard/tests/strings/bug68710.phpt
|
|
|
af9dc8 |
@@ -0,0 +1,25 @@
|
|
|
af9dc8 |
+--TEST--
|
|
|
af9dc8 |
+Bug #68710 Use after free vulnerability in unserialize() (bypassing the
|
|
|
af9dc8 |
+CVE-2014-8142 fix)
|
|
|
af9dc8 |
+--FILE--
|
|
|
af9dc8 |
+
|
|
|
af9dc8 |
+for ($i=4; $i<100; $i++) {
|
|
|
af9dc8 |
+ $m = new StdClass();
|
|
|
af9dc8 |
+
|
|
|
af9dc8 |
+ $u = array(1);
|
|
|
af9dc8 |
+
|
|
|
af9dc8 |
+ $m->aaa = array(1,2,&$u,4,5);
|
|
|
af9dc8 |
+ $m->bbb = 1;
|
|
|
af9dc8 |
+ $m->ccc = &$;;
|
|
|
af9dc8 |
+ $m->ddd = str_repeat("A", $i);
|
|
|
af9dc8 |
+
|
|
|
af9dc8 |
+ $z = serialize($m);
|
|
|
af9dc8 |
+ $z = str_replace("aaa", "123", $z);
|
|
|
af9dc8 |
+ $z = str_replace("bbb", "123", $z);
|
|
|
af9dc8 |
+ $y = unserialize($z);
|
|
|
af9dc8 |
+ $z = serialize($y);
|
|
|
af9dc8 |
+}
|
|
|
af9dc8 |
+?>
|
|
|
af9dc8 |
+===DONE===
|
|
|
af9dc8 |
+--EXPECTF--
|
|
|
af9dc8 |
+===DONE===
|
|
|
af9dc8 |
diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c
|
|
|
af9dc8 |
index a12d2fa..f114080 100644
|
|
|
af9dc8 |
--- a/ext/standard/var_unserializer.c
|
|
|
af9dc8 |
+++ b/ext/standard/var_unserializer.c
|
|
|
af9dc8 |
@@ -309,7 +309,7 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long
|
|
|
af9dc8 |
} else {
|
|
|
af9dc8 |
/* object properties should include no integers */
|
|
|
af9dc8 |
convert_to_string(key);
|
|
|
af9dc8 |
- if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
|
|
|
af9dc8 |
+ if (zend_hash_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
|
|
|
af9dc8 |
var_push_dtor(var_hash, old_data);
|
|
|
af9dc8 |
}
|
|
|
af9dc8 |
zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data,
|
|
|
af9dc8 |
diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re
|
|
|
af9dc8 |
index 4cf1d10..f04fc74 100644
|
|
|
af9dc8 |
--- a/ext/standard/var_unserializer.re
|
|
|
af9dc8 |
+++ b/ext/standard/var_unserializer.re
|
|
|
af9dc8 |
@@ -315,7 +315,7 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long
|
|
|
af9dc8 |
} else {
|
|
|
af9dc8 |
/* object properties should include no integers */
|
|
|
af9dc8 |
convert_to_string(key);
|
|
|
af9dc8 |
- if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
|
|
|
af9dc8 |
+ if (zend_hash_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
|
|
|
af9dc8 |
var_push_dtor(var_hash, old_data);
|
|
|
af9dc8 |
}
|
|
|
af9dc8 |
zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data,
|
|
|
af9dc8 |
--
|
|
|
af9dc8 |
2.1.4
|
|
|
af9dc8 |
|