Fix CVE-2018-1000544 symlink path traversal
Not sure if the exception is the right way to go
This commit is contained in:
parent
6e0d23178a
commit
8e78311d67
|
@ -154,6 +154,9 @@ module Zip
|
||||||
elsif @name.squeeze('/') =~ /\.{2}(?:\/|\z)/
|
elsif @name.squeeze('/') =~ /\.{2}(?:\/|\z)/
|
||||||
puts "WARNING: skipped \"../\" path component(s) in #{@name}"
|
puts "WARNING: skipped \"../\" path component(s) in #{@name}"
|
||||||
return self
|
return self
|
||||||
|
elsif symlink? && get_input_stream.read =~ %r{../..}
|
||||||
|
puts "WARNING: skipped \"#{get_input_stream.read}\" symlink path in #{@name}"
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
dest_path ||= @name
|
dest_path ||= @name
|
||||||
|
|
Binary file not shown.
|
@ -177,4 +177,14 @@ class ZipEntryTest < MiniTest::Test
|
||||||
|
|
||||||
assert File.exist?("#{path}/tmp/file.txt")
|
assert File.exist?("#{path}/tmp/file.txt")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_entry_name_with_relative_symlink
|
||||||
|
assert_raises Errno::ENOENT do
|
||||||
|
Zip::File.open('test/data/symlink.zip') do |zip_file|
|
||||||
|
zip_file.each do |entry|
|
||||||
|
entry.extract
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue