chore(deps): update dependency json to v2.21.2 [security] - #1677
Open
renovate[bot] wants to merge 1 commit into
Open
chore(deps): update dependency json to v2.21.2 [security]#1677renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
renovate
Bot
force-pushed
the
renovate/rubygems-json-vulnerability
branch
from
August 26, 2026 13:59
840a503 to
e97ba2c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
'2.20.0'→'2.21.2'Ruby JSON: JSON::ResumableParser#partial_value dereferences a freed input buffer and crashes on truncated duplicate-key streams
CVE-2026-71847 / GHSA-9hj4-r449-hfvc
More information
Details
Summary
Ruby's JSON native C extension clears the consumed
JSON::ResumableParserinput buffer but leavesstate.start,state.cursor, andstate.endpointing into released storage.When
partial_valuereconstructs an incomplete object containing duplicate keys, the duplicate-key warning path callscursor_position, which dereferences those stale pointers. This results in a heap-use-after-free and can terminate the Ruby process.An attacker who can supply JSON stream data to an application using
JSON::ResumableParsermay cause process termination when the application callspartial_valueon incomplete attacker-controlled input containing duplicate object keys.The issue was reproduced in the native C extension from the official RubyGems releases:
The attached evidence demonstrates:
SIGSEGVusing the official JSON 2.21.1 RubyGem;This was originally reported privately through Ruby's HackerOne program as report
#3867755. A Ruby maintainer independently confirmed reproduction of the ASan failure and requested that further coordination continue through this private advisory.No code execution or information disclosure is claimed.
Details
The affected source is:
The vulnerable sequence in JSON 2.21.1 is:
cResumableParser_parsereaches the end of the current input buffer.json_str_clear(parser->buffer).parser->buffer = Qfalse.partial_valuemakes a shallow copy of the parser state.cursor_positionwalks through the stale input pointers and reads released memory.Relevant source locations:
Buffer release:
https://github.com/ruby/json/blob/fd61def38b9bb859fee7eec8e7d3143600e5b347/ext/json/ext/parser/parser.c#L2562-L2569
Parser-state copy:
https://github.com/ruby/json/blob/fd61def38b9bb859fee7eec8e7d3143600e5b347/ext/json/ext/parser/parser.c#L2647-L2654
Stale-pointer read in
cursor_position:https://github.com/ruby/json/blob/fd61def38b9bb859fee7eec8e7d3143600e5b347/ext/json/ext/parser/parser.c#L590-L628
Duplicate-key handling path:
https://github.com/ruby/json/blob/fd61def38b9bb859fee7eec8e7d3143600e5b347/ext/json/ext/parser/parser.c#L1196-L1255
When input is supplied to the resumable parser, the parser state stores direct pointers into the backing Ruby string:
After the current buffer has been consumed,
cResumableParser_parseclears the string and removes the parser's reference to it:This path does not invalidate or replace:
JSON::ResumableParser#partial_valuesubsequently makes a shallow copy of the parser structure:When the partial object contains duplicate keys, reconstruction follows this call path:
cursor_positionthen reads through pointers that may refer to released storage.AddressSanitizer reports:
The reproducer follows the normal resumable-parser API sequence:
The issue does not require:
The release-build crash reproduced on JSON 2.20.0, 2.21.0, and 2.21.1.
This report covers the native C-extension implementation. The separate Java-platform implementation was not tested and is not claimed to be affected.
PoC
The complete evidence bundle is attached as:
SHA-256:
Requirements
makeRelease-build, network, and differential reproduction
Extract the attachment:
unzip ruby-json-resumable-partial-value-uaf-evidence-20260716.zip cd ruby-json-resumable-partial-value-uaf-evidence-20260716Run the official JSON 2.21.1 release-build proof, loopback network proof, and differential controls:
Expected primary results:
The following four differential controls must also report
result=PASS:The release-build crash stack includes:
AddressSanitizer reproduction
Run:
Expected vulnerable result:
Expected patched-control result:
Affected-version matrix
The release-build crash was reproduced three times for each of the following official RubyGems releases:
Additional evidence is included in:
Impact
This is a use-after-free that can result in native Ruby process termination.
An attacker must be able to supply JSON stream data to an application that:
JSON::ResumableParser;partial_valueafter parsing an incomplete document containing duplicate object keys.In network-facing deployments meeting these conditions, an attacker can cause process termination and denial of service.
The release-build crash was reproduced consistently in the tested Linux environment. The AddressSanitizer result confirms the underlying heap-use-after-free independently of normal allocator behavior.
The demonstrated impact is:
No confidentiality impact, integrity impact, arbitrary code execution, or information disclosure is claimed.
Suggested remediation
Before clearing or releasing the resumable parser's input buffer, invalidate or replace every parser-state pointer that refers to the buffer's backing storage.
Delayed code paths such as duplicate-key warning generation must not calculate cursor positions using pointers after the corresponding buffer has been released.
The attached
patch-control.diffdemonstrates one tested control and is provided for validation rather than as a required final implementation.Severity
Low
References
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.