Merged
Conversation
jkorany
reviewed
Dec 19, 2025
| # @param entry [Entry, Integer] Entry or entry index to extract | ||
| # @param output_path [String] Path where the file should be extracted | ||
| # @raise [Error] if extraction fails | ||
| def extract(entry, output_path) |
Collaborator
There was a problem hiding this comment.
Any concerns about the single entry path?
Contributor
Author
There was a problem hiding this comment.
Great question, normally yes. In this context though, this change is not even 100% necessary. The way we use 7-Zip in the application would prevent this type of attack, as we extract to a memory buffer, and the entry path is actually used as a label. That being said, this change is primarily for the gem itself, if it were ever to be used outside our application.
When using it outside of our application, a user may want to define their own file path which could cause issues. We could also add in an optional helper argument for sanitizing the path themselves during single extract if we wanted.
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
Prevent path traversal (Zip Slip) in
extract_allby validating entry paths stay within the target directory.Changes
safe_extract_pathhelper to validate and resolve paths../sequences that escape the extraction directoryBefore
After