Skip to content

Commit 3c4d32c

Browse files
committed
unserialize: Update CVE tests
It's unlikely that the object syntax error contributed to the actual CVE. The CVE is rather caused by the incorrect object serialization data of the `C` format. Add a second string without such a syntax error to ensure that path is still executed as well to ensure the CVE is absent.
1 parent be67fc9 commit 3c4d32c

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

ext/spl/tests/bug73029.phpt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ Bug #73029: Missing type check when unserializing SplArray
33
--FILE--
44
<?php
55
try {
6+
$a = 'C:11:"ArrayObject":19:{x:i:0;r:2;;m:a:0:{}}';
7+
$m = unserialize($a);
8+
$x = $m[2];
9+
} catch(UnexpectedValueException $e) {
10+
print $e->getMessage() . "\n";
11+
}
12+
try {
613
$a = 'C:11:"ArrayObject":19:0x:i:0;r:2;;m:a:0:{}}';
714
$m = unserialize($a);
815
$x = $m[2];
@@ -11,6 +18,10 @@ $x = $m[2];
1118
}
1219
?>
1320
DONE
14-
--EXPECT--
21+
--EXPECTF--
1522
Error at offset 10 of 19 bytes
23+
24+
Notice: unserialize(): Error at offset 22 of 43 bytes in %s on line %d
25+
26+
Warning: Trying to access array offset on value of type bool in %s on line %d
1627
DONE

ext/standard/tests/serialize/bug73341.phpt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
Bug #73144 (Use-afte-free in ArrayObject Deserialization)
33
--FILE--
44
<?php
5+
try {
6+
$token = 'a:2:{i:0;O:1:"0":2:{s:1:"0";i:0;s:1:"0";a:1:{i:0;C:11:"ArrayObject":7:{x:i:0;r}';
7+
$obj = unserialize($token);
8+
} catch(Exception $e) {
9+
echo $e->getMessage()."\n";
10+
}
11+
512
try {
613
$token = 'a:2:{i:0;O:1:"0":2:0s:1:"0";i:0;s:1:"0";a:1:{i:0;C:11:"ArrayObject":7:{x:i:0;r}';
714
$obj = unserialize($token);
@@ -18,6 +25,8 @@ unserialize($exploit);
1825
}
1926
?>
2027
--EXPECTF--
28+
Error at offset 6 of 7 bytes
29+
2130
Notice: unserialize(): Error at offset 19 of 79 bytes in %s on line %d
2231

2332
Notice: ArrayObject::unserialize(): Unexpected end of serialized data in %sbug73341.php on line %d

0 commit comments

Comments
 (0)