Re:Denial of Service and Unsafe Object Creation Vulnerabilit...
by jdleesmiller on Monday February 11, 2013 @03:06PM
(#5202908)
A few further notes on this, following some reading... The docs aren't very clear about it, either (http://flori.github.com/json/doc/index.html). There is a JSON.parse! method that they explicitly say is to be used only for trusted input, and it looks like JSON.load has some of the same default options.
To further confuse things, JSON.load has the very useful property that you can pass it a String or an IO (e.g. from Rack::Request#body), whereas JSON.parse only accepts a String.
edit: the docs will soon contain a warning about JSON.load; see https://github.com/flori/json/blob/master/lib/json/common.rb
Re:Denial of Service and Unsafe Object Creation Vulnerabilit...
by dbaupp on Monday February 11, 2013 @03:35PM
(#5203042)
Better would be load and load_trusted so that the safer function has the short (and expected) name.
Re:Denial of Service and Unsafe Object Creation Vulnerabilit...
by MatthewPhillips on Monday February 11, 2013 @11:20PM
(#5205166)
Why have the unsafe function at all?
Re:Denial of Service and Unsafe Object Creation Vulnerabilit...
by mikeash on Monday February 11, 2013 @06:35PM
(#5204160)
Better yet would be to remove the trusted functionality entirely and give a good talking-to to whoever wrote it. A generic JSON parser shouldn't have an unsafe parsing method on it period. If you want to implement clever nonsense like this, do it at the next layer up and call it something else.
This seems like poor method naming; I would not intuitively understand that "load" is far more dangerous than "parse."
Why not deprecate these and do names like
JSON.load_trusted
JSON.load_untrusted