Normalize paths
Reject absolute paths and entries that escape the chosen destination through parent-directory components.
Family 03
Bundling files and compressing bytes are different operations. ZIP does both in one container; tar and gzip are often composed as two layers.
| Format | Model | Good fit | Watch for |
|---|---|---|---|
| ZIP .zipapplication/zip | A multi-entry archive. Each entry can be stored or compressed, with a central directory describing the collection. | Portable bundles where individual files should remain addressable. | Compression method and encryption support vary. A .zip extension does not guarantee that every reader supports every feature. |
| gzip .gzapplication/gzip | A compressed data stream with a small header and trailer; conventionally wraps one input stream rather than a directory tree. | Compressing a single file or the output of another archival format. | Original filename and timestamp are optional header fields, not a complete filesystem model. |
| tar .tarapplication/x-tar | A sequential archive of filesystem entries and metadata. Classic tar itself does not imply compression. | Preserving a directory tree before applying a stream compressor. | There are multiple tar variants and extensions. Metadata portability depends on producer and reader. |
An archive is input to a filesystem operation. Validate entries before writing them, especially when the archive is untrusted.
Reject absolute paths and entries that escape the chosen destination through parent-directory components.
Symbolic links and hard links can redirect later writes outside the expected extraction tree.
Bound entry count, expanded size, nesting depth, and processing time before extraction.