Skip to content

Commit

Permalink
Deprecate class instance deserialization
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cmb69 committed Aug 15, 2017
1 parent dff9713 commit 0ddc855
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ext/wddx/tests/005.phpt
Expand Up @@ -44,7 +44,8 @@ session.save_handler=files

session_destroy();
?>
--EXPECT--
--EXPECTF--
Deprecated: session_decode(): Class instance deserialization is deprecated in %s on line %d
array(2) {
["data"]=>
array(4) {
Expand Down
3 changes: 2 additions & 1 deletion ext/wddx/tests/bug27287.phpt
Expand Up @@ -16,5 +16,6 @@ Bug #27287 (segfault with deserializing object data)
echo "OK\n";

?>
--EXPECT--
--EXPECTF--
Deprecated: wddx_deserialize(): Class instance deserialization is deprecated in %s on line %d
OK
1 change: 1 addition & 0 deletions ext/wddx/tests/bug71335.phpt
Expand Up @@ -26,6 +26,7 @@ var_dump($d);
?>
DONE
--EXPECTF--
Deprecated: wddx_deserialize(): Class instance deserialization is deprecated in %s on line %d
object(stdClass)#%d (1) {
["php_class_name"]=>
string(8) "stdClass"
Expand Down
2 changes: 1 addition & 1 deletion ext/wddx/tests/bug73331.phpt
Expand Up @@ -9,7 +9,7 @@ $wddx = "<wddxPacket version='1.0'><header/><data><struct><var name='php_class_n
var_dump(wddx_deserialize($wddx));
?>
--EXPECTF--
Deprecated: wddx_deserialize(): Class instance deserialization is deprecated in %s on line %d

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

2 changes: 2 additions & 0 deletions ext/wddx/tests/bug73831.phpt
Expand Up @@ -19,5 +19,7 @@ try {
} catch(Error $e) { echo $e->getMessage(); }
?>
--EXPECTF--
Deprecated: wddx_deserialize(): Class instance deserialization is deprecated in %s on line %d

Warning: wddx_deserialize(): Class throwable can not be instantiated in %sbug73831.php on line %d
Cannot instantiate interface Throwable
2 changes: 2 additions & 0 deletions ext/wddx/wddx.c
Expand Up @@ -952,6 +952,8 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name)
if (!strcmp(ent1->varname, PHP_CLASS_NAME_VAR) &&
Z_TYPE(ent1->data) == IS_STRING && Z_STRLEN(ent1->data) &&
ent2->type == ST_STRUCT && Z_TYPE(ent2->data) == IS_ARRAY) {
php_error_docref(NULL, E_DEPRECATED, "Class instance deserialization is deprecated");

zend_bool incomplete_class = 0;

zend_str_tolower(Z_STRVAL(ent1->data), Z_STRLEN(ent1->data));
Expand Down

0 comments on commit 0ddc855

Please sign in to comment.