CVE-2026-54903: Oj Integer Overflow Vulnerability
HIGHCVE-2026-54903 is a HIGH integer overflow vulnerability (CWE-190: Integer Overflow or Wraparound) affecting Oj libraries in the RubyGems ecosystem. The issue involves integer overflow in oj.load 2gb string handling. Remediation is available by upgrading affected packages to version 3.17.3.
CVE-2026-54903 at a Glance
How to Fix CVE-2026-54903
To remediate this vulnerability, upgrade all affected Oj dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade oj to 3.17.3
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for oj
How to Check if You Are Affected
To determine whether your application is affected by CVE-2026-54903, inspect your project dependencies for Oj:
inspect dependencies for oj
Analyze the terminal output to locate any version of Oj in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.17.3), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-190: Integer Overflow or Wraparound, where the product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. this occurs when an integer value is incremented to a value that is too large to store in the associated representation. when this occurs, the value may become a very small or negative number. In Oj, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-54903 Affected Oj Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
oj
|
RubyGems |
< 3.17.3
|
3.17.3
|
References
Frequently Asked Questions
What is CVE-2026-54903?
Which Oj versions are affected?
What version fixes CVE-2026-54903?
Is oj affected?
What CWE is associated with CVE-2026-54903?
How can I check RubyGems dependencies for CVE-2026-54903?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-475m-ph3x-64gp",
"modified" : "2026-06-19T20:47:31Z",
"published" : "2026-06-19T20:47:31Z",
"aliases" : [ "CVE-2026-54903" ],
"summary" : "Oj: Integer Overflow in Oj.load 2GB String Handling",
"details" : "### Summary\n\n`Oj.load` is vulnerable to heap corruption when parsing a JSON string longer than 2 GB. An integer overflow in `buf_append_string` (`buf.h:61`) converts the string length to a large negative `size_t`, causing `memcpy` to copy an astronomically large amount of data out of bounds. This crashes the process and can corrupt adjacent heap memory.\n\n### Version\n\n- **Software**: oj gem\n- **Affected**: all versions with `ext/oj/buf.h` and `ext/oj/parse.c`\n- **Latest tested**: 3.17.1 (confirmed present)\n\n### Details\n\n`ext/oj/buf.h`, line 61:\n\n```c\ninline static void buf_append_string(Buf buf, const char *s, size_t slen) {\n // ...\n memcpy(buf->tail, s, slen); // slen derived from 32-bit int that wrapped negative\n```\n\nIn `parse.c`, escape sequence handling computes the remaining string length as an `int`:\n\n```c\n// parse.c:402 (read_escaped_str)\nint slen = (int)(s - str); // ← wraps to negative when string > 2 GB\nbuf_append_string(buf, str, (size_t)slen); // ← (size_t)(-2147483648) = 0x80000000...\n```\n\nASAN report:\n```\n==399019==ERROR: AddressSanitizer: negative-size-param: (size=-2147483648)\n #0 __asan_memcpy\n #1 buf_append_string /ext/oj/buf.h:61\n #2 read_escaped_str /ext/oj/parse.c:402\n #3 read_str /ext/oj/parse.c:542\n #4 oj_parse2 /ext/oj/parse.c:882\n #5 oj_pi_parse /ext/oj/parse.c:1256\n #6 oj_object_parse /ext/oj/object.c:701\n #7 load /ext/oj/oj.c:1259\n0x7f5a26ff0801 is located 1 bytes inside of 2147483657-byte region [0x7f5a26ff0800, 0x7f5aa6ff0809)\n```\n\n### Reproduce\n\n```ruby\nrequire 'oj'\nn = 1 << 31 # 2 GB\njson = '\"' + ('A' * n) + 'A\"' # >2GB JSON string with a trailing escape\nOj.load(json)\n```",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "RubyGems",
"name" : "oj"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.17.3"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "< 3.17.2"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/ohler55/oj/security/advisories/GHSA-475m-ph3x-64gp"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/ohler55/oj"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-190" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-06-19T20:47:31Z",
"nvd_published_at" : null
}
}