So I was just reading up on the OWASP site about PHP Object Injection. According to their site, the suggested fix is to not use serialze
and unserialize
but to use
json_encode
and json_decode
.
However, after doing a few tests in a limited amount of time I have found that this isn't the case at all. For example (working Codepad example):
<?php
function e($method, $args) {
return $method($args);
}
var_dump(call_user_func_array("e", array((string)array_shift(json_decode("[\"system\"]")), "ls" )));
?>
So, my questions are:
Would you agree with me that this is not the case, and there should be more of a suggested fix rather than just using
json_*
functions?Am I actually correct in assuming what I have done is correct?