Intel

AIKIDO-2026-769167

json is vulnerable to Use After Free

Use After FreeGHSA-9hj4-r449-hfvc Published 2 days ago

45

Medium Risk

This Affects:

RUBYjson
2.20.0 - 2.21.1
Fixed in 2.21.2
Are you affected? Scan for Free

TL;DR

JSON::ResumableParser#parse clears the consumed input buffer at end-of-stream but leaves state.start, state.cursor, and state.end pointing into the released storage. When an application later calls partial_value on an incomplete object that contains duplicate keys, the duplicate-key warning path invokes cursor_position, which walks those stale pointers and reads freed memory. An attacker who can feed a crafted truncated JSON stream to a resumable parser and trigger partial_value can crash the Ruby process via this heap use-after-free. The fix resets the parser-state pointers when the buffer is cleared and skips cursor-based line/column computation on the resumable warning path.

Who does this affect?

You are affected if you are using a version that falls within the vulnerable range and your application uses JSON::ResumableParser with partial_value on untrusted streaming JSON input.

Background info

json is vulnerable to Use After Free in versions 2.20.0 - 2.21.1.

How to fix this

Upgrade the json library to the patch version.