One reader for untrusted archives, as a single Go package: archive, module
github.com/Rethunk-Tech/go-archive.
Magic bytes pick the format, never the file extension. Eleven are read: zip, RAR 4, RAR 5, 7z, tar, and gzip, xz, lzma, zstd, bzip2 or lz4, each alone or wrapped around a tar. A zip entry may be stored or compressed with Deflate, bzip2, LZMA, xz or zstd. Archives arrive from the internet with no trust attached, so every reader here is bounded in memory and in bytes before it produces output.
go get github.com/Rethunk-Tech/go-archiveRooting, caps, and a worked Extract and Lister example: HUMANS.md.
Extractenforces policy: path traversal, unsafe names, case collisions, symlinks and hardlinks, device and pipe entries, encryption, and the entry, entry-size, total-size and ratio caps.ExtractFuncapplies the same policy and hands each entry to a callback, for in-memory or non-filesystem sinks.ExtractReaderextracts RAR and the streams from a plainio.Reader.Extensions,HasExtension,StripExtension,IsStreamandIsMediaTypename the formats by file ending and byContent-Type.Cleanturns any string into a path segment Windows stores as written.Listerwalks entries forward-only and applies no extraction policy. Decompression is its only bound (ListerOptions.MaxEntryBytes).- The destination must already exist. Writes travel through the caller's
*os.Root, so no entry resolves outside it. - Decoder windows are capped independently of entry sizes, so a crafted header cannot force a multi-gigabyte allocation.
- Fuzzed against every format, with the crash corpus committed.
| Doc | Audience |
|---|---|
| HUMANS.md | Running and using the package |
| AGENTS.md | Internals, invariants, and why |
| CONTRIBUTING.md | Process — commits, tests, docs |
| SECURITY.md | Vulnerability disclosure |
| CHANGELOG.md | Release notes |
MIT — see LICENSE. © 2026 Rethunk.Tech, LLC. The vendored internal/rardecode keeps its BSD 2-Clause licence; see NOTICE.