Repository navigation
fix(core)!: stop trusting pre-existing symlinks in extraction destination - #816
Merged
Merged
Conversation
…tion Replace the directory cache with a per-component lstat walker so that every parent component below the destination is verified on each entry write. Pre-existing symlinks are refused by default; with symlinks allowed they are accepted only when they resolve inside the destination. Skip parent canonicalization when the parent is the destination root and refuse symlinked final components on non-Unix targets. BREAKING CHANGE: EntryValidator::validate_entry no longer takes a dir_cache argument, and ValidationContext no longer carries a lifetime parameter.
bug-ops
force-pushed
the
hotfix/dircache-symlink-escape
branch
from
November 2, 2026 12:41
a87d494 to
21ebe62
Compare
bug-ops
enabled auto-merge (squash)
November 2, 2026 12:41
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
Extraction previously cached directories it had "created" and trusted them for the rest of the run. A symlink already present in the destination was treated as such a directory, so entries could be written outside the destination.
DirCachewithDirWalker, which runslstaton every component below the destination for each entry write.SafePathno longer trusts the parent; the parent is canonicalized on every entry except when it is the destination root.Behavior change
By default extraction now fails if any component below the destination is a symlink, even one pointing inside the destination.
--allow-symlinksrestores that for contained links. A symlink as the destination root itself is still accepted.Breaking changes
EntryValidator::validate_entryno longer takes adir_cacheargument.ValidationContextno longer has a lifetime parameter.Known limitations
lstatand the write. Closing this fully requiresopenatfrom a pinned directory fd (follow-up).lstatand parent canonicalization; benchmarks were noisy and need a re-run on an idle machine.Test plan
tests/preexisting_dest_symlink.rsfor TAR, ZIP and 7z: directory entry through a link, intermediate component, no directory entries,--forceoverwrite, re-extraction, swap during extraction,--allow-symlinkswith an escaping link.cargo deny.