Login
Log in using an SSO provider:
Fedora Account System
Red Hat Associate
Red Hat Customer
Login using a Red Hat Bugzilla account
Forgot Password
Create an Account
Red Hat Bugzilla – Attachment 674509 Details for
Bug 892870
CVE-2013-0156 rubygem-activesupport: Multiple vulnerabilities in parameter parsing in ActionPack
Home
New
Search
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh92 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
[?]
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
actionpack-CVE-2012-0156-2-3-xml_parsing.patch
actionpack-CVE-2012-0156-2-3-xml_parsing.patch (text/plain), 6.36 KB, created by
Kurt Seifried
on 2013-01-08 06:03:08 UTC
(
hide
)
Description:
actionpack-CVE-2012-0156-2-3-xml_parsing.patch
Filename:
MIME Type:
Creator:
Kurt Seifried
Created:
2013-01-08 06:03:08 UTC
Size:
6.36 KB
patch
obsolete
>From 0da62718fd177d27b5488239662ef1544fb2159f Mon Sep 17 00:00:00 2001 >From: Jeremy Kemper <jeremy@bitsweat.net> >Date: Sat, 5 Jan 2013 17:46:26 -0700 >Subject: [PATCH] Safe XML params parsing. Doesn't allow symbols or yaml. > >--- > actionpack/lib/action_controller/params_parser.rb | 2 +- > actionpack/test/controller/webservice_test.rb | 13 +++++++++ > .../active_support/core_ext/hash/conversions.rb | 28 +++++++++++++++----- > activesupport/test/core_ext/hash_ext_test.rb | 18 ++++++++++++- > 4 files changed, 52 insertions(+), 9 deletions(-) > >diff --git a/actionpack/lib/action_controller/params_parser.rb b/actionpack/lib/action_controller/params_parser.rb >index f7e3c54..927ca95 100644 >--- a/actionpack/lib/action_controller/params_parser.rb >+++ b/actionpack/lib/action_controller/params_parser.rb >@@ -31,7 +31,7 @@ module ActionController > strategy.call(request.raw_post) > when :xml_simple, :xml_node > body = request.raw_post >- body.blank? ? {} : Hash.from_xml(body).with_indifferent_access >+ body.blank? ? {} : Hash.from_safe_xml(body).with_indifferent_access > when :yaml > YAML.load(request.raw_post) > when :json >diff --git a/actionpack/test/controller/webservice_test.rb b/actionpack/test/controller/webservice_test.rb >index e89d6bb..9fea20d 100644 >--- a/actionpack/test/controller/webservice_test.rb >+++ b/actionpack/test/controller/webservice_test.rb >@@ -121,6 +121,19 @@ class WebServiceTest < ActionController::IntegrationTest > end > end > >+ def test_post_xml_using_a_disallowed_type_attribute >+ $stderr = StringIO.new >+ with_test_route_set do >+ post '/', '<foo type="symbol">value</foo>', 'CONTENT_TYPE' => 'application/xml' >+ assert_response 500 >+ >+ post '/', '<foo type="yaml">value</foo>', 'CONTENT_TYPE' => 'application/xml' >+ assert_response 500 >+ end >+ ensure >+ $stderr = STDERR >+ end >+ > def test_register_and_use_yaml > with_test_route_set do > ActionController::Base.param_parsers[Mime::YAML] = Proc.new { |d| YAML.load(d) } >diff --git a/activesupport/lib/active_support/core_ext/hash/conversions.rb b/activesupport/lib/active_support/core_ext/hash/conversions.rb >index a43763f..c586cf4 100644 >--- a/activesupport/lib/active_support/core_ext/hash/conversions.rb >+++ b/activesupport/lib/active_support/core_ext/hash/conversions.rb >@@ -26,6 +26,12 @@ module ActiveSupport #:nodoc: > end > end > >+ class DisallowedType < StandardError #:nodoc: >+ def initialize(type) >+ super "Disallowed type attribute: #{type.inspect}" >+ end >+ end >+ > XML_TYPE_NAMES = { > "Symbol" => "symbol", > "Fixnum" => "integer", >@@ -160,12 +166,20 @@ module ActiveSupport #:nodoc: > end > > module ClassMethods >- def from_xml(xml) >- typecast_xml_value(unrename_keys(XmlMini.parse(xml))) >+ def from_xml(xml, disallowed_types = nil) >+ typecast_xml_value(unrename_keys(XmlMini.parse(xml)), disallowed_types || []) >+ end >+ >+ def from_safe_xml(xml) >+ from_xml xml, %w(symbol yaml) > end > > private >- def typecast_xml_value(value) >+ def typecast_xml_value(value, disallowed_types) >+ if value.include?('type') && !value['type'].is_a?(Hash) && disallowed_types.include?(value['type']) >+ raise DisallowedType, value['type'] >+ end >+ > case value.class.to_s > when 'Hash' > if value['type'] == 'array' >@@ -175,9 +189,9 @@ module ActiveSupport #:nodoc: > else > case entries.class.to_s # something weird with classes not matching here. maybe singleton methods breaking is_a? > when "Array" >- entries.collect { |v| typecast_xml_value(v) } >+ entries.collect { |v| typecast_xml_value(v, disallowed_types) } > when "Hash" >- [typecast_xml_value(entries)] >+ [typecast_xml_value(entries, disallowed_types)] > else > raise "can't typecast #{entries.inspect}" > end >@@ -205,7 +219,7 @@ module ActiveSupport #:nodoc: > nil > else > xml_value = value.inject({}) do |h,(k,v)| >- h[k] = typecast_xml_value(v) >+ h[k] = typecast_xml_value(v, disallowed_types) > h > end > >@@ -214,7 +228,7 @@ module ActiveSupport #:nodoc: > xml_value["file"].is_a?(StringIO) ? xml_value["file"] : xml_value > end > when 'Array' >- value.map! { |i| typecast_xml_value(i) } >+ value.map! { |i| typecast_xml_value(i, disallowed_types) } > case value.length > when 0 then nil > when 1 then value.first >diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb >index 44308c3..4cbe64d 100644 >--- a/activesupport/test/core_ext/hash_ext_test.rb >+++ b/activesupport/test/core_ext/hash_ext_test.rb >@@ -833,6 +833,22 @@ class HashToXmlTest < Test::Unit::TestCase > assert_equal expected_product_hash, Hash.from_xml(product_xml)["product"] > end > >+ def test_from_xml_raises_on_disallowed_type_attributes >+ assert_raise Hash::DisallowedType do >+ Hash.from_xml '<product><name type="foo">value</name></product>', %w(foo) >+ end >+ end >+ >+ def test_from_safe_xml_raises_on_disallowed_type_attributes >+ assert_raise Hash::DisallowedType do >+ Hash.from_safe_xml '<product><name type="symbol">value</name></product>' >+ end >+ >+ assert_raise Hash::DisallowedType do >+ Hash.from_safe_xml '<product><name type="yaml">value</name></product>' >+ end >+ end >+ > def test_should_use_default_value_for_unknown_key > hash_wia = HashWithIndifferentAccess.new(3) > assert_equal 3, hash_wia[:new_key] >@@ -867,7 +883,7 @@ class HashToXmlTest < Test::Unit::TestCase > > def test_empty_string_works_for_typecast_xml_value > assert_nothing_raised do >- Hash.__send__(:typecast_xml_value, "") >+ Hash.__send__(:typecast_xml_value, "", []) > end > end > >-- >1.7.10.2 (Apple Git-33) >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 892870
:
674509
|
674510
|
674511
|
674512
|
675064
|
675066
|
675067
|
675068
|
675069
|
675070
|
675071
|
675072
|
675077
|
675078
|
675079
|
675080