GHSL-2026-140: Heap Buffer Write Overflow in 7-Zip
A heap buffer overflow in 7-Zip's NTFS handler occurs because a shift operation in GetCuSize() is undefined when the cluster size log is 28 and the compression unit is 4, causing a 1-byte buffer to be allocated instead of the intended size. An attacker can craft a malicious NTFS image that, when opened, writes up to 256 MB of controlled data into this tiny buffer, potentially leading to code execution via vtable hijack or a crash.
A heap buffer overflow vulnerability (GHSL-2026-140) exists in 7-Zip version 26.00, caused by an under-allocation in the NTFS compressed stream buffer (GetCuSize shift UB), potentially allowing attackers to exploit this issue for arbitrary code execution or application crashes.
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 function GetCuSize() computes a buffer size using a 32-bit shift that becomes undefined when the shift exponent reaches 32, leading to an undersized allocation.
Impact
On both x86 and x64 builds, the overflow can overwrite a vtable pointer and potentially lead to code execution, though on Windows the attacker may need heap feng shui to avoid an immediate fault; on low-memory systems the allocation may fail, limiting impact to denial of service.
What the attacker needed
Victim opens a crafted NTFS image; 7-Zip version 26.00 or earlier; on x64, at least 16 GB RAM for reliable exploitation
How it was found
- Craft an NTFS image with ClusterSizeLog set to 28 and a compressed data attribute with CompressionUnit equal to 4.
- Open the crafted image in 7-Zip; the NTFS handler is selected based on the 'NTFS ' signature.
- During extraction or testing, the undersized buffer is allocated and then overflowed with attacker-controlled data.
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.
7-Zip is a file archiver that can open many formats, including NTFS disk images. A bug in how it calculates the size of a buffer for compressed data means that a specially crafted image can make 7-Zip allocate a buffer that is far too small, then write a huge amount of data into it. This can crash the program or, 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.