-
Notifications
You must be signed in to change notification settings - Fork 313
Fix CVE-2018-1000544 #371
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
Fix CVE-2018-1000544 #371
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,14 +147,21 @@ def next_header_offset #:nodoc:all | |
end | ||
|
||
# Extracts entry to file dest_path (defaults to @name). | ||
def extract(dest_path = @name, &block) | ||
block ||= proc { ::Zip.on_exists_proc } | ||
|
||
if @name.squeeze('/') =~ /\.{2}(?:\/|\z)/ | ||
def extract(dest_path = nil, &block) | ||
if dest_path.nil? && Pathname.new(@name).absolute? | ||
puts "WARNING: skipped absolute path in #{@name}" | ||
return self | ||
elsif @name.squeeze('/') =~ /\.{2}(?:\/|\z)/ | ||
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. Should this not also gain the |
||
puts "WARNING: skipped \"../\" path component(s) in #{@name}" | ||
return self | ||
elsif symlink? && get_input_stream.read =~ %r{../..} | ||
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. Could you add a test that this still works for non-malicious symlinks? It doesn't appear there is one. The comment on 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. Symlink could also links to absolute path |
||
puts "WARNING: skipped \"#{get_input_stream.read}\" symlink path in #{@name}" | ||
return self | ||
end | ||
|
||
dest_path ||= @name | ||
block ||= proc { ::Zip.on_exists_proc } | ||
|
||
if directory? || file? || symlink? | ||
__send__("create_#{@ftype}", dest_path, &block) | ||
else | ||
|
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.
Is
puts
ing a warning the best thing (most extensible) way to do things? I recognize that's what the previous code did, but it seems off to me. Maybe we should raise, or is there some kind of error reporting mechanism that we can surface to the user that's zipfile-wide?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.
Either way feel free to say that this is out of scope :)