{"id":"CVE-2026-63386","aliases":["CVE-2026-63386","GHSA-3g82-77xr-68x5"],"related":[],"kind":"vulnerability","state":"published","title":"js-toml: Uncontrolled recursion in `load()` causes `RangeError` (stack exhaustion) on deeply nested input","summary":"js-toml is a TOML parser for JavaScript. Prior to 1.1.3, load() does not bound nesting or dotted-key depth in the recursive parser at src/load/parser.ts or the interpreter at src/load/interpreter.ts, so deeply nested arrays, deeply nested inline tables, or long dotted keys can exhaust the V8 call stack and throw a raw RangeError instead of the documented SyntaxParseError. Applications that parse attacker-controlled TOML and handle only SyntaxParseError can rethrow the unexpected exception, which can terminate a worker or process and cause denial of service. The exception is synchronous and catchable by consumers that handle all exceptions, and the issue does not affect confidentiality or integrity. This issue is fixed in version 1.1.3.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"js-toml is a TOML parser for JavaScript. Prior to 1.1.3, load() does not bound nesting or dotted-key depth in the recursive parser at src/load/parser.ts or the interpreter at src/load/interpreter.ts, so deeply nested arrays, deeply nested inline tables, or long dotted keys can exhaust the V8 call stack and throw a raw RangeError instead of the documented SyntaxParseError. Applications that parse attacker-controlled TOML and handle only SyntaxParseError can rethrow the unexpected exception, which can terminate a worker or process and cause denial of service. The exception is synchronous and catchable by consumers that handle all exceptions, and the issue does not affect confidentiality or integrity. This issue is fixed in version 1.1.3.","source":"cvelist"},{"lang":"en","text":"## Summary\n\n`load()` parses untrusted TOML using a recursive-descent parser (Chevrotain) and a\nrecursive tree-walking interpreter. Neither the parser nor the interpreter enforces a\nmaximum nesting / key depth. A small, attacker-controlled document with deep nesting\n(arrays, inline tables) or a long dotted key drives recursion past the V8 call-stack\nlimit, and `load()` throws an **uncaught `RangeError: Maximum call stack size exceeded`**.\n\nThis is a problem for two reasons:\n\n1. **Denial of Service.** A tiny payload (≈2 KB) reliably aborts parsing. In any\n   service that parses user-supplied TOML, an unhandled `RangeError` can crash the\n   worker/process (500 / restart loop).\n2. **Error-contract violation.** The library signals invalid input via\n   `SyntaxParseError` (see `src/load/exception.ts`; the entire test suite asserts\n   `SyntaxParseError`). Consumers that follow this contract —\n\n   ```js\n   try { load(input); }\n   catch (e) {\n     if (e instanceof SyntaxParseError) return badRequest();\n     throw e; // unexpected -> propagates\n   }\n   ```\n\n   — will **re-throw** the `RangeError` instead of treating the input as malformed,\n   turning malformed input into an unexpected fatal error.\n\n## Impact\n\n- Unauthenticated attacker who can supply a TOML string to an application using\n  `js-toml` can force `load()` to throw a non-`SyntaxParseError` error.\n- If the error is not caught by a generic handler, the Node.js process terminates\n  (availability impact).\n- Even when caught generically, the documented/expected error type contract is broken,\n  which can bypass input-validation branches that key off `SyntaxParseError`.\n\nNo confidentiality or integrity impact. The error is thrown synchronously and is\ncatchable, so a consumer that catches *all* exceptions is not crashed — this is why the\nseverity is assessed Low–Medium rather than High.\n\n## Affected code / root cause\n\nThere is no depth bound anywhere in the parse pipeline. Recursion occurs in (at least)\ntwo independent places:\n\n1. **Parser (recursive descent).** `src/load/parser.ts` — `array` / `inlineTable`\n   rules recurse through `value` for each nesting level.\n2. **Interpreter (tree walk).** `src/load/interpreter.ts` —\n   `assignValue`, `createTable`, `getOrCreateArray` recurse per dotted-key segment, and\n   `cleanInternalProperties` recurses per object depth.\n\nBecause there is no configurable or hard limit, the recursion depth is bounded only by\nthe V8 stack, and overflow surfaces as a raw `RangeError`.\n\n## Steps to reproduce (PoC)\n\nEnvironment used: Node.js v20, `js-toml@1.1.2`.\n\n```js\nimport { load, SyntaxParseError } from 'js-toml';\n\nfunction probe(label, toml) {\n  try {\n    load(toml);\n    console.log(`[OK]            ${label}`);\n  } catch (e) {\n    const expected = e instanceof SyntaxParseError;\n    console.log(`[${e.constructor.name}${expected ? '' : ' (UNEXPECTED)'}] ${label}: ${String(e.message).split('\\n')[0]}`);\n  }\n}\n\n// 1) Deeply nested arrays  (~2 KB payload)\nprobe('nested array depth 1000', 'x = ' + '['.repeat(1000) + ']'.repeat(1000));\n\n// 2) Deeply nested inline tables\nlet v = '1';\nfor (let i = 0; i < 1000; i++) v = `{ a = ${v} }`;\nprobe('nested inline table depth 1000', 'x = ' + v);\n\n// 3) Deep dotted key (interpreter recursion)\nconst key = Array.from({ length: 5000 }, (_, i) => 'a' + i).join('.');\nprobe('dotted key depth 5000', `${key} = 1`);\n```\n\n### Observed output\n\n```\n[RangeError (UNEXPECTED)] nested array depth 1000: Maximum call stack size exceeded\n[RangeError (UNEXPECTED)] nested inline table depth 1000: Maximum call stack size exceeded\n[RangeError (UNEXPECTED)] dotted key depth 5000: Maximum call stack size exceeded\n```\n\nEach case throws `RangeError`, **not** `SyntaxParseError`. Overflow occurs in single-digit\nmilliseconds, so it is not a CPU-exhaustion issue — it is an immediate, deterministic abort.\n\nNotes on thresholds (machine-dependent; exact numbers vary by stack size):\n- Nested arrays / inline tables overflow at roughly **depth ~1000** (parser recursion).\n- Dotted keys overflow at roughly **depth ~5000** (interpreter recursion); depth 1000 still succeeds.\n\n## Suggested remediation\n\nEnforce an explicit, documented maximum nesting/key depth and surface violations as\n`SyntaxParseError` (consistent with all other invalid-input handling). For example:\n\n- Track current depth in the parser/interpreter and throw `SyntaxParseError`\n  (e.g. `\"Maximum nesting depth exceeded\"`) once a configurable limit (e.g. 100–1000)\n  is reached, **before** the native stack overflows.\n- As a defensive backstop, wrap the top-level `load()` body so that a thrown\n  `RangeError` from stack exhaustion is converted into a `SyntaxParseError`, guaranteeing\n  the documented error contract holds for all malformed input.\n\nA configurable limit (with a safe default) is preferable so legitimate deep documents can\nopt into a higher bound.\n\n## Disclosure\n\nReported privately via GitHub Security Advisory. Happy to provide additional reproducers\nor test against a candidate patch.","format":"markdown","source":"ghsa"}],"published":"2026-09-22T19:00:19.734Z","modified":"2026-11-20T14:45:04.348Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"}],"cwes":["CWE-400","CWE-674"],"affected":[{"ranges":[{"version":"< 1.1.3","status":"affected"}],"vendor":"sunnyadn","product":"js-toml","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.1.3"}],"ecosystem":"npm","package":"js-toml","purl":"pkg:npm/js-toml","source":"ghsa"}],"references":[{"url":"https://github.com/sunnyadn/js-toml/security/advisories/GHSA-3g82-77xr-68x5","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sunnyadn/js-toml/commit/4e10acf1f99ff3cb443c58b8f0a57664e41e87c6","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sunnyadn/js-toml/releases/tag/v1.1.3","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-63386","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/sunnyadn/js-toml","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-09-26T00:06:28.029Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-63386","url":"https://www.cve.org/CVERecord?id=CVE-2026-63386","licence":"CVE Terms of Use","modified":"2026-09-26T00:06:50.619Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-3g82-77xr-68x5","url":"https://github.com/advisories/GHSA-3g82-77xr-68x5","licence":"CC-BY-4.0","modified":"2026-11-20T14:45:04.348Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-63386","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-63386","licence":"Public domain","modified":"2026-09-26T01:17:01.650Z"}],"updatedAt":"2026-11-25T22:59:40.507Z","epss":{"score":0.00361,"percentile":0.31947,"date":"2026-12-01T12:00:22.000Z"}}