summaryrefslogtreecommitdiff
path: root/ext/standard/tests/strings
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2016-08-02 01:08:42 -0700
committerStanislav Malyshev <stas@php.net>2016-08-16 22:54:42 -0700
commit448c9be157f4147e121f1a2a524536c75c9c6059 (patch)
tree345471bd401fb077fb956c73f2087d03954e3268 /ext/standard/tests/strings
parent1bb92d52121cf2635df163911216bf2958db4d34 (diff)
downloadphp-git-448c9be157f4147e121f1a2a524536c75c9c6059.tar.gz
Fix bug #72663 - destroy broken object when unserializing
Diffstat (limited to 'ext/standard/tests/strings')
-rw-r--r--ext/standard/tests/strings/bug72663.phpt26
-rw-r--r--ext/standard/tests/strings/bug72663_2.phpt17
2 files changed, 43 insertions, 0 deletions
diff --git a/ext/standard/tests/strings/bug72663.phpt b/ext/standard/tests/strings/bug72663.phpt
new file mode 100644
index 0000000000..e61f939d4d
--- /dev/null
+++ b/ext/standard/tests/strings/bug72663.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #72663: Create an Unexpected Object and Don't Invoke __wakeup() in Deserialization
+--FILE--
+<?php
+class obj implements Serializable {
+ var $data;
+ function serialize() {
+ return serialize($this->data);
+ }
+ function unserialize($data) {
+ $this->data = unserialize($data);
+ }
+}
+
+$inner = 'a:1:{i:0;O:9:"Exception":2:{s:7:"'."\0".'*'."\0".'file";R:4;}';
+$exploit = 'a:2:{i:0;C:3:"obj":'.strlen($inner).':{'.$inner.'}i:1;R:4;}';
+
+$data = unserialize($exploit);
+echo $data[1];
+?>
+DONE
+--EXPECTF--
+Notice: unserialize(): Unexpected end of serialized data in %sbug72663.php on line %d
+
+Notice: unserialize(): Error at offset 46 of 47 bytes in %sbug72663.php on line %d
+DONE \ No newline at end of file
diff --git a/ext/standard/tests/strings/bug72663_2.phpt b/ext/standard/tests/strings/bug72663_2.phpt
new file mode 100644
index 0000000000..ac605e9fd2
--- /dev/null
+++ b/ext/standard/tests/strings/bug72663_2.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #72663: Create an Unexpected Object and Don't Invoke __wakeup() in Deserialization
+--FILE--
+<?php
+
+ini_set('session.serialize_handler', 'php_serialize');
+session_start();
+$sess = 'O:9:"Exception":2:{s:7:"'."\0".'*'."\0".'file";R:1;}';
+session_decode($sess);
+var_dump($_SESSION);
+?>
+DONE
+--EXPECTF--
+Notice: session_decode(): Unexpected end of serialized data in %sbug72663_2.php on line %d
+array(0) {
+}
+DONE \ No newline at end of file