CVE-2026-54500: Oj: intern.c form_attr has an uninitialized stack read

Published Jun 19, 2026
·
Updated

Summary

Oj.load in :object mode reads uninitialized stack memory (and, for long keys, reads out of bounds) when parsing a JSON object whose key is 254 bytes or longer. The interned bytes can surface to the caller, disclosing process stack memory.

Details

In ext/oj/intern.c, formattr() handles the long-key path by allocating a heap buffer b, populating it with the attribute name, and then freeing it — but it passed the uninitialized stack buffer buf (not b) to rbintern3():

c static VALUE formattr(const char str, sizet len) { char buf[256]; if (sizeof(buf) - 2 <= len) { // long-key path (len >= 254) char b = OJRALLOCN(char, len + 2); // ... b is filled correctly ... id = rbintern3(buf, len + 1, ojutf8encoding); // BUG: reads buf OJRFREE(b); return id; } // ... }

rbintern3 therefore reads len + 1 bytes of uninitialized stack memory. When the key length is >= 256, it also reads out of bounds past the 256-byte buf (CWE-125). The resulting bytes are interned and can reach the caller via the produced Symbol or via the EncodingError message raised on invalid UTF-8, leaking process stack contents.

This is the same defect previously fixed in ext/oj/usual.c; intern.c held a duplicated copy of formattr that was missed.

Proof of Concept

ruby require 'oj' key = "A" 300 json = %Q[{"^o":"Object","#{key}":1}] Oj.load(json, mode: :object)

On affected versions this raises an EncodingError whose message contains ~1500 bytes of uninitialized stack memory (not the supplied "A"s). The leaked byte count varies between runs with the identical payload (e.g. 1491 vs 1516 bytes), confirming the content is uninitialized memory rather than fixed data.

Impact

Information disclosure of process stack memory to a caller that parses untrusted JSON with Oj.load(..., mode: :object). For keys >= 256 bytes it is also an out-of-bounds read (CWE-125).

Severity is bounded by several preconditions: it requires :object mode (which is already discouraged for untrusted input), the leaked bytes are uncontrolled (the attacker cannot choose what is disclosed), and the data only reaches an attacker if the application surfaces the resulting Symbol or EncodingError back to them. Scored CVSS 5.3 (Medium) on that basis.

Patches

Fixed in 3.17.3: formattr() now passes b to rbintern3 (a one-character change mirroring the earlier usual.c fix). Verified on the fixed build: the same payload returns cleanly with no leak across repeated runs.

Credit

Reported by Zac Wang (@7a6163).

Other sources

Oj (Optimized JSON) is a JSON parser and Object marshaller packaged as a Ruby gem. In versions prior to 3.17.3, Oj.load in :object mode reads uninitialized stack memory (and, for long keys, reads out of bounds) when parsing a JSON object whose key is 254 bytes or longer. The interned bytes can surface to the caller, disclosing process stack memory. In ext/oj/intern.c, formattr() handles the long-key path by allocating a heap buffer, b, populating it with the attribute name, and then freeing it — but it passed the uninitialized stack buffer buf (not b) to rbintern3(). rbintern3 therefore reads len + 1 bytes of uninitialized stack memory. When the key length is = 256, it also reads out of bounds past the 256-byte buf. The resulting bytes are interned and can reach the caller via the produced Symbol or via the EncodingError message raised on invalid UTF-8, leaking process stack contents. This issue has been fixed in version 3.17.3.

IBM

Oj (Optimized JSON) is a JSON parser and Object marshaller packaged as a Ruby gem. In versions prior to 3.17.3, Oj.load in :object mode reads uninitialized stack memory (and, for long keys, reads out of bounds) when parsing a JSON object whose key is 254 bytes or longer. The interned bytes can surface to the caller, disclosing process stack memory. In ext/oj/intern.c, formattr() handles the long-key path by allocating a heap buffer, b, populating it with the attribute name, and then freeing it — but it passed the uninitialized stack buffer buf (not b) to rbintern3(). rbintern3 therefore reads len + 1 bytes of uninitialized stack memory. When the key length is >= 256, it also reads out of bounds past the 256-byte buf. The resulting bytes are interned and can reach the caller via the produced Symbol or via the EncodingError message raised on invalid UTF-8, leaking process stack contents. This issue has been fixed in version 3.17.3.

NVD

Affected Software

2 affected componentsFixes available
rubygems/oj<3.17.3
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 (Optimized JSON) to a version that resolves this vulnerability.

    Fixed in 3.17.3
  3. Compensating control

    If you must remain on a version prior to 3.17.3, avoid using `Oj.load(json, mode: :object)` with untrusted JSON input, since the leak occurs specifically in `:object` mode when parsing JSON object keys with length >= 254 bytes.

Event History

Jun 19, 2026
Advisory Published
via GitHub·07:35 PM
Data Sourced
via GitHub·07:35 PM
DescriptionSeverityWeaknessAffected Software
Jun 30, 2026
CVE Published
via MITRE·11:08 PM
Data Sourced
via MITRE·11:08 PM
DescriptionSeverityWeakness
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 is the severity of CVE-2026-54500?

CVE-2026-54500 has a medium severity rating of 5.3.

2

What is the risk associated with CVE-2026-54500?

The risk level for CVE-2026-54500 is categorized as 27.

3

How does CVE-2026-54500 affect the Oj library?

CVE-2026-54500 allows for the potential disclosure of uninitialized stack memory when parsing JSON objects with long keys.

4

How do I fix CVE-2026-54500?

To mitigate CVE-2026-54500, update the Oj library to the latest version where the vulnerability is resolved.

5

What could be the impact of exploiting CVE-2026-54500?

Exploiting CVE-2026-54500 could lead to the exposure of sensitive process stack memory to the caller.

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