Skip to content
Info disclosure Disclosed report Intermediate CVE-2019-11038

Uninitialized read in gdImageCreateFromXbm

The XBM image parser in PHP's GD extension reads pixel data into a variable without checking whether the hex parse succeeded, so the variable can hold uninitialised stack data. An attacker could supply a crafted XBM file to leak data from stack memory.

chamal Follow

Originally disclosed on HackerOne

Medium 5.3 View original
  • Triaged in 6 months
  • Fixed in 16 months
  • Paid in 16 months
  • Disclosed after 16 months

This bug is present in gdImageCreateFromXbm method of ext/gd/libgd/gd_xbm.c file. This method contains below mentioned lines.

C
...
unsigned int b;
...
sscanf(h, "%x", &b);
		for (bit = 1; bit <= max_bit; bit = bit << 1) {
			gdImageSetPixel(im, x++, y, (b & bit) ? 1 : 0);
...

So when sscanf method is not able to read a hex value, "b" variable will contain uninitialized data. Bug Report : https://bugs.php.net/bug.php?id=77973 PHP Version : 7.1.29 CVE-ID : 2019-11038

Impact

Uninitialized data may leak data from stack memory.

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

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the return value of the hex parsing call is ignored, so the destination variable is used even when no value was parsed and remains uninitialised.

Impact

Uninitialised stack memory could be leaked through the parsed image data.

What the attacker needed

Attacker supplies a crafted XBM file; application parses it with PHP GD

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When a program reads a file, it should check that each value it reads is actually valid. Here the code asks a parsing function to read a hex number into a variable but never checks whether that read worked, so the variable keeps whatever leftover data was already in memory. That leftover data can then be written out as image pixels, revealing bits of memory the attacker should not see.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More by chamal

View all

8 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.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.