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

Libarchive 7zip read_SubStreamsInfo Code Execution Vulnerability

A heap overflow in libarchive's 7zip parsing allows an attacker to cause memory corruption via a crafted 7zip file, potentially leading to code execution.

Marcin 'Icewall' Noga Follow

Originally disclosed on Cisco Talos

High 7.8 View original

An exploitable \heap overflow vulnerability exists in the 7zip readSubStreamsInfo functionality of libarchive. A specially crafted 7zip file can cause a integer overflow resulting in memory corruption that can lead 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 an integer overflow when summing numUnpackStreams across folders, leading to an undersized heap allocation and subsequent buffer overflow.

Impact

An attacker could cause memory corruption and potentially execute code, though the CVSS vector indicates local access with user interaction.

What the attacker needed

Victim opens a crafted 7zip file; libarchive 3.1.2 or similar

How it was found

  1. Craft a 7zip file with more than 42 folders and large numUnpackStreams values to overflow the sum.
  2. Open the file with a libarchive-based extractor, triggering read_SubStreamsInfo.
  3. The overflowed sum causes a small calloc allocation for unpackSizes.
  4. Subsequent parsing writes beyond the allocated buffer, causing heap corruption.

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.

When libarchive opens a 7zip file, it reads a count of sub-streams and adds them up. If the total is too large, the number wraps around to a small value, so the program allocates a tiny buffer but then writes many more values into it, overflowing the buffer. This can crash the program or 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.

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.