-
Notifications
You must be signed in to change notification settings - Fork 7.6k
fix: stop FileCompressorTool from archiving out-of-tree symlink targets #6249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When if os.path.isfile(input_path):
zipf.write(input_path, os.path.basename(input_path))Remediation: Validate
Suggested change
For more details, see the finding in Corridor. Provide feedback: Reply with whether this is a valid vulnerability or false positive to help improve Corridor's accuracy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In with tarfile.open(output_path, mode) as tarf: # type: ignore[call-overload]
arcname = os.path.basename(input_path)
tarf.add(input_path, arcname=arcname, filter=_drop_links)Remediation: Validate
Suggested change
For more details, see the finding in Corridor. Provide feedback: Reply with whether this is a valid vulnerability or false positive to help improve Corridor's accuracy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During directory compression, the code validates each file path but discards the resolved, canonical path returned by
validate_file_path(...). The subsequent write uses the originalfull_path, creating a TOCTOU window where a symlink can be swapped between validation and use, allowing out-of-tree content to be archived.Project guardrail 59 requires using the canonical path returned by
validate_file_path()for the actual I/O to prevent TOCTOU races.Remediation: Use the resolved path from
validate_file_path(...)for the write operation.For more details, see the finding in Corridor.
Provide feedback: Reply with whether this is a valid vulnerability or false positive to help improve Corridor's accuracy.