On the OWASP site, he explains this type of flaw that makes code injection possible. But a part is not clear to me and if someone who understands can clarify me. The excerpt reads as follows:
In order to successfully exploit PHP Object Injection vulnerability two conditions must be met:
The application must have a class which implements PHP magic method (such as __wakeup or __destruct) that can be used to carry out malicious attacks, or to start a "POP chain".
-
All of the classes used during the attack must be declared when the vulnerable unserialize () is being called, otherwise object autoloading should be supported for such classes.
That is, when it says that the application must implement a magic method so that there is success in exploiting this failure. Is it referring to any and all classes in my application, or just the class of the object being serialized?
Ex:
let's say I have an object
class Usuario{
...
}
and an object
class Setup{
function __construct() {
...
}
function __wakeup() {
...
}
}
And I was serializing my obj $user
. Could an attacker use the magic methods of class Setup
for a possible attack? or these methods should exist in the class of the object being serialized. In this case the class Usuario
?
$user = new Usuario();
echo serialize($user);