|
| 1 | +--- |
| 2 | +layout: advisory |
| 3 | +title: 'CVE-2026-71847 (json): Ruby JSON - JSON::ResumableParser#partial_value dereferences |
| 4 | + a freed input buffer and crashes on truncated duplicate-key streams' |
| 5 | +comments: false |
| 6 | +categories: |
| 7 | +- json |
| 8 | +advisory: |
| 9 | + gem: json |
| 10 | + cve: 2026-71847 |
| 11 | + ghsa: 9hj4-r449-hfvc |
| 12 | + url: https://nvd.nist.gov/vuln/detail/CVE-2026-71847 |
| 13 | + title: Ruby JSON - JSON::ResumableParser#partial_value dereferences a freed input |
| 14 | + buffer and crashes on truncated duplicate-key streams |
| 15 | + date: 2026-08-07 |
| 16 | + description: |- |
| 17 | + ### Summary |
| 18 | +
|
| 19 | + Ruby's JSON native C extension clears the consumed `JSON::ResumableParser` |
| 20 | + input buffer but leaves `state.start`, `state.cursor`, and `state.end` |
| 21 | + pointing into released storage. |
| 22 | +
|
| 23 | + When `partial_value` reconstructs an incomplete object containing |
| 24 | + duplicate keys, the duplicate-key warning path calls `cursor_position`, |
| 25 | + which dereferences those stale pointers. This results in a |
| 26 | + heap-use-after-free and can terminate the Ruby process. |
| 27 | +
|
| 28 | + An attacker who can supply JSON stream data to an application using |
| 29 | + `JSON::ResumableParser` may cause process termination when the |
| 30 | + application calls `partial_value` on incomplete attacker-controlled |
| 31 | + input containing duplicate object keys. |
| 32 | +
|
| 33 | + The issue was reproduced in the native C extension from the official |
| 34 | + RubyGems releases: |
| 35 | +
|
| 36 | + * JSON 2.20.0 |
| 37 | + * JSON 2.21.0 |
| 38 | + * JSON 2.21.1 |
| 39 | +
|
| 40 | + The attached evidence demonstrates: |
| 41 | +
|
| 42 | + * an AddressSanitizer-confirmed heap-use-after-free; |
| 43 | + * a native `SIGSEGV` using the official JSON 2.21.1 RubyGem; |
| 44 | + * an end-to-end loopback TCP attacker/victim reproduction; |
| 45 | + * four differential controls; |
| 46 | + * successful execution after applying a tested patch control. |
| 47 | +
|
| 48 | + This was originally reported privately through Ruby's HackerOne program |
| 49 | + as report `#3867755`. A Ruby maintainer independently confirmed |
| 50 | + reproduction of the ASan failure and requested that further |
| 51 | + coordination continue through this private advisory. |
| 52 | +
|
| 53 | + No code execution or information disclosure is claimed. |
| 54 | +
|
| 55 | + ### Impact |
| 56 | +
|
| 57 | + This is a use-after-free that can result in native Ruby process termination. |
| 58 | +
|
| 59 | + An attacker must be able to supply JSON stream data to an application that: |
| 60 | +
|
| 61 | + 1. uses `JSON::ResumableParser`; |
| 62 | + 2. processes attacker-controlled streaming input; |
| 63 | + 3. calls `partial_value` after parsing an incomplete document |
| 64 | + containing duplicate object keys. |
| 65 | +
|
| 66 | + In network-facing deployments meeting these conditions, an attacker |
| 67 | + can cause process termination and denial of service. |
| 68 | +
|
| 69 | + The release-build crash was reproduced consistently in the tested |
| 70 | + Linux environment. The AddressSanitizer result confirms the underlying |
| 71 | + heap-use-after-free independently of normal allocator behavior. |
| 72 | +
|
| 73 | + The demonstrated impact is: |
| 74 | +
|
| 75 | + ```text |
| 76 | + Denial of service through native process termination |
| 77 | + ``` |
| 78 | +
|
| 79 | + No confidentiality impact, integrity impact, arbitrary code execution, |
| 80 | + or information disclosure is claimed. |
| 81 | + cvss_v4: 8.7 |
| 82 | + unaffected_versions: |
| 83 | + - "< 2.20.0" |
| 84 | + patched_versions: |
| 85 | + - ">= 2.21.2" |
| 86 | + related: |
| 87 | + url: |
| 88 | + - https://nvd.nist.gov/vuln/detail/CVE-2026-71847 |
| 89 | + - https://rubygems.org/gems/json/versions/2.21.2 |
| 90 | + - https://github.com/ruby/json/blob/master/CHANGES.md#2026-07-31-2212 |
| 91 | + - https://github.com/ruby/json/releases/tag/v2.21.2 |
| 92 | + - https://advisories.gitlab.com/gem/json/CVE-2026-71847 |
| 93 | + - https://osv.dev/vulnerability/GHSA-9hj4-r449-hfvc |
| 94 | + - https://github.com/ruby/json/security/advisories/GHSA-9hj4-r449-hfvc |
| 95 | + - https://github.com/advisories/GHSA-9hj4-r449-hfvc |
| 96 | + notes: | |
| 97 | + - "Low" severity in global GHSA URL. |
| 98 | + - cvss_v4 from nvd.nist.gov URL. |
| 99 | + - Watch for Ruby's HackerOne #3867755. |
| 100 | +--- |
0 commit comments