Skip to content
Memory corruption Advisory Advanced CVE-2016-4302

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.

Marcin 'Icewall' Noga Follow

Originally disclosed on Cisco Talos

High 7.8 View original

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.

Marcin ‘Icewall’ Noga, on Cisco Talos

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

  1. Open a crafted RAR file with libarchive and read its header.
  2. Extract the archive so the compressed data path runs.
  3. The parser reads further headers that set dictionary_size to zero.
  4. The PPMd context is allocated with size zero.
  5. 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.

More by Marcin 'Icewall' Noga

View all

9 more disclosed reports, best first.

More from Cisco Talos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.