Skip to content

About

Bounded reader for untrusted archives in Go: zip, RAR 4/5, 7z, tar and gzip, xz, lzma, zstd, bzip2 or lz4 streams, detected by magic bytes and capped in memory and bytes.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

157 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-archive

License: MIT Go


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.

Quick start

go get github.com/Rethunk-Tech/go-archive

Rooting, caps, and a worked Extract and Lister example: HUMANS.md.

Features

  • Extract enforces 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.
  • ExtractFunc applies the same policy and hands each entry to a callback, for in-memory or non-filesystem sinks. ExtractReader extracts RAR and the streams from a plain io.Reader.
  • Extensions, HasExtension, StripExtension, IsStream and IsMediaType name the formats by file ending and by Content-Type.
  • Clean turns any string into a path segment Windows stores as written.
  • Lister walks 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.

Documentation

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

License

MIT — see LICENSE. © 2026 Rethunk.Tech, LLC. The vendored internal/rardecode keeps its BSD 2-Clause licence; see NOTICE.

About

Bounded reader for untrusted archives in Go: zip, RAR 4/5, 7z, tar and gzip, xz, lzma, zstd, bzip2 or lz4 streams, detected by magic bytes and capped in memory and bytes.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages