fix: reject path traversal entries in TAR list command (#104)#108
Merged
fix: reject path traversal entries in TAR list command (#104)#108
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
list_tar_entriesnow validates each TAR entry path for..components and absolute pathsPathTraversalerror on detection, matching ZIPlistbehavior exactlyRoot Cause
list_tar_entriesusedentry.path()(raw tar-rs path, no validation), while ZIP listing usedentry.enclosed_name()which returnsNonefor traversal paths. The inconsistency allowedliston a malicious TAR to succeed with exit code 0, bypassing the pre-extraction conflict check.Changes
crates/exarch-core/src/inspection/list.rs: addcontains_traversal()helper + traversal check inlist_tar_entriesCHANGELOG.md: document the fixTests
5 new unit tests:
test_list_tar_path_traversal_dotdot—../escape.txt→ PathTraversaltest_list_tar_path_traversal_nested—foo/../../escape.txt→ PathTraversaltest_list_tar_path_traversal_absolute—/etc/passwd→ PathTraversaltest_list_tar_gz_path_traversal— same via gzip-compressed TARtest_list_tar_path_traversal_mixed_entries_fail_fast— safe entry + traversal entry → fail-fastTest plan
cargo +nightly fmt --all -- --checkpassescargo clippy --all-targets --all-features --workspace -- -D warningspassescargo nextest run --workspace --all-features --exclude exarch-python --exclude exarch-node --lib --bins— 584 passed, 3 skippedcargo deny checkpassesCloses #104