阅读全部内容

Python多个整数溢出漏洞

  [字体: ]


受影响系统:
Python python 2.5.x
Python python 2.4.x
不受影响系统:
Python python 2.5.2 r6
Python python 2.4.4 r14
描述:
BUGTRAQ  ID: 30491
CVE(CAN) ID: CVE-2008-2315,CVE-2008-2316,CVE-2008-3142,CVE-2008-3143,CVE-2008-3144

Python是一种开放源代码的脚本编程语言。

Python中存在多个整数溢出漏洞,可能允许恶意用户导致拒绝服务或入侵有漏洞的系统。

1) stringobject、unicodeobject、bufferobject、longobject、tupleobject、stropmodule、gcmodule、mmapmodule等核心模块中存在各种整数溢出。

2) hashlib模块中的整数溢出可能导致不可信任的加密摘要结果。

3) 在处理unicode字符串时unicode_resize()中的整数溢出可能在32位系统上导致错误的内存分配。以下是有漏洞的代码段:

174 static
175 int unicode_resize(register PyUnicodeObject *unicode,
176                       Py_ssize_t length)
177 {
[...]
201
202     oldstr = unicode->str;
203     PyMem_RESIZE(unicode->str, Py_UNICODE, length + 1);
[...]
209     unicode->str[length] = 0;
210     unicode->length = length;
211  

95 #define PyMem_RESIZE(p, type, n) \
96   ( assert((n) <= PY_SIZE_MAX / sizeof(type)) , \
97         ( (p) = (type *) PyMem_REALLOC((p), (n) * sizeof(type)) ) )

4) 在不存在vsnprintf()函数的架构上,PyOS_vsnprintf()函数中存在整数溢出漏洞。以下是有漏洞的代码段:

53 int
54 PyOS_vsnprintf(char *str, size_t size, const char  *format, va_list va)
55 {
56         int len;  /* # bytes written, excluding \0 */
[...]
60         assert(str != NULL);
61         assert(size > 0);
62         assert(format != NULL);
63
[...]
67         /* Emulate it. */
68         buffer = PyMem_MALLOC(size + 512);
69         if (buffer == NULL) {
70                 len = -666;
71                 goto Done;
72         }
73
74         len = vsprintf(buffer, format, va);
75         if (len < 0)
76                 /* ignore the error */;
77
78         else if ((size_t)len >= size + 512)
79                 Py_FatalError("Buffer overflow in
PyOS_snprintf/PyOS_vsnprintf");
80
81         else {
82                 const size_t to_copy = (size_t)len < size ?
83                                         (size_t)len : size - 1;
84                 assert(to_copy < size);
85                 memcpy(str, buffer, to_copy);
86                 str[to_copy] = '\0';
87         }
88         PyMem_FREE(buffer);
89 Done:
[...]
91         str[size-1] = '\0';
92         return len;
93 }

5) 如果向PyOS_vsnprintf()函数传送了0长度的字符串的话,就可能触发整数溢出,导致内存破坏。以下是有漏洞的代码段:

53 int
54 PyOS_vsnprintf(char *str, size_t size, const char  *format, va_list va)
55 {
56         int len;  /* # bytes written, excluding \0 */
57 #ifndef HAVE_SNPRINTF
58         char *buffer;
59 #endif
60         assert(str != NULL);
61         assert(size > 0);
62         assert(format != NULL);
[...]
65         len = vsnprintf(str, size, format, va);
[...]
91         str[size-1] = '\0';
92         return len;
93 }

<*来源:David Remahl (vuln@remahl.se
        Justin Ferguson (jferguson@ioactive.com
  
  链接:http://secunia.com/advisories/31305/
        http://bugs.gentoo.org/show_bug.cgi?format=multiple&id=232137
        http://bugs.gentoo.org/show_bug.cgi?format=multiple&id=230640
        http://bugs.python.org/issue2620
        http://bugs.python.org/issue2588
        http://bugs.python.org/issue2589
        http://security.gentoo.org/glsa/glsa-200807-16.xml
*>

建议:
厂商补丁:

Gentoo
------
Gentoo已经为此发布了一个安全公告(GLSA-200807-16)以及相应补丁:
GLSA-200807-16:Python: Multiple vulnerabilities
链接:http://security.gentoo.org/glsa/glsa-200807-16.xml

所有Python 2.4用户都应升级到最新版本:

    # emerge --sync
    # emerge --ask --oneshot --verbose ">=dev-lang/python-2.4.4-r14"

所有Python 2.5用户都应升级到最新版本:

    # emerge --sync
    # emerge --ask --oneshot --verbose ">=dev-lang/python-2.5.2-r6"

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

http://svn.python.org/view?rev=65335&view=rev


日期:2008年08月

【 hits:】 【 评论 】 【 推荐 】 【 打印
上一篇:OpenVPN客户端lladdr和iproute配置指令远程代码执行漏洞
下一篇:8E6科技R3000 Internet过滤器Host头绕过检测漏洞
相关新闻      
为什么选择连天科技
河南连天科技有限公司 ( LianTian Technology Co.,Ltd. ),是国内从事网络安全的高科技企业之一。
连天科技是Radware、Mirage、绿盟、AVENTAIL、Sonicwall、比蒙等国际国内知名厂商的河南区域战略合作伙伴,我们本着“专业、专注、全心、全程”的服务理念为客户提供全面的信息安全解决方案,协助客户建立安全可靠的运营环境。