Oj gem CVE-2026-54899
MEDIUMAttack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessIdentify app reusing Oj::Parser
-
DeliveryTrigger symbol_keys toggle to false
-
ExploitSubmit crafted JSON payload
-
ExecutionParser dereferences freed key_cache
-
PersistUAF read in cache_intern
-
ImpactCrash, leak, or corrupt heap
Vulnerability Assessment
| Weakness |
CWE
ASVS 5.0
V15 - Secure Coding and Architecture Memory lifecycle management
MITRE ATT&CK
2 techniques across 2 tactics: Execution, Privilege Escalation The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Exploitation requires that the target application reuse a single Oj::Parser instance built with the :usual mode and symbol_keys: true, then toggle that instance's symbol_keys option to false at runtime (via the symbol_keys= setter or the equivalent option call) before invoking parse on attacker-influenced JSON. Limiting factors: the bug is not reachable through the common Oj.load / Oj.dump module-level API, does not affect freshly constructed parsers that never change symbol_keys, and requires the C extension build of oj (the default on MRI Ruby); CVSS is not provided so authentication requirements not confirmed from available data, but the attacker only needs to supply JSON that the vulnerable code path will parse. |
| Impact | No NVD CVSS vector is supplied, and EPSS, KEV, and SSVC data are absent from the input, so prioritization must rely on the technical facts. Exploitation requires an application path that (a) reuses a single Oj::Parser instance and (b) flips symbol_keys from true to false at runtime before parsing - an uncommon pattern, since most callers either set the option once at construction or use the module-level Oj.load API rather than Oj::Parser. Once that pattern exists, however, parsing attacker-controlled JSON is enough to trigger the UAF, and use-after-frees in C extensions can in principle yield information disclosure, crashes (DoS of the Ruby process), or, with heap-grooming, memory corruption; the tag set (Memory Corruption, Information Disclosure, Use After Free) reflects this range. Realistic priority is moderate: low likelihood of triggering in default deployments, but high impact where the toggle pattern exists, and the fix is a trivial dependency bump so there is no reason to defer patching. |
| Exploit ScenarioDerived | An application instantiates a long-lived Oj::Parser(:usual, symbol_keys: true) - for example as a memoized parser in a web request pipeline - and at some point sets parser.symbol_keys = false based on a configuration flag or per-request hint before parsing user-supplied JSON; the next parse call dereferences the freed key cache, at minimum crashing the worker (DoS) and potentially leaking adjacent heap data into returned key values. No public PoC beyond the reporter's three-line reproducer has been identified, and weaponization into reliable code execution would additionally require heap-grooming primitives specific to the host Ruby/glibc allocator. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Jun 19, 2026
Heap use-after-free in the Oj Ruby JSON parser (versions prior to 3.17.3) is triggered when an application toggles the symbol_keys option from true to false on a reused Oj::Parser instance. The opt_symbol_keys_set function frees the internal key cache via cache_free but fails to NULL the d->key_cache pointer, so the next parse call dereferences freed memory through cache_intern, potentially leading to memory disclosure, crashes, or controlled corruption. No public exploit identified at time of analysis, and the issue is documented in GitHub Security Advisory GHSA-2cw7-v8ff-p88r.
RemediationAI
Vendor-released patch: oj 3.17.3 - upgrade by pinning gem 'oj', '>= 3.17.3' in the Gemfile and running bundle update oj, then redeploy so the C extension is recompiled against the fixed source (see https://github.com/ohler55/oj/security/advisories/GHSA-2cw7-v8ff-p88r). If immediate upgrade is not possible, the targeted workaround is to avoid mutating symbol_keys on an existing Oj::Parser instance: construct a fresh Oj::Parser for each desired configuration, or set symbol_keys only once at construction; alternatively, route untrusted JSON through Oj.load / Oj.safe_load rather than a reused Oj::Parser, accepting the throughput cost of not reusing the parser object. Auditing application code and dependencies for any assignment like parser.symbol_keys = false on a long-lived parser is a quick way to confirm exposure.
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in rubygems
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
Oj (Optimized JSON) is a high-performance C-extension JSON parser/serializer for Ruby, widely used as a drop-in replacement for the standard JSON library and by Rails applications via multi_json. The flaw lives in the optimized 'usual' parser implementation (ext/oj/usual.c) which maintains a key_cache structure used by cache_intern to deduplicate and intern hash keys (as Symbol or String) during object parsing. The root cause is CWE-416 (Use After Free): opt_symbol_keys_set at ext/oj/usual.c:1043-1051 calls cache_free(d->key_cache) when disabling symbol keys but does not assign d->key_cache = NULL, leaving a dangling pointer that close_object → cache_key → cache_intern (cache.c:328) subsequently reads on the next parse, as confirmed by the AddressSanitizer trace provided in the advisory.
Know when the next one hits your stack
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:L/SC:N/SI:N/SA:N
Attacker-supplied JSON reaches the bug remotely (AV:N) but only when the app reuses a parser and toggles symbol_keys (AC:H); no auth or UI needed; UAF most reliably crashes the worker (A:H) with possible limited memory disclosure/corruption (C:L/I:L).
Primary rating from Vendor (https://github.com/ohler55/oj).
CVSS VectorVendor: https://github.com/ohler55/oj
Lifecycle Timeline
1DescriptionCVE.org
Summary
Disabling symbol_keys on a reused Oj::Parser instance triggers a heap use-after-free. When symbol_keys is toggled from true to false, opt_symbol_keys_set frees the internal key cache (cache_free) but does not clear the pointer. The next parse call reads from the freed cache via cache_intern, producing a use-after-free.
Version
- Software: oj gem
- Affected: all versions with
ext/oj/usual.c - Latest tested: 3.17.1 (confirmed present)
Details
ext/oj/usual.c, opt_symbol_keys_set:
// usual.c:1043-1051
if (symbol_keys) {
d->key_cache = cache_create(...); // allocate
} else {
cache_free(d->key_cache); // free - but d->key_cache pointer not NULLed
}On the next parse call, cache_key → cache_intern reads from d->key_cache which now points to freed memory.
ASAN report:
==145265==ERROR: AddressSanitizer: heap-use-after-free on address 0x50b00001a318
READ of size 8 at 0x50b00001a318 thread T0
#0 cache_intern /ext/oj/cache.c:328
#1 cache_key /ext/oj/usual.c:161
#2 close_object /ext/oj/usual.c:285
#3 parse /ext/oj/parser.c:693
#4 parser_parse /ext/oj/parser.c:1408
freed by thread T0 here:
#0 free
#1 cache_free /ext/oj/cache.c:277
#2 opt_symbol_keys_set /ext/oj/usual.c:1051
#3 option /ext/oj/usual.c:1111
#4 parser_missing /ext/oj/parser.c:1362
0x50b00001a318 is 40 bytes inside freed 112-byte region [fd]fd fd fd fd fd fd fdReproduce
require 'oj'
p = Oj::Parser.new(:usual, symbol_keys: true)
p.symbol_keys = false
# frees cache without nulling pointer
p.parse('{"attacker":1}')
# UAF: reads freed cacheExecutive ViewAI
The Oj Ruby JSON parser library contains a heap memory corruption vulnerability affecting versions before 3.17.3 that is triggered when applications reuse parser instances while changing the symbol_keys configuration. This creates risk of production service crashes and potential memory data exposure across Ruby-based applications, with no vendor patch currently available. Remediation requires immediate code-level changes to eliminate the vulnerable usage pattern.
No vendor-released patch identified at time of analysis. Interim mitigations: (1) Refactor code to instantiate new Oj::Parser objects instead of reusing instances when symbol_keys configuration changes; (2) Implement code review controls to prevent reuse of parser instances across configuration changes; (3) Deploy crash monitoring and alerting for JSON parsing operations; (4) Evaluate alternative JSON parsing libraries for critical systems until patch availability is confirmed.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Use-after-free vulnerabilities occur when a program continues to access memory through a pointer after that memory has been deallocated.
Memory corruption occurs when a program writes data beyond the boundaries of allocated memory regions or accesses memory in unintended ways, violating the integrity of the process's address space.
Information disclosure occurs when an application unintentionally exposes sensitive data that aids attackers in reconnaissance or directly compromises security.
GHSA-2cw7-v8ff-p88r
NVD
CVE.org
EPSS
Exploit-DB