RubySec

Providing security resources for the Ruby community

CVE-2026-54897 (oj): Oj - Use-After-Free in Oj::Doc Iterators via Reentrant Close

Oj - Use-After-Free in Oj::Doc Iterators via Reentrant Close

Published: June 19, 2026

SECURITY IDENTIFIERS

GEM

oj

PATCHED VERSIONS

>= 3.17.3

DESCRIPTION

Summary

Oj::Doc iterators (each_value, each_child, each_leaf) are vulnerable to a heap use-after-free. When a Ruby block yielded during iteration calls doc.close or d.close, the document's heap memory is freed while the C iterator is still running. When control returns from the block, the iterator reads from the freed region, producing a use-after-free accessible from pure Ruby.

RELATED