com php-src: Add additional serialize tests for fixed bugs: ext/standard/tests/serialize/bug69425.phpt ext/standard/tests/serialize/bug70513.phpt
ext/standard/tests/serialize/bug72731.phpt
| From: | Nikita Popov | Date: | Mon, 16 Jan 2017 12:24:13 +0000 |
| Subject: | com php-src: Add additional serialize tests for fixed bugs: ext/standard/tests/serialize/bug69425.phpt ext/standard/tests/serialize/bug70513.phpt ext/standard/tests/serialize/bug72731.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96750@lists.php.net to get a copy of this message | ||
Commit: 6477bb724e0c4e95dfc8f315cac4b7e7a692b0f8
Author: Nikita Popov <nikic@php.net> Mon, 16 Jan 2017 13:24:13 +0100
Parents: 50b38322b96416b0a5609591a52178f6100768da
Branches: PHP-5.6 PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6477bb724e0c4e95dfc8f315cac4b7e7a692b0f8
Log:
Add additional serialize tests for fixed bugs
These have been fixed as a side-effect of the delayed __wakeup
patch.
Changed paths:
A ext/standard/tests/serialize/bug69425.phpt
A ext/standard/tests/serialize/bug70513.phpt
A ext/standard/tests/serialize/bug72731.phpt
Diff:
diff --git a/ext/standard/tests/serialize/bug69425.phpt b/ext/standard/tests/serialize/bug69425.phpt
new file mode 100644
index 0000000..bfa8b9b
--- /dev/null
+++ b/ext/standard/tests/serialize/bug69425.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Bug #69425: Use After Free in unserialize()
+--FILE--
+<?php
+
+// POC 1
+class test
+{
+ var $ryat;
+
+ function __wakeup()
+ {
+ $this->ryat = 1;
+ }
+}
+
+$data =
unserialize('a:2:{i:0;O:4:"test":1:{s:4:"ryat";R:1;}i:1;i:2;}');
+var_dump($data);
+
+// POC 2
+$data =
unserialize('a:2:{i:0;O:12:"DateInterval":1:{s:1:"y";R:1;}i:1;i:2;}');
+var_dump($data);
+
+?>
+--EXPECT--
+int(1)
+array(2) {
+ [0]=>
+ object(DateInterval)#1 (15) {
+ ["y"]=>
+ int(-1)
+ ["m"]=>
+ int(-1)
+ ["d"]=>
+ int(-1)
+ ["h"]=>
+ int(-1)
+ ["i"]=>
+ int(-1)
+ ["s"]=>
+ int(-1)
+ ["weekday"]=>
+ int(-1)
+ ["weekday_behavior"]=>
+ int(-1)
+ ["first_last_day_of"]=>
+ int(-1)
+ ["invert"]=>
+ int(0)
+ ["days"]=>
+ int(-1)
+ ["special_type"]=>
+ int(0)
+ ["special_amount"]=>
+ int(-1)
+ ["have_weekday_relative"]=>
+ int(0)
+ ["have_special_relative"]=>
+ int(0)
+ }
+ [1]=>
+ int(2)
+}
diff --git a/ext/standard/tests/serialize/bug70513.phpt b/ext/standard/tests/serialize/bug70513.phpt
new file mode 100644
index 0000000..2ac4ef6
--- /dev/null
+++ b/ext/standard/tests/serialize/bug70513.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Bug #70513: GMP Deserialization Type Confusion Vulnerability
+--SKIPIF--
+<?php if (!extension_loaded('gmp')) die('skip requires gmp');
+--FILE--
+<?php
+
+class obj
+{
+ var $ryat;
+
+ function __wakeup()
+ {
+ $this->ryat = 1;
+ }
+}
+
+$obj = new stdClass;
+$obj->aa = 1;
+$obj->bb = 2;
+
+$inner =
's:1:"1";a:3:{s:2:"aa";s:2:"hi";s:2:"bb";s:2:"hi";i:0;O:3:"obj":1:{s:4:"ryat";R:2;}}';
+$exploit =
'a:1:{i:0;C:3:"GMP":'.strlen($inner).':{'.$inner.'}}';
+$x = unserialize($exploit);
+var_dump($x);
+var_dump($obj);
+
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ int(1)
+}
+object(stdClass)#1 (2) {
+ ["aa"]=>
+ int(1)
+ ["bb"]=>
+ int(2)
+}
diff --git a/ext/standard/tests/serialize/bug72731.phpt b/ext/standard/tests/serialize/bug72731.phpt
new file mode 100644
index 0000000..3d7d1e7
--- /dev/null
+++ b/ext/standard/tests/serialize/bug72731.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #72731: Type Confusion in Object Deserialization
+--FILE--
+<?php
+
+class obj {
+ var $ryat;
+ function __wakeup() {
+ $this->ryat = 0x1122334455;
+ }
+}
+
+$poc =
'O:8:"stdClass":1:{i:0;O:3:"obj":1:{s:4:"ryat";R:1;}}';
+var_dump(unserialize($poc));
+
+?>
+--EXPECT--
+int(73588229205)