HDF5 Group libhdf5 gif2h5 heap-based buffer overflow vulnerability
A heap-based buffer overflow exists in the gif2h5 tool of HDF5 1.10.4 when parsing a GIF image descriptor. An attacker could provide a malicious GIF file to cause a crash and potentially execute code.
Originally disclosed on Cisco Talos
A heap-based buffer overflow 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
The ReadGifImageDesc function allocates a heap buffer based on image width and height but then writes the image data stream without any bounds checking, relying on valid block size values.
Impact
An attacker could cause a crash and potentially execute code by providing a malicious GIF file to the gif2h5 tool.
What the attacker needed
Victim opens a malicious GIF file with gif2h5
How it was found
- Create a GIF file with a local image descriptor specifying a small image size (e.g., 5x5) but containing a data stream larger than the allocated buffer.
- Run the gif2h5 tool with the malicious GIF file as input.
- The tool allocates a heap buffer based on the image dimensions and then writes the oversized data stream into it, overflowing the buffer.
- The overflow corrupts heap metadata, leading to a crash (e.g., 'malloc(): corrupted top size').
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 heap buffer overflow happens when a program writes more data into a memory area than it was allocated for. Here, the gif2h5 tool allocates memory based on the image size but then copies image data without checking the size, so a crafted GIF can overwrite other memory. This can crash the program and, in some cases, 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.