CVE-2026-40345: deepmerge-ts: Stack exhaustion when merging recursive object graphs

Published Aug 17, 2026
·
Updated

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

js 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.

Other sources

deepmerge-ts is a typescript library providing functionality to deep merging of javascript objects. Prior to 8.0.0, the deepmerge, deepmergeCustom, deepmergeInto, and deepmergeIntoCustom APIs do not track visited objects or object pairs when recursively merging records. When two input values contain self-references at the same property path, the merge logic repeatedly revisits the same pair until Node.js raises RangeError: Maximum call stack size exceeded. Applications that merge attacker-controlled recursive object graphs can synchronously crash the affected process or cause repeated worker restarts. Plain JSON input alone cannot create the recursive graph required to trigger the issue. This issue is fixed in version 8.0.0.

— MITRE

Affected Software

1 affected componentFixes available
npm/deepmerge-ts<8.0.0
8.0.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/deepmerge-ts to a version that resolves this vulnerability.

    Fixed in 8.0.0
  2. Upgrade

    Upgrade deepmerge-ts to a version that resolves this vulnerability.

    Fixed in 8.0.0
  3. Compensating control

    Avoid passing attacker-controlled recursive object graphs into deepmerge/deepmergeInto (e.g., enforce application-side limits or reject cyclic/self-referential inputs) to prevent stack exhaustion/RangeError: Maximum call stack size exceeded until upgrading.

Event History

Aug 17, 2026
Advisory Published
via GitHub·01:32 PM
Data Sourced
via GitHub·01:32 PM
DescriptionWeaknessAffected Software
Aug 20, 2026
CVE Published
via MITRE·04:33 PM
Data Sourced
via MITRE·04:33 PM
DescriptionWeakness
Data Sourced
via NVD·05:17 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

What is the severity of CVE-2026-40345?

CVE-2026-40345 has a risk rating of 33, indicating a moderate level of severity.

2

How do I fix CVE-2026-40345?

To fix CVE-2026-40345, update to the latest version of the deepmerge-ts library that addresses this vulnerability.

3

What are the potential impacts of CVE-2026-40345?

The potential impacts of CVE-2026-40345 include application crashes due to excessive recursion caused by crafted recursive object graphs.

4

What functions are affected by CVE-2026-40345?

CVE-2026-40345 affects the `deepmerge()` and `deepmergeInto()` functions from the deepmerge-ts library.

5

Is CVE-2026-40345 exploitable in a production environment?

Yes, CVE-2026-40345 is exploitable in a production environment through specially crafted recursive object graphs.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203