Executive brief
Oj (Optimized JSON) is a high-performance Ruby library used for processing JSON data. A flaw in how the library manages memory during data cleanup (garbage collection) can cause the application to crash when processing specific JSON inputs. This could lead to a denial-of-service, impacting the availability of Ruby-based web applications or services that rely on this library for data parsing.
Technical details
A Use-After-Free (UAF) vulnerability exists in Oj::Parser within the 'usual' mode due to improper garbage collection (GC) marking. The `parser_mark` function in `ext/oj/parser.c` fails to mark `array_class` and `hash_class` references. If a GC cycle occurs after these classes are assigned to the parser but before a parse operation begins, the Ruby GC reclaims the class objects. Subsequent calls to `rb_funcallv` within `usual.c` then dereference these dangling pointers, resulting in a segmentation fault. This issue affects all versions prior to 3.17.2 and can be triggered if an attacker can influence the parser configuration or timing.
Affected products
- ohler55 oj < 3.17.2
Timeline
- 2026-06-16: advisory: GitHub Security Advisory published by maintainer
- 2026-06-30: patched: Fix released in version 3.17.2
- 2026-07-01: disclosed: CVE-2026-54901 published to NVD