首页 -> 安全研究

安全研究

安全漏洞
PHP-Nuke index.php search模块SQL注入漏洞

发布日期:2006-02-20
更新日期:2006-02-20

受影响系统:
PHP-Nuke PHP-Nuke 7.8
PHP-Nuke PHP-Nuke 7.7
PHP-Nuke PHP-Nuke 7.6
PHP-Nuke PHP-Nuke 7.5
不受影响系统:
PHP-Nuke PHP-Nuke 7.9
描述:
BUGTRAQ  ID: 16732

PHP-Nuke是一个广为流行的网站创建和管理工具,它可以使用很多数据库软件作为后端,比如MySQL、PostgreSQL、mSQL、Interbase、Sybase等。

PHP-Nuke较新版本的软件包中的search模块实现上存在输入验证漏洞,远程攻击者可能利用此漏洞对服务器程序执行SQL注入攻击。

在较早版本PHP-Nuke的“modules/Search/index.php”代码中,以7.1版本为例:

----------------[ from source code ]------------------

$query = addslashes($query);

if ($type=="stories" OR !$type) {

        if ($category > 0) {
            $categ = "AND catid=$category ";
        } elseif ($category == 0) {
            $categ = "";
        }
   $q = "select s.sid, s.aid, s.informant, s.title, s.time, s.hometext,
s.bodytext, a.url, s.comments, s.topic from ".$prefix."_stories s, \
".$prefix."_authors  a where s.aid=a.aid $queryalang $categ";
     if (isset($query)) $q .= "AND (s.title LIKE '%$query%' OR s.hometext LIKE
'%$query%' OR s.bodytext LIKE '%$query%' OR s.notes LIKE '%$query%') ";
       if ($author != "") $q .= "AND s.aid='$author' ";

----------------[ /from source code ]-----------------

可见addslashes()用于$query变量,因此不可能执行sql注入。而在较新PHP-Nuke版本的相同代码段中,以7.5版为例:

----------------[ from source code ]------------------

$query = stripslashes(check_html($query, "nohtml"));

if ($type=="stories" OR !$type) {

    if ($category > 0) {
        $categ = "AND catid='$category' ";
    } else {
           $categ = "";
    }
  $q = "select s.sid, s.aid, s.informant, s.title, s.time, s.hometext,
s.bodytext, a.url, s.comments, s.topic from ".$prefix."_stories s, \
".$prefix."_authors  a where s.aid=a.aid $queryalang $categ";
  if (isset($query)) $q .= "AND (s.title LIKE '%$query%' OR s.hometext LIKE
'%$query%' OR s.bodytext LIKE '%$query%' OR s.notes LIKE '%$query%') ";
  if ($author != "") $q .= "AND s.aid='$author' ";
----------------[ /from source code ]-----------------

只有第一行发生了变化:

$query = stripslashes(check_html($query, "nohtml"));

在这段代码中没有正确的过滤用户输入,允许攻击者执行SQL注入攻击。

<*来源:Janek Vind (come2waraxe@yahoo.com
  
  链接:http://marc.theaimsgroup.com/?l=bugtraq&m=114045901025009&w=2
*>

测试方法:

警 告

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

p0hh0nsee%') UNION ALL SELECT 1,2,aid,pwd,5,6,7,8,9,10 FROM nuke_authors/*

建议:
厂商补丁:

PHP-Nuke
--------
目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载:

* PHP-Nuke PHP-Nuke 7.9.0
http://phpnuke.org/modules.php?name=Release

浏览次数:4354
严重程度:0(网友投票)
本安全漏洞由绿盟科技翻译整理,版权所有,未经许可,不得转载
绿盟科技给您安全的保障