Oj - Use-After-Free in 'Oj::Parser' SAJ Long Key Callback
Published: June 19, 2026
SECURITY IDENTIFIERS
- CVE: CVE-2026-54902 (NVD)
- GHSA: GHSA-m578-w5vf-rfcm
GEM
PATCHED VERSIONS
>= 3.17.3
DESCRIPTION
Summary
Oj::Parser in SAJ mode does not protect cached object keys (≥ 35 bytes)
from garbage collection. A Ruby callback that triggers GC inside
hash_end can cause the key string to be reclaimed while the C
parser still holds a pointer to it. The subsequent access to the
freed string VALUE results in a segfault, confirmed by an
RIP pointing to address 0x4242 (a canary-style pattern suggesting
control over the freed memory's content).
RELATED
- https://www.cve.org/CVERecord/SearchResults?query=CVE-2026-54902
- https://rubygems.org/gems/oj/versions/3.17.3
- https://github.com/ohler55/oj/blob/master/CHANGELOG.md#3173---2026-06-04
- https://github.com/ohler55/oj/pull/1015
- https://github.com/ohler55/oj/security/advisories/GHSA-m578-w5vf-rfcm
- https://github.com/advisories/GHSA-m578-w5vf-rfcm
