VulnWatch by ve1ve2
medium 5.3 EPSS 0.36%

GHSA-3g82-77xr-68x5 / CVE-2026-63386: js-toml allows uncontrolled recursion in `load()` leading `RangeError` (stack exhaustion) on deeply nested input

Source:
GitHub Security Advisories
Published:
Fetched:
Updated:
Affects:
js-toml

https://github.com/advisories/GHSA-3g82-77xr-68x5 ↗

ghsanpmCWE-400CWE-674

js-toml allows uncontrolled recursion in `load()` leading `RangeError` (stack exhaustion) on deeply nested input ## Summary `load()` parses untrusted TOML using a recursive-descent parser (Chevrotain) and a recursive tree-walking interpreter. Neither the parser nor the interpreter enforces a maximum nesting / key depth. A small, attacker-controlled document with deep nesting (arrays, inline tables) or a long dotted key drives recursion past the V8 call-stack limit, and `load()` throws an **uncaught `RangeError: Maximum call stack size exceeded`**. This is a problem for two reasons: 1. **Denial of Service.** A tiny payload (≈2 KB) reliably aborts parsing. In any service that parses user-supplied TOML, an unhandled `RangeError` can crash the worker/process (500 / restart loop). 2. **Error-contract violation.** The library signals invalid input via `SyntaxParseError` (see `src/load/exception.ts`; the entire test suite asserts `SyntaxParseError`). Consumers that follow this contract — ```js try { load(input); } catch (e) { if (e instanceof SyntaxParseError) return badRequest(); throw e; // unexpected -> propagates } ``` — will **re-throw** the `RangeError` instead of treating the input as malformed, turning malformed input into an unexpected fatal error. ## Impact - Unauthenticated attacker who can supply a TOML string to an application using `js-toml` can force `load()` to throw a non-`SyntaxParseError` error. - If the error is not caught by a generic handler, the Node.js process terminates (availability impact). - Even when caught generically, the documented/expected error type contract is broken, which can bypass input-validation branches that key off `SyntaxParseError`. No confidentiality or integrity impact. The error is thrown synchronously and is catchable, so a consumer that catches *all* exceptions is not crashed — this is why the severity is assessed Low–Medium rather than High. ## Affected code / root cause There is no depth bound anywhere in the parse pipeline. Recursion occurs in (at least) two independent places: 1. **Parser (recursive descent).** `src/load/parser.ts` — `array` / `inlineTable` rules recurse through `value` for each nesting level. 2. **Interpreter (tree walk).** `src/load/interpreter.ts` — `assignValue`, `createTable`, `getOrCreateArray` recurse per dotted-key segment, and `cleanInternalProperties` recurses per object depth. Because there is no configurable or hard limit, the recursion depth is bounded only by the V8 stack, and overflow surfaces as a raw `RangeError`. ## Steps to reproduce (PoC) Environment used: Node.js v20, `js-toml@1.1.2`. ```js import { load, SyntaxParseError } from 'js-toml'; function probe(label, toml) { try { load(toml); console.log(`[OK] ${label}`); } catch (e) { const expected = e instanceof SyntaxParseError; console.log(`[${e.constructor.name}${expected ? '' : ' (UNEXPECTED)'}] ${label}: ${String(e.message).split('\n')[0]}`); } } // 1) Deeply nested arrays (~2 KB payload) probe('nested array depth Affected packages: npm:js-toml Patched: js-toml 1.1.3

Linked vulnerabilities (2)

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

js-toml allows uncontrolled recursion in `load()` leading `RangeError` (stack exhaustion) on deeply nested input

CWE: CWE-400, CWE-674Aliases: CVE-2026-63386
CVE-2026-63386 medium 5.3 EPSS 0.36% (p31) NVDCVE.orgGHSA
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

js-toml allows uncontrolled recursion in `load()` leading `RangeError` (stack exhaustion) on deeply nested input

CWE: CWE-400, CWE-674Aliases: GHSA-3g82-77xr-68x5

Also reported by (1)