Ruby JSON: Out of Bound Write in parser when `allow_control_characters: true` is enabled
Published 1 Dec 2026 · Updated 1 Dec 2026
Affected packages
- Affected
- >=2.18.0 <2.18.2
- Fixed in
- 2.18.2
bundle update --conservative json # Gemfile: '>= 2.18.2'- Affected
- >=2.19.0 <2.19.3
- Fixed in
- 2.19.3
bundle update --conservative json # Gemfile: '>= 2.19.3'Which json does your project really install?
Works for private projects: the file is read in memory to run the scan and then dropped. Also reads Gemfile.
Public repo?
Look after several Rails or Ruby apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Details
Summary
Parsing invalid JSON with the allow_control_characters: 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.
require "json"
doc = '"' + ("A" * 4096) + "\\\x01" + '"'
JSON.parse(doc, allow_control_characters: true)Impact
If the allow_control_characters: true option is used to parse untrusted input, it could be used as a DOS vector.
Is GHSA-cjpr-jw2g-fw99 in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected json, and gives you the command that fixes it.
More advisories for json
- LowCVE-2026-71847Ruby JSON: JSON::ResumableParser#partial_value dereferences a freed input buffer and crashes on truncated duplicate-key streams · 7 Aug 2026
- LowCVE-2026-54696Ruby json: JSON generator heap buffer overflow when streaming to an IO · 23 Jul 2026
- HighCVE-2026-33210Ruby JSON has a format string injection vulnerability · 19 Mar 2026
- HighCVE-2025-27788Out-of-bounds Read in Ruby JSON Parser · 12 Mar 2025
- HighCVE-2020-10663Unsafe object creation in json RubyGem · 27 Jul 2020
- HighCVE-2013-0269JSON gem has Improper Input Validation vulnerability · 24 Oct 2017
References
- Linkgithub.com/ruby/json/security/advisories/GHSA-cjpr-jw2g-fw99
- Linkgithub.com/ruby/json/commit/75e2f6453a3bf79df086ac10e41dbc5b7f124a76
- Linkgithub.com/ruby/json/commit/dcfbbcd36f240c18c3b89e5399105715f70162e3
- Packagegithub.com/ruby/json
- Linkgithub.com/ruby/json/releases/tag/v2.18.2
- Linkgithub.com/ruby/json/releases/tag/v2.19.3
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.