Skip to content
Memory corruption Advisory Advanced CVE-2017-2813

IrfanView JPEG 2000 Reference Tile Width Arbitrary Code Execution Vulnerability

The JPEG 2000 plugin in IrfanView 4.44 uses the reference tile width from the file in a buffer size calculation without checking for integer wraparound, so a crafted image causes a small buffer to be allocated for a large tile. Writing tile data into that undersized buffer produces a controlled out-of-bounds write that can be abused for arbitrary code execution.

Aleksandar Nikolic Follow

Originally disclosed on Cisco Talos

High 8.8 View original

An exploitable integer overflow vulnerability exists in the JPEG 2000 parser functionality of IrfanView 4.44. A specially crafted jpeg2000 image can cause an integer overflow leading to wrong memory allocation resulting in arbitrary code execution.

Aleksandar Nikolic, 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 reference tile width value from the SIZ marker is multiplied by 20 to size a heap buffer without any check for integer overflow, so a large value wraps to a small allocation that is later indexed with the original large value.

Impact

An attacker could achieve arbitrary code execution in the context of the application, though the text notes that depending on memory layout the out-of-bounds write may not crash and the outcome depends on controlling other SIZ fields.

What the attacker needed

Victim opens a crafted JPEG 2000 file; or victim's thumbnailing processes the file; Windows running IrfanView 4.44

How it was found

  1. Open a crafted JPEG 2000 file in IrfanView, or let its thumbnailing feature process the file.
  2. The parser reads the reference tile width from the SIZ marker and multiplies it by 20 plus a small value to compute the allocation size.
  3. The multiplication overflows, so a small heap buffer is reserved instead of a large one.
  4. A pointer into the buffer is computed using the original tile width multiplied by four, placing it out of bounds.
  5. A loop bounded by the number of components writes values through that pointer, corrupting memory beyond the buffer.

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.

An image file contains numbers that tell the viewer how big parts of the picture are. The viewer multiplies such a number to work out how much memory to reserve, but a very large number wraps around to a small one, so too little memory is reserved. The viewer then writes picture data past the end of that small block, and an attacker who crafts the file carefully can use this to 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 Aleksandar Nikolic

View all

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