Skip to content

Commit b2d1f2a

Browse files
authored
Backport #4760 to 3.1
Zip check allowlist (#4758) - backport to 3.1.
2 parents ff2326c + 6d111c3 commit b2d1f2a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

apps/dashboard/app/controllers/files_controller.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,13 @@ def fs
6868
next unless File.readable?(file.realpath)
6969

7070
if File.file?(file.realpath)
71-
zip.write_deflated_file(file.relative_path.to_s) do |zip_file|
72-
IO.copy_stream(file.realpath, zip_file)
71+
File.open(file.realpath, 'rb') do |opened_file|
72+
real_path = File.readlink("/proc/self/fd/#{opened_file.fileno}")
73+
next unless AllowlistPolicy.default.permitted?(real_path)
74+
75+
zip.write_deflated_file(file.relative_path.to_s) do |zip_file|
76+
IO.copy_stream(opened_file, zip_file)
77+
end
7378
end
7479
else
7580
zip.add_empty_directory(dirname: file.relative_path.to_s)

0 commit comments

Comments
 (0)