7zip UDF CInArchive::ReadFileItem Code Execution Vulnerability
An out-of-bounds read in 7-Zip's UDF file handling occurs because the PartitionRef field in a long allocation descriptor is not checked against the number of partition maps. An attacker could craft a malicious UDF file to cause a crash or potentially execute arbitrary code.
Originally disclosed on Cisco Talos
An out of bound read vulnerability exists in the CInArchive::ReadFileItem method functionality of 7zip for handling UDF files that can lead to denial of service or 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 code fails to validate that the PartitionRef index from a long allocation descriptor is within the bounds of the PartitionMaps vector before using it to access an array element.
Impact
An attacker could cause a denial of service (crash) and potentially achieve arbitrary code execution, though the report notes this may only happen 'in some circumstances'.
What the attacker needed
Victim opens a crafted UDF file
The fix
The vulnerability should be fixed by adding a bounds check to ensure PartitionRef is less than the size of the PartitionMaps vector before accessing it.
How it was found
- Create a UDF file with a malformed long allocation descriptor in the File Set Descriptor's RootDirICB.
- Set the PartitionRef field to a value larger than the number of partition maps (e.g., 0xff).
- Open the crafted file with 7-Zip.
- The program reads out of bounds and crashes with an access violation.
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 UDF (a filesystem used on optical discs). When opening a UDF file, it reads a field called PartitionRef to find which partition to use, but it does not check if that number is valid. A specially crafted file can make 7-Zip read memory outside its intended bounds, which may crash the program or, in some cases, allow an attacker 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.