Skip to content

bug: list command silently accepts path traversal entries in TAR archives #104

@bug-ops

Description

@bug-ops

The list command displays ../escape.txt (a traversal entry) without any warning or error when the archive is a TAR. This is inconsistent with ZIP behavior where list raises PathTraversal error.

Reproduction

# TAR with ../escape.txt entry:
exarch list partial.tar
# Output: shows ../escape.txt as a normal entry, exit 0

# ZIP with ../escape.txt entry:
exarch list partial.zip
# Error: path traversal detected: ../escape.txt, exit 1

Root cause

inspection/list.rs: list_tar_entries uses entry.path() (raw tar-rs path, no validation):

let path = entry.path()...into_owned();  // no ../  check

ZIP uses entry.enclosed_name() which returns None for traversal paths, converted to PathTraversal error.

Impact

  1. User confusion: list on a malicious TAR shows ../escape.txt as a valid path — no indication the archive is dangerous.
  2. CLI conflict-check bypass: The extract command calls list_archive before extracting to detect conflicts. For TAR, this list call succeeds even with traversal entries, so the conflict check is effectively bypassed. Extraction starts, and traversal is only caught mid-extraction, leaving partial files on disk (see enhancement: extraction is not atomic — partial state left on disk when error occurs mid-archive #89).
  3. Inconsistency: ZIP is safe, TAR is not.

Fix

In list_tar_entries, validate each path component for .. or null bytes, returning PathTraversal error (consistent with ZIP behavior). This also makes the CLI conflict pre-check effective for TAR archives with traversal entries.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions