Skip to content
DoS Write-up Intermediate

PHP CVE-2018-5711 - Hanging Websites by a Harmful GIF

A type conversion bug in PHP's GIF parsing code causes an infinite loop when processing a crafted GIF. An attacker could upload such a GIF to a site that uses the GD library to resize images, exhausting server resources.

blog.orange.tw

Published on blog.orange.tw

Recently, I reviewed several Web frameworks and language implementations, and found some vulnerabilities.

The author, on blog.orange.tw

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

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

How it worked

Root cause

The variable 'count' is declared as unsigned char, so when GetDataBlock returns -1, it is converted to 255, and the condition to set 'done' is never met, causing an infinite loop.

What the attacker needed

Victim uses GD library to resize images; attacker can upload a GIF

The fix

The vulnerability was fixed in PHP versions 5.6.33, 7.0.27, 7.1.13, and 7.2.1.

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 write-up has not been written yet. The Original tab links to the source.

A GIF file is made of blocks of data. The code that reads these blocks has a loop that should stop when it sees a special end marker. But because of a mistake in how a number is stored, the loop never stops, so the server gets stuck and cannot do other work.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.