@stablelib/cbor: Stack exhaustion Denial of Service via deeply nested CBOR arrays, maps, or tags
Key facts
- Attack vector
- —
- Privileges required
- —
- User interaction
- —
- Attack complexity
- —
- Impact type
- Denial of service
- Confidentiality · integrity · availability
- —
- Fix status
- Fixed
No CVSS vector from any source. Fix status from GitHub. Impact type from CWE-674.
Summary
### 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.
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| — | @stablelib/cbor (npm) | before 2.0.3 | 2.0.3 | Patch available | GHSA-5jg4-p4qw-cgfr |
- @stablelib/cbor (npm) Vendor— Affected before 2.0.3 Fixed in 2.0.3 Patch available GHSA-5jg4-p4qw-cgfr
Remediation
- Fix · GHSA-5jg4-p4qw-cgfr @stablelib/cbor (npm) Fixed in 2.0.3 Advisory →
Timeline
- 2026-10-03 Threatist record created from GHSA-5jg4-p4qw-cgfr
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences