MySQL存在缓冲区溢出攻击漏洞

(2004-07-08 10:30 )( )(天极软件 )
导读-- MySQL是一款开放源代码关系型数据库系统。MySQL验证机制实现存在问题……

  受影响系统:

  MySQL AB MySQL 5.0
  MySQL AB MySQL 4.1.2
  MySQL AB MySQL 4.1.1
  MySQL AB MySQL 4.1.0

  不受影响系统:

  MySQL AB MySQL 4.1.3

  详细描述:

  MySQL是一款开放源代码关系型数据库系统。MySQL验证机制实现存在问题,远程攻击者可以利用这个漏洞无需用户密码通过验证。

  通过提交特殊构建的验证包,可使攻击者绕过MySQL 4.1中的密码验证。

check_connection (sql_parse.cpp), 837行中:

  /*
  Old clients send null-terminated string as password; new clients send
  the size (1 byte) + string (not null-terminated). Hence in case of
empty
  password both send '\0'.
  */
  uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ?
  *passwd++ : strlen(passwd);

  在'client capabilities'标记中提供0x8000,用户可以按照他们的选择指定passwd_len字段。用于这个攻击,选择0x14 (20)作为SHA HASH长度。

  然后是几个用于确保用户来自许可主机的检查。这些检查通过后,就会进入如下代码:

    /* check password: it should be empty or valid */
    if (passwd_len == acl_user_tmp->salt_len)
    {
      if (acl_user_tmp->salt_len == 0 ||
        acl_user_tmp->salt_len == SCRAMBLE_LENGTH &&
        check_scramble(passwd, thd->scramble, acl_user_tmp->salt) == 0 ||
        check_scramble_323(passwd, thd->scramble,
                 (ulong *) acl_user_tmp->salt) == 0)
      {
      acl_user= acl_user_tmp;
      res= 0;
      }
    }

  check_scramble函数失败,但内部的check_scramble_323函数我们可以看到:

my_bool
check_scramble_323(const char *scrambled, const char *message,
           ulong *hash_pass)
{
  struct rand_struct rand_st;
  ulong hash_message[2];
  char buff[16],*to,extra;            /* Big enough for check */
  const char *pos;

  hash_password(hash_message, message, SCRAMBLE_LENGTH_323);
  randominit(&rand_st,hash_pass[0] ^ hash_message[0],
       hash_pass[1] ^ hash_message[1]);
  to=buff;
  for (pos=scrambled ; *pos ; pos++)
  *to++=(char) (floor(my_rnd(&rand_st)*31)+64);
  extra=(char) (floor(my_rnd(&rand_st)*31));
  to=buff;
  while (*scrambled)
  {
  if (*scrambled++ != (char) (*to++ ^ extra))
    return 1;                 /* Wrong password */
  }
  return 0;
}

  在这里,用户可以任意指定一'scrambled'字符串长度,因此使用零长度字符串可绕过验证,在最后的比较中由于'scrambled'字符串没有字符,使函数返回'0',允许用户以零长度字符串绕过验证。

  另外基于堆栈的缓冲区'buff'可以通过超长'scramble'字符串溢出,缓冲区被从my_rnd()函数输出的字符溢出,字符范围是0x40..0x5f,在部分平台下可能可以导致任意代码执行。

  补丁下载

  MySQL AB 4.1.3已经修补此漏洞,或者5.0 Build版本也已经修正此问题:

  http://www.mysql.com

责编:
订阅新闻邮件) (推荐) (打印) (关闭页面) (至顶) (我对此感兴趣
相关文章
笔名:
请您注意:

 遵守国家有关法律、法规,尊重网上道德,承担一切因您的行为而直接或间接引起的法律责任。

 天极网拥有管理笔名和留言的一切权利。