[#1025] Fix Rails vulnerability (CVE-2012-2660)

This commit is contained in:
Holger Just 2012-06-01 20:56:09 +02:00
parent 9d32e68ec0
commit f959b9bdb9
1 changed files with 28 additions and 0 deletions

View File

@ -115,4 +115,32 @@ module ActionController
end end
end end
end end
# Backported fix for CVE-2012-2660
# https://groups.google.com/group/rubyonrails-security/browse_thread/thread/f1203e3376acec0f
# TODO: Remove this once we are on Rails >= 3.2.4
require 'action_controller/request'
class Request
protected
# Remove nils from the params hash
def deep_munge(hash)
hash.each_value do |v|
case v
when Array
v.grep(Hash) { |x| deep_munge(x) }
when Hash
deep_munge(v)
end
end
keys = hash.keys.find_all { |k| hash[k] == [nil] }
keys.each { |k| hash[k] = nil }
hash
end
def parse_query(qs)
deep_munge(super)
end
end
end end