bug72562.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. Bug #72562: Use After Free in unserialize() with Unexpected Session Deserialization
  3. --EXTENSIONS--
  4. session
  5. --SKIPIF--
  6. <?php include('skipif.inc'); ?>
  7. --FILE--
  8. <?php
  9. ini_set('session.serialize_handler', 'php_binary');
  10. session_start();
  11. $sess = "\x1xi:1;\x2y";
  12. session_decode($sess);
  13. $uns_1 = '{';
  14. $out_1[] = unserialize($uns_1);
  15. unset($out_1);
  16. $fakezval = ptr2str(1122334455);
  17. $fakezval .= ptr2str(0);
  18. $fakezval .= "\x00\x00\x00\x00";
  19. $fakezval .= "\x01";
  20. $fakezval .= "\x00";
  21. $fakezval .= "\x00\x00";
  22. for ($i = 0; $i < 5; $i++) {
  23. $v[$i] = $fakezval.$i;
  24. }
  25. $uns_2 = 'R:2;';
  26. $out_2 = unserialize($uns_2);
  27. var_dump($out_2);
  28. function ptr2str($ptr)
  29. {
  30. $out = '';
  31. for ($i = 0; $i < 8; $i++) {
  32. $out .= chr($ptr & 0xff);
  33. $ptr >>= 8;
  34. }
  35. return $out;
  36. }
  37. ?>
  38. --EXPECTF--
  39. Warning: session_decode(): Failed to decode session object. Session has been destroyed in %s%ebug72562.php on line %d
  40. Notice: unserialize(): Error at offset 0 of 1 bytes in %s%ebug72562.php on line %d
  41. Notice: unserialize(): Error at offset 4 of 4 bytes in %s%ebug72562.php on line %d
  42. bool(false)