CVE-2026-54903: Oj: Integer Overflow in Oj.load 2GB String Handling

Published Jun 19, 2026
·
Updated

Summary

Oj.load is vulnerable to heap corruption when parsing a JSON string longer than 2 GB. An integer overflow in bufappendstring (buf.h:61) converts the string length to a large negative sizet, causing memcpy to copy an astronomically large amount of data out of bounds. This crashes the process and can corrupt adjacent heap memory.

Version

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

Details

ext/oj/buf.h, line 61:

c inline static void bufappendstring(Buf buf, const char s, sizet slen) { // ... memcpy(buf->tail, s, slen); // slen derived from 32-bit int that wrapped negative

In parse.c, escape sequence handling computes the remaining string length as an int:

c // parse.c:402 (readescapedstr) int slen = (int)(s - str); // ← wraps to negative when string > 2 GB bufappendstring(buf, str, (sizet)slen); // ← (sizet)(-2147483648) = 0x80000000...

ASAN report: ==399019==ERROR: AddressSanitizer: negative-size-param: (size=-2147483648) #0 asanmemcpy #1 bufappendstring /ext/oj/buf.h:61 #2 readescapedstr /ext/oj/parse.c:402 #3 readstr /ext/oj/parse.c:542 #4 ojparse2 /ext/oj/parse.c:882 #5 ojpiparse /ext/oj/parse.c:1256 #6 ojobjectparse /ext/oj/object.c:701 #7 load /ext/oj/oj.c:1259 0x7f5a26ff0801 is located 1 bytes inside of 2147483657-byte region [0x7f5a26ff0800, 0x7f5aa6ff0809)

Reproduce

ruby require 'oj' n = 1 << 31 # 2 GB json = '"' + ('A' n) + 'A"' # >2GB JSON string with a trailing escape Oj.load(json)

Other sources

Oj (Optimized JSON) is a JSON parser and Object marshaller packaged as a Ruby gem. In versions prior to 3.17.2, Oj.load is vulnerable to heap corruption when parsing a JSON string longer than 2 GB. An integer overflow in bufappendstring (buf.h:61) converts the string length to a large negative sizet, causing memcpy to copy an astronomically large amount of data out of bounds. This crashes the process and can corrupt adjacent heap memory. 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:42 PM
Data Sourced
via MITRE·11:42 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-54903?

CVE-2026-54903 has a risk score of 42, indicating a moderate level of severity.

2

How do I fix CVE-2026-54903?

To fix CVE-2026-54903, update to the latest version of the Oj gem where this vulnerability has been addressed.

3

What is the impact of CVE-2026-54903?

The impact of CVE-2026-54903 includes potential heap corruption and application crashes when parsing large JSON strings.

4

Which versions of Oj are affected by CVE-2026-54903?

CVE-2026-54903 affects versions of the Oj gem prior to the patched release that addresses this vulnerability.

5

What type of vulnerability is CVE-2026-54903?

CVE-2026-54903 is classified as an integer overflow vulnerability leading to heap corruption.

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