CVE-2026-54900: Oj Negative-Size Memcpy Vulnerability
HIGHCVE-2026-54900 is a HIGH negative-size memcpy vulnerability (CWE-416: Use After Free) affecting Oj libraries in the RubyGems ecosystem. The issue involves negative-size memcpy in oj::parser create_id attribute handling. Remediation is available by upgrading affected packages to version 3.17.3.
CVE-2026-54900 at a Glance
How to Fix CVE-2026-54900
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-54900, 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-416: Use After Free, where the product reuses or references memory after it has been freed. at some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer. 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-54900 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-54900?
Which Oj versions are affected?
What version fixes CVE-2026-54900?
Is oj affected?
What CWE is associated with CVE-2026-54900?
How can I check RubyGems dependencies for CVE-2026-54900?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-9cv6-qcjw-4grx",
"modified" : "2026-06-19T20:47:23Z",
"published" : "2026-06-19T20:47:23Z",
"aliases" : [ "CVE-2026-54900" ],
"summary" : "Oj: Negative-Size memcpy in Oj::Parser create_id Attribute Handling",
"details" : "### Summary\n\n`Oj::Parser#parse` in usual mode with `create_id` 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 `form_attr` (`usual.c:63`) converts the length to `-1` before passing it to `memcpy`. This causes `memcpy` to copy `SIZE_MAX` bytes (interpreted as a huge `size_t`), corrupting heap memory and crashing the process.\n\n### Version\n\n- **Software**: oj gem\n- **Affected**: all versions with `ext/oj/usual.c`\n- **Latest tested**: 3.17.1 (confirmed present)\n\n### Details\n\n`ext/oj/usual.c`, `form_attr`:\n\n```c\n// usual.c:55–64\nstatic ID form_attr(const char *str, size_t slen) {\n char buf[4096];\n // ...\n int blen = (int)slen + 1; // ← truncates: 65535 + 1 = 65536 → wraps to 0\n // or: 65535 cast to int = 65535 (fits),\n // but blen = 65536 → INT overflow on +1 if slen=INT_MAX\n // ...\n memcpy(buf, \"@\", 1);\n memcpy(buf + 1, str, (size_t)blen); // ← size_t(-1) = SIZE_MAX\n}\n```\n\nThe cache (`cache_intern`) uses a fixed 65,536-byte slab. When `slen = 65535`, the arithmetic wraps and `memcpy` is called with `(size_t)-1`.\n\nASAN report:\n```\n==80452==ERROR: AddressSanitizer: negative-size-param: (size=-1)\n #0 memcpy\n #1 form_attr /ext/oj/usual.c:63\n #2 cache_intern /ext/oj/cache.c:326\n #3 get_attr_id /ext/oj/usual.c:186\n #4 close_object_create /ext/oj/usual.c:374\n #5 parse /ext/oj/parser.c:693\n #6 parser_parse /ext/oj/parser.c:1408\n0x531000528800 is located 0 bytes inside of 65536-byte region [0x531000528800, 0x531000538800)\n```\n\n### Reproduce\n\nGenerate the payload:\n\n```python\nkey = 'A' * 65535\nwith open('poc.json', 'w') as f:\n f.write('{\"json_class\":\"Oj::Bag\",\"' + key + '\":1}')\n```\n\nTrigger:\n\n```ruby\nrequire 'oj'\nOj::Parser.new(:usual, create_id: 'json_class').parse(STDIN.read)\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-9cv6-qcjw-4grx"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/ohler55/oj"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-416" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-06-19T20:47:23Z",
"nvd_published_at" : null
}
}