GHSA-5jg4-p4qw-cgfr: @stablelib/cbor Denial of Service Vulnerability

HIGH
CWE-674
Published
Advisory Summary

GHSA-5jg4-p4qw-cgfr is a HIGH denial of service vulnerability (CWE-674: Uncontrolled Recursion) affecting @stablelib/cbor libraries in the npm ecosystem. The issue involves stack exhaustion denial of service via deeply nested cbor arrays, maps, or tags. Remediation is available by upgrading affected packages to version 2.0.3.

GHSA-5jg4-p4qw-cgfr at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-5jg4-p4qw-cgfr
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-674: Uncontrolled Recursion
Affected Product @stablelib/cbor
Package Ecosystem npm
Published Date
Last Updated

How to Fix GHSA-5jg4-p4qw-cgfr

To remediate this vulnerability, upgrade all affected @stablelib/cbor dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@stablelib/cbor fixed: 2.0.3
npm install @stablelib/cbor@2.0.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @stablelib/cbor

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-5jg4-p4qw-cgfr, inspect your project dependencies using npm:

npm ls @stablelib/cbor

Analyze the terminal output to locate any version of @stablelib/cbor in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.0.3), your application is affected.

Note: The npm ls @stablelib/cbor command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-674: Uncontrolled Recursion, where the product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack. In @stablelib/cbor, 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 `@stablelib/cbor` decodes nested CBOR structures recursively and does not enforce a maximum nesting depth. A sufficiently deep attacker-controlled CBOR payload can therefore crash decoding with `RangeError: Maximum call stack size exceeded`. ### Details The decoder processes arrays, maps, and tagged values through recursive calls. Each nested container causes another descent into `_decodeValue()` until a leaf value is reached. There is no depth limit, no iterative fallback, and no protection against pathological nesting. An attacker can therefore supply a payload made of thousands of nested arrays, maps, or tags and force the decoder to recurse until the JavaScript call stack is exhausted. ### PoC ```js import { decode } from "@stablelib/cbor"; const depth = 12000; const payload = new Uint8Array(depth + 1); // Build [[[...[null]...]]] payload.fill(0x81, 0, depth); // array(1) payload[depth] = 0xf6; // null decode(payload); // RangeError: Maximum call stack size exceeded ``` ### Impact Any application that decodes attacker-controlled CBOR can be forced into a reliable denial of service with a single crafted payload. The immediate result is an exception during decoding. In services that do not catch that exception safely, the request fails and the worker or process handling the decode may terminate. ### Solution Upgrade to version 2.0.4. The stack is limited to 128 by default, but can be configured using the `maxDepth` option. Catch the `CBORMaxDepthExceededError` exception.

GHSA-5jg4-p4qw-cgfr Affected @stablelib/cbor Versions

1 component(s)
Fixed Versions:
2.0.3
Product / Package Ecosystem Affected Versions Fixed Version
@stablelib/cbor
npm
< 2.0.3
2.0.3

References

Frequently Asked Questions

What is GHSA-5jg4-p4qw-cgfr?
GHSA-5jg4-p4qw-cgfr is a security vulnerability in @stablelib/cbor involving Stack exhaustion Denial of Service via deeply nested CBOR arrays, maps, or tags under CWE-674: Uncontrolled Recursion.
Which @stablelib/cbor versions are affected?
Affected versions include releases prior to 2.0.3 across affected packages: @stablelib/cbor.
What version fixes GHSA-5jg4-p4qw-cgfr?
Upgrading to 2.0.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @stablelib/cbor affected?
Yes, @stablelib/cbor is affected in releases prior to 2.0.3. Upgrade your dependency to 2.0.3 or later.
What CWE is associated with GHSA-5jg4-p4qw-cgfr?
GHSA-5jg4-p4qw-cgfr is classified under CWE-674: Uncontrolled Recursion (The product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack.).
How can I check npm dependencies for GHSA-5jg4-p4qw-cgfr?
Run the dependency tree command: 'npm ls @stablelib/cbor'. 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-5jg4-p4qw-cgfr",
  "modified" : "2026-04-07T14:22:35Z",
  "published" : "2026-04-04T05:33:09Z",
  "aliases" : [ ],
  "summary" : "@stablelib/cbor: Stack exhaustion Denial of Service via deeply nested CBOR arrays, maps, or tags",
  "details" : "### Summary\n\n`@stablelib/cbor` decodes nested CBOR structures recursively and does not enforce a maximum nesting depth. A sufficiently deep attacker-controlled CBOR payload can therefore crash decoding with `RangeError: Maximum call stack size exceeded`.\n\n### Details\n\nThe decoder processes arrays, maps, and tagged values through recursive calls. Each nested container causes another descent into `_decodeValue()` until a leaf value is reached.\n\nThere is no depth limit, no iterative fallback, and no protection against pathological nesting. An attacker can therefore supply a payload made of thousands of nested arrays, maps, or tags and force the decoder to recurse until the JavaScript call stack is exhausted.\n\n### PoC\n\n```js\nimport { decode } from \"@stablelib/cbor\";\n\nconst depth = 12000;\nconst payload = new Uint8Array(depth + 1);\n\n// Build [[[...[null]...]]]\npayload.fill(0x81, 0, depth); // array(1)\npayload[depth] = 0xf6;        // null\n\ndecode(payload);\n// RangeError: Maximum call stack size exceeded\n```\n\n### Impact\n\nAny application that decodes attacker-controlled CBOR can be forced into a reliable denial of service with a single crafted payload.\n\nThe immediate result is an exception during decoding. In services that do not catch that exception safely, the request fails and the worker or process handling the decode may terminate.\n\n\n### Solution\n\nUpgrade to version 2.0.4. The stack is limited to 128 by default, but can be configured using the `maxDepth` option. Catch the `CBORMaxDepthExceededError` exception.",
  "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" : "npm",
      "name" : "@stablelib/cbor"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.0.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/StableLib/stablelib/security/advisories/GHSA-5jg4-p4qw-cgfr"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/StableLib/stablelib/commit/0149e18d9d4736e22c257744ca945ebce7899a01"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/StableLib/stablelib"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-674" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-04T05:33:09Z",
    "nvd_published_at" : null
  }
}