Created
May 18, 2020 07:09
-
-
Save ohader/ef6766c0167848761e982654010397cb to your computer and use it in GitHub Desktop.
Example of Insecure Deserialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyClass | |
{ | |
/** | |
* @var string | |
*/ | |
protected $dontTouch; | |
public function __destruct() | |
{ | |
if ($this->dontTouch !== null) { | |
throw new \Exception($this->dontTouch); | |
} | |
} | |
public function __sleep() | |
{ | |
return []; | |
} | |
public function __wakeup() | |
{ | |
// too late | |
} | |
} | |
$serialized = 'O:7:"MyClass":1:{s:12:"*dontTouch";s:6:"attack";}'; | |
unserialize($serialized); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment