Skip to content

Commit 6a7b588

Browse files
authored
Backport #4759 to 4.0
Zip check allowlist (#4758) - backported to 4.0.
2 parents 3014bc3 + fff54d9 commit 6a7b588

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
@@ -67,8 +67,13 @@ def fs
6767
next unless File.readable?(file.realpath)
6868

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

0 commit comments

Comments
 (0)