Skip to content

Commit 0ddc855

Browse files
committed
Deprecate class instance deserialization
The ability to deserialize class instances is a bad idea for a general *data* exchange format, because it can lead to remote code execution vulnerabilities (due to __wakeup() calls). We therefore deprecate this "feature" to pave the way for its eventual removal.
1 parent dff9713 commit 0ddc855

File tree

6 files changed

+10
-3
lines changed

6 files changed

+10
-3
lines changed

ext/wddx/tests/005.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ session.save_handler=files
4444

4545
session_destroy();
4646
?>
47-
--EXPECT--
47+
--EXPECTF--
48+
Deprecated: session_decode(): Class instance deserialization is deprecated in %s on line %d
4849
array(2) {
4950
["data"]=>
5051
array(4) {

ext/wddx/tests/bug27287.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ Bug #27287 (segfault with deserializing object data)
1616
echo "OK\n";
1717

1818
?>
19-
--EXPECT--
19+
--EXPECTF--
20+
Deprecated: wddx_deserialize(): Class instance deserialization is deprecated in %s on line %d
2021
OK

ext/wddx/tests/bug71335.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var_dump($d);
2626
?>
2727
DONE
2828
--EXPECTF--
29+
Deprecated: wddx_deserialize(): Class instance deserialization is deprecated in %s on line %d
2930
object(stdClass)#%d (1) {
3031
["php_class_name"]=>
3132
string(8) "stdClass"

ext/wddx/tests/bug73331.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ $wddx = "<wddxPacket version='1.0'><header/><data><struct><var name='php_class_n
99
var_dump(wddx_deserialize($wddx));
1010
?>
1111
--EXPECTF--
12+
Deprecated: wddx_deserialize(): Class instance deserialization is deprecated in %s on line %d
1213

1314
Warning: wddx_deserialize(): Class pdorow can not be unserialized in %s73331.php on line %d
1415
NULL
15-

ext/wddx/tests/bug73831.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ try {
1919
} catch(Error $e) { echo $e->getMessage(); }
2020
?>
2121
--EXPECTF--
22+
Deprecated: wddx_deserialize(): Class instance deserialization is deprecated in %s on line %d
23+
2224
Warning: wddx_deserialize(): Class throwable can not be instantiated in %sbug73831.php on line %d
2325
Cannot instantiate interface Throwable

ext/wddx/wddx.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,8 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name)
952952
if (!strcmp(ent1->varname, PHP_CLASS_NAME_VAR) &&
953953
Z_TYPE(ent1->data) == IS_STRING && Z_STRLEN(ent1->data) &&
954954
ent2->type == ST_STRUCT && Z_TYPE(ent2->data) == IS_ARRAY) {
955+
php_error_docref(NULL, E_DEPRECATED, "Class instance deserialization is deprecated");
956+
955957
zend_bool incomplete_class = 0;
956958

957959
zend_str_tolower(Z_STRVAL(ent1->data), Z_STRLEN(ent1->data));

0 commit comments

Comments
 (0)