统计在线人数...

Php动态函数注入漏洞

[ 来源:不详 | 作者:neeao | 时间:2006-5-30 12:53:20 | 浏览:统计中... ]


信息来源:LoveShell

最先是在www.milw0rm.com上看到的,原文是英文,看得不懂但是收益很多,最近看到有中文版本了,大家学习下哦!
原始连接http://www.milw0rm.com/papers/60

向翻译者suwcf致敬,有能力的建议看原文!

以下是简介阶层日益严重 PHP的应用性. 可以让执行 任意法或任意功能或阅读/书写的机会 国内任意变量.
看来只有极少数研究人员正在寻找 这些问题包括StefanEsser,Retrogod,Gulftech.
不过,这可能是目前许多严重问题 应用,特别是大型或复杂的问题. 此外, 这些研究人员可以引发性错误,但品牌
他们充分发挥XSS如果不诊断. 看到这种独特性并非PHP. 其他 可以理解的语言有类似的问题. 例如,Perl,
参展,有Xeval功能. 最近MySpaceXSS 注射用eval问题Java[1],已注射eval
一些平日申请报(CVE-2005-2483、 CVE-2005-3302),Perl(CVE-2002-1750,CVE-2003-0770,CVE-2005-1527、
CVE-2005-2837).

------------------------------------------------------
Dynamic Evaluation Vulnerabilities in PHP applications
------------------------------------------------------

以下是简介阶层日益严重 PHP的应用性. 可以让执行
任意法或任意功能或阅读/书写的机会 国内任意变量.
看来只有极少数研究人员正在寻找
这些问题包括StefanEsser,Retrogod,Gulftech.
不过,这可能是目前许多严重问题 应用,特别是大型或复杂的问题.
此外, 这些研究人员可以引发性错误,但品牌
他们充分发挥XSS如果不诊断. 看到这种独特性并非PHP.
其他 可以理解的语言有类似的问题. 例如,Perl,
参展,有Xeval功能. 最近MySpaceXSS
注射用eval问题Java[1],已注射eval
一些平日申请报(CVE-2005-2483、 CVE-2005-3302),
Perl(CVE-2002-1750,CVE-2003-0770,CVE-2005-1527、
CVE-2005-2837).

--------------
Eval Injection
--------------
术语笔记: 这个期限不是共同, 但它被使用在CVE 。
这文字, 没有常用的选择。

一个eval 射入弱点发生当攻击者可能控制
被灌输eval() 作用输入串的全部或部份
电话。 Eval 将执行论据作为代码。 安全
涵义为这是显然的。 这个问题知道为
几年[ 2 ], 但它仍然在之下被研究。

Example:

$myvar = "varname";
$x = $_GET['arg'];
eval("\$myvar = \$x;");

What happens if arg is set to "10 ; system(\"/bin/echo uh-oh\");" ?

Basic detection:

以原始代码: 因为这是一个标准PHP 作用, 这容易
对grep 潜在地危险打电话对eval() 。 但是,
研究员必须进一步调查是否输入可能是
由攻击者控制。

- 没有原始代码: 如果絮絮叨叨错误是可利用的, 一无效
输入也许触发错误信息与分析错误有关。
使用"phpinfo" 输入也许是有用的。 但是, 您可能
必须演奏以输入匹配语法要求
声明最后被灌输eval, 象您
有时需要做在XSS 或SQL 射入。

消灭问题:

- 避免eval() 每当可能

- 使用唯一可接受的价值whitelists 插入入eval()
电话。 whitelist 也许需要改变根据的地方
节目您是。

---------------------------
Dynamic Variable Evaluation
---------------------------

术语笔记: 没有共同的期限为这问题。

PHP 支持"易变的可变物,"是可变物或表示
那评估对其它可变物[ 3 的] 名字。 他们可能被使用
动态地改变在期间可变物被获取或被设置
节目的施行。 这个强有力和方便特点是
还危险。

如果易变的名字不是受控的, 攻击者能读或
给任意可变物写, 根据应用。
后果取决于节目。 在某些情况下, 均匀重要
可变物譬如$_globals 可能被修改[ 4 ] 。

Example:

$varname = "myvar";
$$varname = 10;
echo $myvar;

This will set $myvar, and print the string "10"!

It seems likely that this issue will occur more frequently as PHP
developers modify their programs so that they do not require
register_globals.

A number of applications have code such as the following:

$safevar = "0";
$param1 = "";
$param2 = "";
$param3 = "";
# my own "register globals" for param[1,2,3]
foreach ($_GET as $key => $value) {
$$key = $value;
}

If the attacker provides "safevar=bad" in the query string, then
$safevar will be set to the value "bad".

Detection Examples:

$$varname

${$varname}

${$var . $name}

${arbitrary expression}

Eliminating the problem:

- use only whitelists of acceptable variable names. The whitelist
might need to change depending on where in the program you are.

---------------------------
Dynamic Function Evaluation
---------------------------

Terminology note: there is no common term for this kind of issue.

Variable variables can also be used to dynamically reference
functions:

$funcname = "myfunction";

$$funcname("Arg1", "Arg2");

This effectively calls myfunction("Arg1", "Arg2") !

Detection Examples:

$$fname();

${$var1 . $var2} ("arg");

${"varname"} ();

Eliminating the problem:

- use only whitelists of acceptable function names. The whitelist
might need to change depending on where in the program you are.

----------
References
----------

[1] Myspace.com - Intricate Script Injection
Justin Lavoie
http://marc.theaimsgroup.com/?l=bugtraq&m=114469411219299&w=2

[2] A Study In Scarlet: Exploiting Common Vulnerabilities in PHP Applications
Shaun Clowes
http://www.securereality.com.au/studyinscarlet.txt

This classic paper briefly mentioned the risk of eval

[3] PHP: Variable variables
http://us3.php.net/manual/en/language.variables.variable.php

[4] $GLOBALS Overwrite and it's Consequences
Stefan Esser
http://www.hardened-php.net/globals-problem

This paper talks specifically about dynamic variable evaluation
and the impact on superglobals such as $_GLOBALS. Esser was one
of the first (if not the first) researchers to use the term "eval
injection".

-------------------------
Sample Vulnerable Program
-------------------------

<html>
<body>
<h1>Dynamic Evaluation Vulnerabilities in PHP Applications - Examples</h1>
<table border=2>
<tr>
<td>Dynamic variable evaluation (a "variable variable")
<td><a href="?test=

[1] [2]  下一页

共有0人参与评价,平均得分:0分
评论内容只代表网友观点,与本站立场无关! 查看完整内容
   

当前在线人数
QQ:748838 MSN:allen_xia#msn.com E-mail:allenxia666#126.com QQ群:28200145