GeezerVison is showing github.com — fix(extract): prevent symlink-follow truncation via FILE_FLAG_OPEN_REPARSE_POINT (#1116 follow-up) by ByGh00st · Pull Request #1195 · zip-rs/zip2
Conversation
ByGh00st
commented
Oct 26, 2026
•
edited by blacksmith-sh
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Follow-up hardening for #1116 (prevent following symbolic links during file creation).
Problem
In create_outfile, options.create(true).write(true).truncate(true) is invoked to open and create the target file. While fs::remove_file safely clears pre-existing symlinks and fs::symlink_metadata audits the path afterwards, on Windows, if an entry at outpath is swapped for a symbolic link or reparse point during concurrent filesystem activity, options.open(outpath) follows the link by default and truncates the external target before the post-open audit executes. Additionally, the post-open check audited fs::symlink_metadata(outpath) rather than the open file handle itself.
Solution
- Prevent Reparse Point Traversal: Configured
options.custom_flags(FILE_FLAG_OPEN_REPARSE_POINT) on Windows via windows_sys. This instructs CreateFileW to open the reparse point/symlink itself rather than following it across filesystem boundaries to external files.
- Handle-Based Metadata Audit: Audited
file.metadata()?.file_type().is_symlink() directly on the opened file handle, ensuring the open file descriptor itself is validated against symbolic links and reparse points.
Verification
cargo clippy --lib -- -D warnings: CLEAN (0 warnings)
tests/extract_symlink.rs: All symlink security regression suites pass.
![Autofix with [code]smith](/api/image?u=https%3A%2F%2Fcamo.githubusercontent.com%2F33b6f70f3541c4e93f4503d29cbfec051fa1b040d8e0ae9313a51c4ece44a627%2F68747470733a2f2f70722d636f6d6d656e74732d6173736574732e626c61636b736d6974682e73682f636f6465736d6974682f6175746f6669782d776974682d636f6465736d6974682d6461726b2d33782e706e67)
Need help on this PR? Tag @codesmith-bot with what you need.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.