Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joseph-ravenwolfe/7795942 to your computer and use it in GitHub Desktop.
Save joseph-ravenwolfe/7795942 to your computer and use it in GitHub Desktop.
Rails DDOS Vulnerability Patch
# config/initializers/action_view_header_caching_handler.rb
ActiveSupport.on_load(:action_view) do
ActionView::LookupContext::DetailsKey.class_eval do
class << self
alias :old_get :get
def get(details)
if details[:formats]
details = details.dup
syms = Set.new Mime::SET.symbols
details[:formats] = details[:formats].select { |v|
syms.include? v
}
end
old_get details
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment