npm serialize-javascript Cross-Site Scripting Vulnerability

Vulnerability

A cross-site scripting (XSS) vulnerability has been identified in the npm package 'serialize-javascript', affecting versions prior to 6.0.2. The issue arises because the module fails to properly sanitize certain inputs, such as regular expressions and other JavaScript object types. This lack of sanitization allows attackers to inject malicious code that can be executed when the data is deserialized by a web browser. The vulnerability is particularly critical in environments where serialized data is sent to web clients, as it could compromise the security of the website or web application using this package.

Impact

Exploitation of this vulnerability allows for cross-site scripting attacks, where injected scripts are executed in the context of the user's browser. This could lead to unauthorized actions or exposure of sensitive data, such as cookies containing session information.

Reproduction

To reproduce this vulnerability, serialize a JavaScript object that includes a regular expression or another unsanitized object type using a version of 'serialize-javascript' prior to 6.0.2. Once serialized, the data can be sent to a web client, where the injected script will execute, demonstrating the cross-site scripting vulnerability.

Remediation

Users can upgrade to 'serialize-javascript' version 6.0.2 or later, where this vulnerability has been fixed.

Added: Sep 1, 2025, 7:22 PM
Updated: Sep 1, 2025, 7:22 PM

Vulnerability Rating

Custom Algorithm
spread
0.0
impact
1.7
exploitability
7.4
remediation
0.0
relevance
0.0
threat
4.8
urgency
2.9
incentive
1.7

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