One Tarball, Multiple Outcomes: tar Implementation Incompatibilities Exposed
A researcher constructed a tar archive designed to exploit ambiguity in how different tools handle hard links with PAX headers. The archive includes a hard link with a PAX header specifying 512 bytes—exactly the size of a tar header. Though POSIX permits data in hard links within PAX archives, the specification leaves ambiguous how implementations should interpret this scenario.
The results are strikingly different across tools. GNU tar, BusyBox, Python, Go, and Perl ignore the size specification and extract normally. The bsdtar utility (macOS system tar) writes the 512 bytes into the hard link. Implementations including 7-Zip, node-tar, tar-fs, Rust’s tar, and astral-tokio-tar skip over the data, resulting in missing files. Java’s Commons Compress creates additional files containing header data. PHP’s PharData produces an empty hard link. RubyGems skips the hard link but creates a PaxHeaders directory. R incorrectly applies the size to a different file. Haskell’s tar extracts correctly but has UTF-8 encoding issues. Three implementations—.NET, Julia, and uv’s tar-codec—reject the archive as invalid.
The archive is one of 134 test cases in the tar-minefield collection, designed to document how implementations handle edge cases and specification ambiguities. A website displays extraction behavior across all tools.
Read the full article
Continue reading at Hacker News →This is an AI-generated summary. Read the original for the full story.