We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c902335 commit 9c0cc49Copy full SHA for 9c0cc49
lib/hooks/app/helpers.rb
@@ -80,9 +80,9 @@ def load_handler(handler_class_name, handler_dir)
80
file_path = File.join(handler_dir, file_name)
81
82
# Security: Ensure the file path doesn't escape the handler directory
83
- normalized_handler_dir = File.expand_path(handler_dir)
84
- normalized_file_path = File.expand_path(file_path)
85
- unless normalized_file_path.start_with?(normalized_handler_dir)
+ normalized_handler_dir = Pathname.new(File.expand_path(handler_dir))
+ normalized_file_path = Pathname.new(File.expand_path(file_path))
+ unless normalized_file_path.descend.any? { |path| path == normalized_handler_dir }
86
error!("handler path outside of handler directory", 400)
87
end
88
0 commit comments