]> source.dussan.org Git - redmine.git/commitdiff
Rails CVE-2012-2660.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 3 Jun 2012 20:08:23 +0000 (20:08 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 3 Jun 2012 20:08:23 +0000 (20:08 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9767 e93f8b46-1217-0410-a6f0-8f06a7374b81

config/initializers/10-patches.rb

index 9591070485b971dd6b320a5a4ea8f078a1c1aa6f..43cd7d0a8d433c32bb0eaae548b0e1c76be2b409 100644 (file)
@@ -85,4 +85,30 @@ module ActionController
       end
     end
   end
+
+  # CVE-2012-2660
+  # https://groups.google.com/group/rubyonrails-security/browse_thread/thread/f1203e3376acec0f
+  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