The Hardest Tarball?
An archive constructed with GNU tar extracts into eight distinct ways across various tools due to ambiguous POSIX pax header specifications and hard link handling.
read it A fascinating deep dive into how multiple tar libraries diverge wildly on a single malformed archive, illustrating parser differentials.
summary
The author constructs a specialized tarfile using GNU tar that exploits ambiguous POSIX rules regarding pax extended headers and hard link sizes. Depending on the extraction library—ranging from GNU tar and bsdtar to Rust, Go, and Java implementations—the archive yields eight completely different file structures or gets rejected entirely. This test case is part of a broader collection called tar-minefield, exposing widespread inconsistencies in how languages parse legacy file formats. The discussion highlights the tension between strict security for software distribution and best-effort extraction for backups.
key points
- A single tarball with a hard link and pax size override produces eight entirely different extraction results across tools like GNU tar, bsdtar, 7-Zip, and PHP.
- Modern strict parsers reject the archive entirely, highlighting a shift toward safety over POSIX-compliant best-effort extraction in package managers.
- The test case is part of haampie/tar-minefield, a growing suite of tricky tarballs exposing parser differentials.
who should read it
Systems programmers, security engineers, and developers maintaining file parsers or archive utilities.
discussion positive
consensus
Commenters note that tar serves two conflicting threat models—strict safety for software distribution versus best-effort recovery for backups—making strict rejection ideal for some contexts and leniency for others.
pushback
Some argue that pax extended headers should not completely override base header fields when original values are valid, pointing out flaws in the POSIX specification itself.
“Precisely” and “simply” are not words I would use to describe pax’s prescriptions around data-bearing hardlink members.
(I maintain several of the tar parsers mentioned in this post, which I appreciate for its clear treatment of a larger differential problem in the tar ecosystem.)
A maintainer of several tar parsers explains the real-world difficulty of implementing pax prescriptions and differential behaviors.
Generated by an LLM from the article and thread. Check the sources before relying on it.