All vulnerabilities
CVE-2026-54899GHSA-2cw7-v8ff-p88r

oj: Oj: Use-After-Free in Oj::Parser Symbol Key Cache Toggle

ohler55 ojrubygemsLibraries & packages
CVSS
8.7High
ExploitationPublic exploit codeCISA's assessment says proof of concept code is public, assessed 1 Jul 2026. Not in the KEV catalogCISA via CVE List
Exploit odds (EPSS)0.33%Chance of exploitation activity in the next 30 days, higher than 25% of CVEs. Scored 23 Oct 2026FIRST EPSS
Fixed in3.17.2Fixed versionGitHub
Published30 Jun 2026Updated 6 Oct 2026CVE List

What fixes it

  • 3.17.2oj, rubygemsGitHub
  • 3.17.2oj, RubyGemsOSVbundle update oj --conservative # needs 3.17.2 or later

A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.

Description

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 fd

Reproduce

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 cache

Text from GitHub Advisory Database

Affected versions 53

  • oj, rubygems< 3.17.2GitHub
  • ojaffected: < 3.17.2CVE List
  • oj, RubyGemsfrom first release, fixed in 3.17.2OSV
  • oj, RubyGems0.5OSV
  • oj, RubyGems0.5.1OSV
  • oj, RubyGems0.5.2OSV
  • oj, RubyGems0.6.0OSV
  • oj, RubyGems0.7.0OSV
  • oj, RubyGems0.8.0OSV
  • oj, RubyGems0.9.0OSV
  • oj, RubyGems1.0.0OSV
  • oj, RubyGems1.0.1OSV
  • oj, RubyGems1.0.2OSV
  • oj, RubyGems1.0.3OSV
  • oj, RubyGems1.0.4OSV
  • oj, RubyGems1.0.5OSV
  • oj, RubyGems1.0.6OSV
  • oj, RubyGems1.1.0OSV
  • oj, RubyGems1.1.1OSV
  • oj, RubyGems1.2.0OSV
  • oj, RubyGems1.2.1OSV
  • oj, RubyGems1.2.10OSV
  • oj, RubyGems1.2.11OSV
  • oj, RubyGems1.2.12OSV
  • oj, RubyGems1.2.13OSV
  • oj, RubyGems1.2.2OSV
  • oj, RubyGems1.2.3OSV
  • oj, RubyGems1.2.4OSV
  • oj, RubyGems1.2.5OSV
  • oj, RubyGems1.2.6OSV
  • oj, RubyGems1.2.7OSV
  • oj, RubyGems1.2.8OSV
  • oj, RubyGems1.2.9OSV
  • oj, RubyGems1.3.0OSV
  • oj, RubyGems1.3.2OSV
  • oj, RubyGems1.3.4OSV
  • oj, RubyGems1.3.5OSV
  • oj, RubyGems1.3.6OSV
  • oj, RubyGems1.3.7OSV
  • oj, RubyGems1.4.0OSV
  • oj, RubyGems1.4.1OSV
  • oj, RubyGems1.4.2OSV
  • oj, RubyGems1.4.3OSV
  • oj, RubyGems1.4.4OSV
  • oj, RubyGems1.4.5OSV
  • oj, RubyGems1.4.6OSV
  • oj, RubyGems1.4.6a2OSV
  • oj, RubyGems1.4.7OSV
  • oj, RubyGems2.0.0OSV
  • oj, RubyGems2.0.1OSV
  • oj, RubyGems2.0.10OSV
  • oj, RubyGems2.0.11OSV
  • oj, RubyGems2.0.12OSV

References 5