RubySec

Providing security resources for the Ruby community

CVE-2026-54902 (oj): Oj - Use-After-Free in 'Oj::Parser' SAJ Long Key Callback

Oj - Use-After-Free in 'Oj::Parser' SAJ Long Key Callback

Published: June 19, 2026

SECURITY IDENTIFIERS

GEM

oj

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