CVE-2026-141523: Ruby JSON: Out of Bound Write in parser when `allow_control_characters: true` is enabled
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.
Other sources
Ruby JSON is a JSON implementation for Ruby. From 2.18.0 until 2.18.2 and 2.19.3, JSON.parse can perform an out-of-bounds write when allowcontrolcharacters is enabled and attacker-controlled invalid JSON contains sufficient padding before a backslash immediately followed by an ASCII control character. This malformed escape sequence can defeat the parser's bounds checks, potentially corrupting heap memory and more likely crashing the Ruby VM, which can cause denial of service in applications that parse untrusted input with the affected option. This issue is fixed in versions 2.18.2 and 2.19.3.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
rubygems/jsonto a version that resolves this vulnerability.Fixed in 2.19.3 - Upgrade
Upgrade
rubygems/jsonto a version that resolves this vulnerability.Fixed in 2.18.2 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 1.9.3 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 2.18.2 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 2.19.3
Event History
Frequently Asked Questions
Which applications are exposed?
Applications that parse attacker-controlled JSON with JSON.parse while allow_control_characters is enabled are exposed on affected Ruby JSON versions.
What does an attacker need to send to trigger the issue?
The input must be invalid JSON containing sufficient padding before a backslash that is immediately followed by an ASCII control character. Exploitation does not require authentication or user interaction.
What is the likely impact of successful exploitation?
The malformed escape sequence can cause an out-of-bounds write and heap-memory corruption. The more likely outcome is a Ruby VM crash, resulting in denial of service for the application parsing the input.
Which versions contain the fix?
The issue is fixed in Ruby JSON versions 2.18.2 and 2.19.3.