Skip to content

Instantly share code, notes, and snippets.

@ohader
Created May 18, 2020 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohader/ef6766c0167848761e982654010397cb to your computer and use it in GitHub Desktop.
Save ohader/ef6766c0167848761e982654010397cb to your computer and use it in GitHub Desktop.
Example of Insecure Deserialization
<?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