CVE-2026-54500: Oj Intern.c Form_attr (uninitialized Stack Read) Vulnerability

MODERATE
Advisory Identifier: GHSA-fm7p-mprw-wjm9
CVSS 5.3
CWE-125 CWE-908
Published
Advisory Summary

CVE-2026-54500 is a MODERATE (CVSS 5.3) intern.c form_attr (uninitialized stack read) vulnerability (CWE-125: Out-of-bounds Read) affecting Oj libraries in the RubyGems ecosystem. The issue involves intern.c form_attr (uninitialized stack read). Remediation is available by upgrading affected packages to version 3.17.3.

CVE-2026-54500 at a Glance

CVE Identifier CVE-2026-54500
GHSA Identifier GHSA-fm7p-mprw-wjm9
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-125: Out-of-bounds Read
Affected Product Oj
Package Ecosystem RubyGems
Published Date
Last Updated

Security Impact

CVSS: 5.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2026-54500

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.

oj fixed: 3.17.3
Upgrade oj to 3.17.3
Verify Direct and Transitive Dependencies

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-54500, 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-125: Out-of-bounds Read, where the product reads data past the end, or before the beginning, of the intended buffer. 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

### 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`, `form_attr()` 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 `rb_intern3()`: ```c static VALUE form_attr(const char *str, size_t len) { char buf[256]; if (sizeof(buf) - 2 <= len) { // long-key path (len >= 254) char *b = OJ_R_ALLOC_N(char, len + 2); // ... b is filled correctly ... id = rb_intern3(buf, len + 1, oj_utf8_encoding); // BUG: reads `buf` OJ_R_FREE(b); return id; } // ... } ``` `rb_intern3` 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 `form_attr` 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**: `form_attr()` now passes `b` to `rb_intern3` (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).

CVE-2026-54500 Affected Oj Versions

1 component(s)
Fixed Versions:
3.17.3
Product / Package Ecosystem Affected Versions Fixed Version
oj
RubyGems
< 3.17.3
3.17.3

References

Frequently Asked Questions

What is CVE-2026-54500?
CVE-2026-54500 is a security vulnerability in Oj involving intern.c form_attr (uninitialized stack read) under CWE-125: Out-of-bounds Read.
Which Oj versions are affected?
Affected versions include releases prior to 3.17.3 across affected packages: oj.
What version fixes CVE-2026-54500?
Upgrading to 3.17.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is oj affected?
Yes, oj is affected in releases prior to 3.17.3. Upgrade your dependency to 3.17.3 or later.
What is the CVSS score of CVE-2026-54500?
CVE-2026-54500 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N.
What CWE is associated with CVE-2026-54500?
CVE-2026-54500 is classified under CWE-125: Out-of-bounds Read (The product reads data past the end, or before the beginning, of the intended buffer.).
How can I check RubyGems dependencies for CVE-2026-54500?
Run the dependency tree command: 'inspect dependencies for oj'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-fm7p-mprw-wjm9",
  "modified" : "2026-06-19T19:35:59Z",
  "published" : "2026-06-19T19:35:59Z",
  "aliases" : [ "CVE-2026-54500" ],
  "summary" : "Oj: intern.c form_attr (uninitialized stack read)",
  "details" : "### Summary\n\n`Oj.load` in `:object` mode reads uninitialized stack memory (and, for long\nkeys, reads out of bounds) when parsing a JSON object whose key is 254 bytes\nor longer. The interned bytes can surface to the caller, disclosing process\nstack memory.\n\n### Details\n\nIn `ext/oj/intern.c`, `form_attr()` handles the long-key path by allocating a\nheap buffer `b`, populating it with the attribute name, and then freeing it —\nbut it passed the **uninitialized stack buffer `buf`** (not `b`) to\n`rb_intern3()`:\n\n```c\nstatic VALUE form_attr(const char *str, size_t len) {\n    char buf[256];\n    if (sizeof(buf) - 2 <= len) {        // long-key path (len >= 254)\n        char *b = OJ_R_ALLOC_N(char, len + 2);\n        // ... b is filled correctly ...\n        id = rb_intern3(buf, len + 1, oj_utf8_encoding);   // BUG: reads `buf`\n        OJ_R_FREE(b);\n        return id;\n    }\n    // ...\n}\n```\n\n`rb_intern3` therefore reads `len + 1` bytes of uninitialized stack memory.\nWhen the key length is >= 256, it also reads out of bounds past the 256-byte\n`buf` (CWE-125). The resulting bytes are interned and can reach the caller via\nthe produced Symbol or via the `EncodingError` message raised on invalid\nUTF-8, leaking process stack contents.\n\nThis is the same defect previously fixed in `ext/oj/usual.c`; `intern.c` held\na duplicated copy of `form_attr` that was missed.\n\n### Proof of Concept\n\n```ruby\nrequire 'oj'\nkey  = \"A\" * 300\njson = %Q[{\"^o\":\"Object\",\"#{key}\":1}]\nOj.load(json, mode: :object)\n```\n\nOn affected versions this raises an `EncodingError` whose message contains\n~1500 bytes of uninitialized stack memory (not the supplied \"A\"s). The leaked\nbyte count varies between runs with the identical payload (e.g. 1491 vs 1516\nbytes), confirming the content is uninitialized memory rather than fixed data.\n\n### Impact\n\nInformation disclosure of process stack memory to a caller that parses\nuntrusted JSON with `Oj.load(..., mode: :object)`. For keys >= 256 bytes it is\nalso an out-of-bounds read (CWE-125).\n\nSeverity is bounded by several preconditions: it requires `:object` mode\n(which is already discouraged for untrusted input), the leaked bytes are\nuncontrolled (the attacker cannot choose what is disclosed), and the data only\nreaches an attacker if the application surfaces the resulting Symbol or\n`EncodingError` back to them. Scored CVSS 5.3 (Medium) on that basis.\n\n### Patches\n\nFixed in **3.17.3**: `form_attr()` now passes `b` to `rb_intern3` (a\none-character change mirroring the earlier `usual.c` fix). Verified on the\nfixed build: the same payload returns cleanly with no leak across repeated\nruns.\n\n### Credit\n\nReported by Zac Wang (@7a6163).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "oj"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.17.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ohler55/oj/security/advisories/GHSA-fm7p-mprw-wjm9"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ohler55/oj"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-125", "CWE-908" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-19T19:35:59Z",
    "nvd_published_at" : null
  }
}