Ruby JSON is a JSON implementation for Ruby. From version 2.14.0 to before versions 2.15.2.1, 2.17.1.2, and 2.19.2, a format string injection vulnerability can lead to denial of service attacks or information disclosure, when the allowduplicatekey: false parsing option is used to parse user supplied documents. This issue has been patched in versions 2.15.2.1, 2.17.1.2, and 2.19.2.
Summary
Parsing invalid JSON with the allowcontrolcharacters: true option enabled can result in an out of bound write, potentially corrupting the heap, but more likely a VM crash.
Details
If an ASCI control character is preceded by a backslash, the bound checks can be defeated.
Originally fixed as a regular bug in json 1.9.3.
Proof of concept
The issue can easily be reproduced with a backslash followed by a control character. Some padding is required.
ruby require "json" doc = '"' + ("A" 4096) + "\\\x01" + '"' JSON.parse(doc, allowcontrolcharacters: true)
Impact
If the allowcontrolcharacters: true option is used to parse untrusted input, it could be used as a DOS vector.
Ruby JSON is a JSON implementation for Ruby. Versions 2.9.0 through 2.19.8 are vulnerable to heap buffer overflow when the JSON generator is provided with an oversized streamed object. When streaming to an IO JSON.dump(obj, io) and JSON::State#generate(obj, io) can write past the internal JSON generator buffer when a streamed object contains an attacker-controlled string near 16 KB. Exploitation would result in a reliable process crash/denial of service. This issue has been fixed in version 2.19.9.