Skip to content
Memory corruption Advisory Advanced CVE-2021-21772

3MF Consortium lib3mf NMR::COpcPackageReader::releaseZIP() use-after-free vulnerability

A use-after-free exists in lib3mf's COpcPackageReader::releaseZIP() because zip_close() frees the zip_source_t object that is then passed to zip_source_close(). An attacker can supply a crafted 3MF file to trigger the bug, potentially leading to code execution.

Lilith >_> Follow

Originally disclosed on Cisco Talos

High 8.1 View original

A use-after-free vulnerability exists in the NMR::COpcPackageReader::releaseZIP() functionality of 3MF Consortium lib3mf 2.0.0. A specially crafted 3MF file can lead to code execution.

Lilith >_>, 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, releaseZIP() calls zip_close() which frees the archive's source object, and then calls zip_source_close() on the same now-freed pointer.

Impact

A crafted 3MF file could lead to code execution, though the report notes the attacker must win a race to control the freed memory.

What the attacker needed

Victim opens a crafted 3MF file; attacker wins a race to control freed memory

How it was found

  1. Call ReadFromBuffer or ReadFromFile with a crafted 3MF file.
  2. The reader creates a COpcPackageReader and a zip_source_t object.
  3. An exception during processing causes releaseZIP() to be called.
  4. releaseZIP() calls zip_close(), which frees the zip_source_t object.
  5. releaseZIP() then calls zip_source_close() on the freed pointer, causing a use-after-free.

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 3MF file is a zip archive used for 3D printing. The library frees an internal zip object and then tries to use it again, which is a use-after-free. If an attacker can control what memory replaces the freed object, they might 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 Lilith >_>

View all

148 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.