Skip to content

fix: reject path traversal entries in TAR list command (#104)#108

Merged
bug-ops merged 2 commits intomainfrom
list-tar-path-traversal
Mar 15, 2026
Merged

fix: reject path traversal entries in TAR list command (#104)#108
bug-ops merged 2 commits intomainfrom
list-tar-path-traversal

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 15, 2026

Summary

  • list_tar_entries now validates each TAR entry path for .. components and absolute paths
  • Returns PathTraversal error on detection, matching ZIP list behavior exactly
  • Fixes the CLI conflict-check bypass where a malicious TAR could pass the pre-extraction list phase

Root Cause

list_tar_entries used entry.path() (raw tar-rs path, no validation), while ZIP listing used entry.enclosed_name() which returns None for traversal paths. The inconsistency allowed list on a malicious TAR to succeed with exit code 0, bypassing the pre-extraction conflict check.

Changes

  • crates/exarch-core/src/inspection/list.rs: add contains_traversal() helper + traversal check in list_tar_entries
  • CHANGELOG.md: document the fix

Tests

5 new unit tests:

  • test_list_tar_path_traversal_dotdot../escape.txt → PathTraversal
  • test_list_tar_path_traversal_nestedfoo/../../escape.txt → PathTraversal
  • test_list_tar_path_traversal_absolute/etc/passwd → PathTraversal
  • test_list_tar_gz_path_traversal — same via gzip-compressed TAR
  • test_list_tar_path_traversal_mixed_entries_fail_fast — safe entry + traversal entry → fail-fast

Test plan

  • cargo +nightly fmt --all -- --check passes
  • cargo clippy --all-targets --all-features --workspace -- -D warnings passes
  • cargo nextest run --workspace --all-features --exclude exarch-python --exclude exarch-node --lib --bins — 584 passed, 3 skipped
  • cargo deny check passes

Closes #104

list_tar_entries now validates each entry path for parent directory
components (..) and absolute paths, returning PathTraversal error
consistent with ZIP listing behavior.

Closes #104
@github-actions github-actions bot added core Changes to exarch-core docs Documentation labels Mar 15, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 15, 2026 02:25
@bug-ops bug-ops merged commit 8199757 into main Mar 15, 2026
20 checks passed
@bug-ops bug-ops deleted the list-tar-path-traversal branch March 15, 2026 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes to exarch-core docs Documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant