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.
Originally disclosed on Cisco Talos
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.
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
- Craft a GIF file with a specific CodeSize value and decompression data.
- Run the gif2h5 tool on the crafted GIF file.
- The tool reads the decompression data and calculates an out-of-bounds index.
- The tool writes to the heap buffer at the out-of-bounds index, corrupting memory.
- 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.