Libarchive Rar RestartModel Code Execution Vulnerability
A crafted RAR archive causes libarchive to allocate a zero-byte PPMd context and then write into it during model restart, corrupting adjacent heap memory. An attacker could use this heap corruption to potentially achieve code execution when a victim extracts the file.
Originally disclosed on Cisco Talos
An exploitable heap overflow vulnerability exists in the Rar decompression functionality of libarchive. A specially crafted Rar file can cause a heap corruption eventually leading 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 RAR parser lets a later header reset dictionary_size to zero after it was set, so Ppmd7_Alloc allocates a zero-byte buffer and RestartModel writes past it.
Impact
Heap corruption occurs during extraction and could lead to code execution, though the report only demonstrates the corruption and crash, not a working exploit.
What the attacker needed
Victim opens or extracts a crafted RAR file; libarchive used for extraction
How it was found
- Open a crafted RAR file with libarchive and read its header.
- Extract the archive so the compressed data path runs.
- The parser reads further headers that set dictionary_size to zero.
- The PPMd context is allocated with size zero.
- RestartModel writes into the zero-size buffer, corrupting the heap.
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 library that opens RAR archives can be tricked by a malformed file into reserving no memory at all for a decompression structure, then writing data into that empty space. Those writes land in memory belonging to other objects, which is called heap corruption. If an attacker controls the data, this can sometimes be turned into running their own code on the victim's machine.
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.