Skip to content

fix(sevenz): restore allow_absolute_paths for 7z with sevenz-rust2 0.21.1#375

Merged
bug-ops merged 1 commit into
mainfrom
fix/374-sevenz-021-compat
Jun 29, 2026
Merged

fix(sevenz): restore allow_absolute_paths for 7z with sevenz-rust2 0.21.1#375
bug-ops merged 1 commit into
mainfrom
fix/374-sevenz-021-compat

Conversation

@bug-ops

@bug-ops bug-ops commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

Root cause

sevenz-rust2 0.21.1 added a path-safety check inside decompress_with_extract_fn that rejects entries whose resolved path escapes the destination directory. The check fires before the caller's extraction callback is invoked, so EntryValidator never sees absolute-path entries. This broke test_7z_absolute_path_with_flag_writes_to_dest across all platforms.

Fix

Switch extract_with_callback to call ArchiveReader::for_each_entries directly. That lower-level API has no built-in path check, so EntryValidator remains the sole authoritative guard for path security (traversal prevention, absolute-path stripping, symlink rejection). All existing security properties are preserved.

Test plan

  • cargo nextest run -p exarch-core -- test_7z_absolute_path — all 3 tests pass
  • cargo nextest run --workspace --all-features --exclude exarch-python --exclude exarch-node — 931/931 pass
  • cargo +nightly fmt --all -- --check — clean
  • cargo clippy --workspace --all-targets --all-features -- -D warnings — clean
  • Closes chore(deps): bump the minor-and-patch group with 4 updates #374

…olute_paths for 7z

sevenz-rust2 0.21.1 adds a path-safety check inside decompress_with_extract_fn
that blocks absolute-path entries before our callback runs. This breaks the
allow_absolute_paths flag for 7z archives because EntryValidator never sees
those entries.

Switch extract_with_callback to use ArchiveReader::for_each_entries directly.
That API has no built-in path check, so our EntryValidator remains the sole
and authoritative guard for path security (traversal, absolute paths, symlinks).

Also bumps anyhow (UB fix in Error::downcast_mut), napi, napi-derive, and
sevenz-rust2 to their latest patch releases via Cargo.lock.

Fixes #374
@github-actions github-actions Bot added core Changes to exarch-core dependencies Dependency updates labels Jun 29, 2026
@bug-ops bug-ops merged commit 52e9b1e into main Jun 29, 2026
24 checks passed
@bug-ops bug-ops deleted the fix/374-sevenz-021-compat branch June 29, 2026 17:42
bug-ops added a commit that referenced this pull request Jun 29, 2026
…, #365) (#377)

On Unix, entry names containing `\` (e.g. `..\..\\x`) were treated as a
single path component by std's PathBuf, bypassing traversal detection in
SafePath::validate. The upstream sevenz-rust2 safe_join that previously
rejected these was removed in #375 when switching to for_each_entries.

Add `formats::common::normalize_entry_name` that replaces `\` with `/`
before PathBuf construction. Apply it in all three 7z entry-name sites:
the extraction pre-validation loop, the extraction callback, and the
list/verify path in inspection/list.rs. This ensures extract, list, and
verify all agree on traversal detection.

ZIP is unaffected (zip crate handles Windows paths internally via
enclosed_name). TAR is correctly left un-normalized (`\` is a legal
Unix filename character in TAR).

Closes #376
Closes #365
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes to exarch-core dependencies Dependency updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant