Skip to content
Memory corruption Advisory Advanced CVE-2019-5100

LEADTOOLS BMP Parsing Remote Code Execution Vulnerability

The BMP header parser in LEADTOOLS multiplies the image width by four to size a buffer, and a crafted width value overflows that calculation so the buffer is too small. A subsequent memory copy then writes past the end of the buffer, which could allow an attacker to run code.

Cory Duplantis Follow

Originally disclosed on Cisco Talos

High 8.8 View original

An exploitable integer overflow vulnerability exists in the BMP header parsing functionality of LEADTOOLS 20. A specially crafted BMP image file can cause an integer overflow, potentially resulting in code execution.

Cory Duplantis, on Cisco Talos

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

How it worked

Root cause

The width value is multiplied by four in a 32-bit calculation without checking for overflow, so the allocation size wraps to a small value while the copy length stays large.

Impact

A crafted image could cause an out-of-bounds write and potentially code execution, though the report only demonstrates a crash.

What the attacker needed

Victim opens a crafted BMP file; application uses the affected library

The fix

The allocation size calculation should be checked for overflow, or performed in a wider integer type, before the buffer is allocated and filled.

How it was found

  1. Open a crafted BMP file whose header declares an oversized width.
  2. The parser reads the signature and the bitmap info header.
  3. It allocates a buffer sized from the width multiplied by four, which overflows to a small value.
  4. It copies image data into that buffer, writing past its end and crashing or corrupting memory.

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.

A BMP is a simple image file format, and its header stores the picture's width. The library works out how much memory to reserve by multiplying that width by four, but with a very large width the number wraps around and becomes small, so too little memory is reserved. When the image data is then copied in, it spills past the reserved area and can overwrite other memory, which in the worst case lets an attacker run their own code.

What is Memory corruption?

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

More by Cory Duplantis

View all

35 more disclosed reports, best first.

More from Cisco Talos

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.