jsondiffpatch Cross-Site Scripting Vulnerability in Annotated Formatter

Vulnerability

A cross-site scripting (XSS) vulnerability has been identified in the jsondiffpatch package, specifically in versions prior to 0.7.6. The issue arises in the annotated formatter, where improper sanitization of JSON values and property names allows for the injection of attacker-controlled HTML. When applications compare untrusted JSON data and render the annotated formatter output in the DOM, this can be exploited to execute malicious scripts in the user's browser.

Impact

Exploitation of this vulnerability allows for cross-site scripting, where injected scripts are executed in the context of the user's browser, potentially leading to session hijacking or other malicious actions.

Reproduction

The vulnerability can be reproduced by comparing two JSON objects using jsondiffpatch's diffing functionality. The first object should contain unescaped HTML, such as an image tag with an event handler, while the second object includes a property name that also contains unescaped HTML. After computing the difference, the annotated formatter output is rendered using 'innerHTML', which interprets the injected HTML and executes the embedded scripts.

Remediation

Users are advised to upgrade jsondiffpatch to version 0.7.6 or higher.

Added: May 16, 2026, 6:20 AM
Updated: May 16, 2026, 6:20 AM

Vulnerability Rating

Custom Algorithm
spread
0.0
impact
1.7
exploitability
7.7
remediation
0.0
relevance
8.4
threat
6.4
urgency
2.9
incentive
0.0

Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.