Skip to content
Memory corruption Advisory Advanced CVE-2022-25972

HDF5 Group libhdf5 gif2h5 out-of-bounds write vulnerability

The gif2h5 tool in libhdf5 1.10.4 fails to check the bounds of a heap buffer during GIF decompression, allowing a crafted GIF file to cause an out-of-bounds write. An attacker could exploit this to corrupt heap memory and potentially achieve code execution.

Dave McDaniel Follow

Originally disclosed on Cisco Talos

High 7.8 View original

An out-of-bounds write vulnerability exists in the gif2h5 functionality of HDF5 Group libhdf5 1.10.4. A specially-crafted GIF file can lead to code execution.

Dave McDaniel, 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

Likely the code uses a user-controlled index (FreeCode) to write into fixed-size heap buffers (Prefix and Suffix) without validating that the index is within the allocated bounds.

Impact

An attacker could exploit this to corrupt heap memory and potentially achieve code execution, though the report only demonstrates a crash.

What the attacker needed

Victim opens a malicious GIF file; gif2h5 tool is used

How it was found

  1. Craft a GIF file with a specific CodeSize value and decompression data.
  2. Run the gif2h5 tool on the crafted GIF file.
  3. The tool reads the decompression data and calculates an out-of-bounds index.
  4. The tool writes to the heap buffer at the out-of-bounds index, corrupting memory.
  5. The tool eventually encounters the EOF code and frees the corrupted heap buffers, causing a crash.

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 converts a GIF image to another format, it uses a table to store colour codes. The program does not check if the table index stays within the table's size, so a malicious GIF can make it write past the end of the table. This can crash the program or let 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 Dave McDaniel

View all

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