Ruby/json/2.18.2
This is a JSON implementation as a Ruby extension in C.
https://rubygems.org/gems/json
Ruby
3 Security Vulnerabilities
Ruby JSON has a format string injection vulnerability
- https://github.com/ruby/json/security/advisories/GHSA-3m6g-2423-7cp3
- https://github.com/advisories/GHSA-3m6g-2423-7cp3
- https://nvd.nist.gov/vuln/detail/CVE-2026-33210
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/json/CVE-2026-33210.yml
- https://github.com/ruby/json/commit/393b41c3e5f87491e1e34fa59fa78ff6fa179a74
- https://github.com/ruby/json/commit/3ce040622e500c4b981d578bb475fb0c23f86862
- https://access.redhat.com/errata/RHSA-2026:20596
- https://access.redhat.com/errata/RHSA-2026:20606
- https://access.redhat.com/errata/RHSA-2026:57565
- https://access.redhat.com/security/cve/CVE-2026-33210
- https://bugzilla.redhat.com/show_bug.cgi?id=2449871
- https://github.com/ruby/json/releases/tag/v2.15.2.1
- https://github.com/ruby/json/releases/tag/v2.17.1.2
- https://github.com/ruby/json/releases/tag/v2.18.3
- https://github.com/ruby/json/releases/tag/v2.19.2
- https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-33210.json
Impact
A format string injection vulnerability than that lead to denial of service attacks or information disclosure, when the allow_duplicate_key: false parsing option is used to parse user supplied documents.
This option isn't the default, if you didn't opt-in to use it, you are not impacted.
Patches
Patched in 2.19.2.
Workarounds
The issue can be avoided by not using the allow_duplicate_key: false parsing option.
Ruby json: JSON generator heap buffer overflow when streaming to an IO
- https://github.com/ruby/json/security/advisories/GHSA-x2f5-4prf-w687
- https://nvd.nist.gov/vuln/detail/CVE-2026-54696
- https://github.com/ruby/json/commit/996bac686d64e4e3aaeae03b14a7f9ee9695ebdb
- https://github.com/ruby/json/releases/tag/v2.19.9
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/json/CVE-2026-54696.yml
- https://github.com/advisories/GHSA-x2f5-4prf-w687
Summary
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. The issue is a heap out-of-bounds write in the IO-streaming path and is demonstrated as a reliable process crash / denial of service.
This was triaged on HackerOne as report #3785370. The issue was confirmed there and I was asked to open it here.
Details
Root cause is in ext/json/fbuffer/fbuffer.h, fbuffer_do_inc_capa().
On the IO path, the buffer is grown to FBUFFER_IO_BUFFER_SIZE (16383), but the early return checks total capacity instead of remaining capacity:
if (RB_UNLIKELY(fb->io)) {
if (fb->capa < FBUFFER_IO_BUFFER_SIZE) {
fbuffer_realloc(fb, FBUFFER_IO_BUFFER_SIZE);
} else {
fbuffer_flush(fb);
}
if (RB_LIKELY(requested < fb->capa)) {
return;
}
}
If fb->len already contains JSON syntax bytes, and a string flush has 16383 - fb->len <= requested < 16383, this check returns even though there is not enough space left. fbuffer_append_reserved() then writes past the buffer:
MEMCPY(fb->ptr + fb->len, newstr, char, len);
The minimal fix is to compare against the remaining capacity:
- if (RB_LIKELY(requested < fb->capa)) {
+ if (RB_LIKELY(requested <= fb->capa - fb->len)) {
return;
}
PoC
require "json"
require "stringio"
io = StringIO.new
big = "a" * 16385
big[16382] = '"' # escapable byte near the buffer boundary
JSON.dump([big], io)
Verified results:
Ruby 4.0.5 / bundled json 2.18.0:
malloc(): invalid size (unsorted)
.../json/common.rb:956: [BUG] Aborted
ruby/ruby master c78418b7a0 / json 2.19.8 / ASan:
heap-buffer-overflow WRITE of size 16382
fbuffer_append_reserved ext/json/fbuffer/fbuffer.h:145
search_flush ext/json/generator/generator.c:139
convert_UTF8_to_JSON ext/json/generator/generator.c:231
raw_generate_json_string ext/json/generator/generator.c:922
cState_m_generate ext/json/generator/generator.c:1891
Control: the same data through JSON.dump([big]) without an IO argument returns normally. The bug is specific to the IO-streaming path.
Impact
A remote attacker can trigger a heap out-of-bounds write if they control a string field that an application serializes through JSON.dump(obj, io) or JSON::State#generate(obj, io). The demonstrated impact is reliable denial of service. I am not claiming code execution or information disclosure.
JSON generator heap buffer overflow when streaming to an IO
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 was triaged on HackerOne as report #3785370. The issue was confirmed there and I was asked to open it here.
This issue has been fixed in version 2.19.9.
143 Other Versions
| Version | License | Security | Released | |
|---|---|---|---|---|
| 2.9.0 | Ruby | 2 | 2024-12-03 - 08:25 | about 2 years |
| 2.8.2 | Ruby | 2024-11-14 - 13:57 | about 2 years | |
| 2.8.1 | Ruby | 2024-11-06 - 17:36 | about 2 years | |
| 2.8.0 | Ruby | 2024-11-06 - 16:04 | about 2 years | |
| 2.8.0.alpha1 | Ruby | 2024-11-06 - 15:17 | about 2 years | |
| 2.7.6 | Ruby | 2024-11-04 - 13:20 | about 2 years | |
| 2.7.5 | Ruby | 2024-10-30 - 11:17 | about 2 years | |
| 2.7.4 | Ruby | 2024-10-25 - 10:57 | about 2 years | |
| 2.7.4.rc2 | Ruby | 2024-10-25 - 10:00 | about 2 years | |
| 2.7.4.rc1 | Ruby | 2024-10-25 - 08:44 | about 2 years | |
| 2.7.3 | Ruby | 2024-10-24 - 08:22 | about 2 years | |
| 2.7.3.rc1 | Ruby | 2024-10-23 - 07:41 | about 2 years | |
| 2.7.2 | Ruby | 2024-04-04 - 03:31 | over 2 years | |
| 2.7.1 | Ruby | 2023-12-05 - 04:13 | almost 3 years | |
| 2.7.0 | Ruby | 2023-12-01 - 06:38 | about 3 years | |
| 2.6.3 | Ruby | 2022-12-05 - 11:10 | almost 4 years | |
| 2.6.2 | Ruby | 2022-05-16 - 22:01 | over 4 years | |
| 2.6.1 | Ruby | 2021-10-24 - 00:23 | about 5 years | |
| 2.6.0 | Ruby | 2021-10-14 - 08:03 | about 5 years | |
| 2.5.1 | Ruby | 2020-12-22 - 12:49 | almost 6 years | |
| 2.5.0 | Ruby | 2020-12-22 - 10:45 | almost 6 years | |
| 2.4.1 | Ruby | 2020-12-17 - 05:16 | almost 6 years | |
| 2.4.0 | Ruby | 2020-12-15 - 10:49 | almost 6 years | |
| 2.3.1 | Ruby | 2020-06-30 - 12:17 | over 6 years | |
| 2.3.0 | Ruby | 2019-12-11 - 17:33 | almost 7 years | |
| 2.2.0 | Ruby | 2 | 2019-02-21 - 22:28 | almost 8 years |
| 2.1.0 | Ruby | 2 | 2017-04-18 - 09:40 | over 9 years |
| 2.0.4 | Ruby | 2 | 2017-04-11 - 10:42 | over 9 years |
| 2.0.3 | Ruby | 2 | 2017-01-12 - 14:21 | almost 10 years |
| 2.0.2 | Ruby | 2 | 2016-07-26 - 11:12 | over 10 years |
| 2.0.1 | Ruby | 2 | 2016-07-01 - 15:34 | over 10 years |
| 2.0.0 | Ruby | 2 | 2016-07-01 - 09:32 | over 10 years |
| 1.8.6 | Ruby | 2 | 2017-01-13 - 11:12 | almost 10 years |
| 1.8.5 | Ruby | 2 | 2017-01-12 - 11:47 | almost 10 years |
| 1.8.3 | Ruby | 2 | 2015-06-02 - 07:29 | over 11 years |
| 1.8.2 | Ruby | 2 | 2015-01-09 - 00:58 | almost 12 years |
| 1.8.1 | Ruby | 2 | 2013-10-17 - 12:05 | about 13 years |
| 1.8.0 | Ruby | 2 | 2013-05-13 - 12:57 | over 13 years |
| 1.7.7 | Ruby | 2 | 2013-02-11 - 18:12 | almost 14 years |
| 1.7.6 | UNKNOWN | 4 | 2012-12-31 - 00:41 | almost 14 years |
| 1.7.5 | UNKNOWN | 4 | 2012-08-17 - 19:00 | over 14 years |
| 1.7.4 | UNKNOWN | 4 | 2012-07-26 - 07:47 | over 14 years |
| 1.7.3 | UNKNOWN | 4 | 2012-05-11 - 22:27 | over 14 years |
| 1.7.2 | UNKNOWN | 4 | 2012-05-11 - 19:04 | over 14 years |
| 1.7.1 | UNKNOWN | 4 | 2012-05-07 - 11:29 | over 14 years |
| 1.7.0 | UNKNOWN | 4 | 2012-04-28 - 01:29 | over 14 years |
| 1.6.8 | UNKNOWN | 2 | 2013-02-11 - 18:05 | almost 14 years |
| 1.6.7 | UNKNOWN | 3 | 2012-04-28 - 01:17 | over 14 years |
| 1.6.6 | UNKNOWN | 3 | 2012-03-26 - 15:11 | over 14 years |
| 1.6.5 | UNKNOWN | 3 | 2012-01-15 - 14:50 | almost 15 years |
