CVE-2026-54899: Oj: Use-After-Free in Oj::Parser Symbol Key Cache Toggle

Published Jun 19, 2026
·
Updated

Summary

Disabling symbolkeys on a reused Oj::Parser instance triggers a heap use-after-free. When symbolkeys is toggled from true to false, optsymbolkeysset frees the internal key cache (cachefree) but does not clear the pointer. The next parse call reads from the freed cache via cacheintern, 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, optsymbolkeysset:

c // usual.c:1043–1051 if (symbolkeys) { d->keycache = cachecreate(...); // allocate } else { cachefree(d->keycache); // free — but d->keycache pointer not NULLed }

On the next parse call, cachekey → cacheintern reads from d->keycache 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 cacheintern /ext/oj/cache.c:328 #1 cachekey /ext/oj/usual.c:161 #2 closeobject /ext/oj/usual.c:285 #3 parse /ext/oj/parser.c:693 #4 parserparse /ext/oj/parser.c:1408 freed by thread T0 here: #0 free #1 cachefree /ext/oj/cache.c:277 #2 optsymbolkeysset /ext/oj/usual.c:1051 #3 option /ext/oj/usual.c:1111 #4 parsermissing /ext/oj/parser.c:1362 0x50b00001a318 is 40 bytes inside freed 112-byte region [fd]fd fd fd fd fd fd fd

Reproduce

ruby require 'oj' p = Oj::Parser.new(:usual, symbolkeys: true) p.symbolkeys = false # frees cache without nulling pointer p.parse('{"attacker":1}') # UAF: reads freed cache

Other sources

Oj (Optimized JSON) is a JSON parser and Object marshaller packaged as a Ruby gem. Prior to version 3.17.2, disabling symbolkeys on a reused Oj::Parser instance triggers a heap use-after-free. When symbolkeys is toggled from true to false, optsymbolkeysset frees the internal key cache (cachefree) but does not clear the pointer. The next parse call reads from the freed cache via cacheintern, producing a use-after-free. This issue has been fixed in version 3.17.2.

MITRE

Affected Software

2 affected componentsFixes available
rubygems/oj<3.17.2
3.17.3
IBM Aspera Enterprise WebApps<=1.0.0 - 1.0.5

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade rubygems/oj to a version that resolves this vulnerability.

    Fixed in 3.17.3
  2. Upgrade

    Upgrade oj gem to a version that resolves this vulnerability.

    Fixed in 3.17.2
  3. Configuration

    If you must run a version prior to 3.17.2, avoid toggling Oj::Parser#symbol_keys from true to false on a reused instance (this triggers the heap use-after-free in ext/oj/usual.c:opt_symbol_keys_set). Create a new Oj::Parser instance with symbol_keys set to the desired value instead of reusing the same instance across the toggle.

    Oj::Parser symbol_keys = false

Event History

Jun 19, 2026
Advisory Published
via GitHub·07:34 PM
Data Sourced
via GitHub·07:34 PM
DescriptionWeaknessAffected Software
Jun 30, 2026
CVE Published
via MITRE·11:03 PM
Data Sourced
via MITRE·11:03 PM
DescriptionWeakness
Jul 1, 2026
Data Sourced
via NVD·12:16 AM
DescriptionSeverityWeakness
Sep 8, 2026
Data Sourced
via IBM·12:00 AM
DescriptionAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Frequently Asked Questions

1

What application behavior is required to trigger this issue?

An application must reuse the same Oj::Parser instance, enable symbol_keys, then disable symbol_keys, and call parse again. The subsequent parse can read the freed internal key cache.

2

Is an unauthenticated remote attacker able to trigger it directly?

The CVSS vector indicates no privileges or user interaction are required and network reachability, but exploitation still depends on an application exposing a request path that performs the affected parser reuse and symbol_keys toggle sequence.

3

Which Oj versions should be investigated?

The issue is described as affecting all oj gem versions containing ext/oj/usual.c. It was confirmed present in version 3.17.1.

4

What can be done if an update cannot be applied immediately?

Avoid toggling symbol_keys from true to false on a reused Oj::Parser instance. Use a fresh parser instance after changing this setting, or keep the setting consistent for the parser's lifetime.

5

How can teams determine whether their code is exposed?

Review uses of Oj::Parser for parser instance reuse and calls that change symbol_keys. The vulnerable sequence is symbol_keys set to true, later set to false, followed by another parse on that same instance.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203