Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 456836 - <dev-ruby/json-{1.6.8,1.7.7}: Denial of Service and Unsafe Object Creation (CVE-2013-0269)
Summary: <dev-ruby/json-{1.6.8,1.7.7}: Denial of Service and Unsafe Object Creation (C...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: Normal minor (vote)
Assignee: Gentoo Security
URL:
Whiteboard: B3 [noglsa]
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-11 19:20 UTC by Hans de Graaff
Modified: 2013-04-10 21:02 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hans de Graaff gentoo-dev Security 2013-02-11 19:20:02 UTC
Denial of Service and Unsafe Object Creation Vulnerability in JSON

There is a denial of service and unsafe object creation vulnerability in the json gem. This vulnerability has been assigned the CVE identifier CVE-2013-0269.

Versions Affected:  All. This includes JSON that ships with Ruby 1.9.X-pXXX.
Not affected:       NONE
Fixed Versions:     1.7.7, 1.6.8, 1.5.5

Impact 
------ 
When parsing certain JSON documents, the JSON gem can be coerced in to creating Ruby symbols in a target system.  Since Ruby symbols are not garbage collected, this can result in a denial of service attack.

The same technique can be used to create objects in a target system that act like internal objects.  These "act alike" objects can be used to bypass certain security mechanisms and can be used as a spring board for SQL injection attacks in Ruby on Rails.

Impacted code looks like this:

    JSON.parse(user_input)

Where the `user_input` variable will have a JSON document like this:

    {"json_class":"foo"}

The JSON gem will attempt to look up the constant "foo".  Looking up this constant will create a symbol.

In JSON version 1.7.x, objects with arbitrary attributes can be created using JSON documents like this:

    {"json_class":"JSON::GenericObject","foo":"bar"}

This document will result in an instance of JSON::GenericObject, with the attribute "foo" that has the value "bar".  Instantiating these objects will result in arbitrary symbol creation and in some cases can be used to bypass security measures.

PLEASE NOTE: this behavior *does not change* when using `JSON.load`.  `JSON.load` should *never* be given input from unknown sources.  If you are processing JSON from an unknown source, *always* use `JSON.parse`.

All users running an affected release should either upgrade or use one of the work arounds immediately. 

Releases 
-------- 
The FIXED releases are available at the normal locations.

Workarounds 
----------- 
For users that cannot upgrade, please use the attached patches.  If you cannot use the attached patches, change your code from this:

    JSON.parse(json)

To this:

    JSON.parse(json, :create_additions => false)

If you cannot change the usage of `JSON.parse` (for example you're using a gem which depends on `JSON.parse` like multi_json), then apply this monkey patch:

    module JSON
      class << self
        alias :old_parse :parse
        def parse(json, args = {})
          args[:create_additions] = false
          old_parse(json, args)
        end
      end
    end
Comment 1 Hans de Graaff gentoo-dev Security 2013-02-11 19:25:33 UTC
json 1.6.8 and json 1.7.7 have now been added to the tree. Please consider json 1.6.8 the stable candidate.

=dev-ruby/json-1.6.8
Comment 2 Sean Amoss (RETIRED) gentoo-dev Security 2013-02-24 13:09:51 UTC
(In reply to comment #1)
> json 1.6.8 and json 1.7.7 have now been added to the tree. Please consider
> json 1.6.8 the stable candidate.
> 
> =dev-ruby/json-1.6.8

Arches, please test and mark stable.
Comment 3 Agostino Sarubbo gentoo-dev 2013-02-24 14:46:33 UTC
ppc stable
Comment 4 Agostino Sarubbo gentoo-dev 2013-02-24 14:51:12 UTC
ppc64 stable
Comment 5 Agostino Sarubbo gentoo-dev 2013-02-24 15:10:07 UTC
ia64 stable
Comment 6 Agostino Sarubbo gentoo-dev 2013-02-24 17:22:48 UTC
hppa stable
Comment 7 Agostino Sarubbo gentoo-dev 2013-02-24 17:33:53 UTC
amd64 stable
Comment 8 Agostino Sarubbo gentoo-dev 2013-02-24 17:36:00 UTC
x86 stable
Comment 9 Agostino Sarubbo gentoo-dev 2013-02-24 18:47:49 UTC
sparc stable
Comment 10 Agostino Sarubbo gentoo-dev 2013-02-24 19:49:44 UTC
s390 stable
Comment 11 Agostino Sarubbo gentoo-dev 2013-02-24 19:58:10 UTC
arm stable
Comment 12 Agostino Sarubbo gentoo-dev 2013-02-26 10:16:43 UTC
alpha stable
Comment 13 Agostino Sarubbo gentoo-dev 2013-02-26 18:53:27 UTC
sh stable
Comment 14 GLSAMaker/CVETool Bot gentoo-dev 2013-03-04 23:21:23 UTC
CVE-2013-0269 (http://nvd.nist.gov/nvd.cfm?cvename=CVE-2013-0269):
  The JSON gem 1.7.x before 1.7.7, 1.6.x before 1.6.8, and 1.5.x before 1.5.5
  allows remote attackers to cause a denial of service (resource consumption)
  or bypass the mass assignment protection mechanism via a crafted JSON
  document that triggers the creation of arbitrary Ruby symbols or certain
  internal objects, as demonstrated by conducting a SQL injection attack
  against Ruby on Rails, aka "Unsafe Object Creation Vulnerability."
Comment 15 Tobias Heinlein (RETIRED) gentoo-dev 2013-03-24 19:44:07 UTC
Ready for vote, I vote NO.
Comment 16 Sean Amoss (RETIRED) gentoo-dev Security 2013-04-10 21:02:05 UTC
GLSA vote: no, too

Closing noglsa.