Cross-site Scripting Vulnerability in @braintree/sanitize-url Package

node-mermaid Updated 02 Oct 2025

Summary

16/03/2022
N/A
Yes i
Medium
6.1

CVE-2021-23648: The package @braintree/sanitize-url before 6.0.0 are vulnerable to Cross-site Scripting (XSS) due to improper sanitization in sanitizeUrl function. Affects node-mermaid across 2 version ranges.

< 8.7.0+ds+~cs27.17.17-3+deb11u1 < 34fc6435a6028a5a2a3d35b0dee2299e5a9a3580

Fixed in 8.7.0+ds+~cs27.17.17-3+deb11u1. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The @braintree/sanitize-url package is a widely used library designed to sanitize URLs to prevent security issues such as XSS attacks. It is commonly integrated into web applications to ensure that user-generated content does not lead to malicious exploits. However, prior to version 6.0.0, the package had a critical vulnerability due to improper sanitization in its sanitizeUrl function, making it susceptible to XSS attacks.

Vulnerability Detail

The vulnerability arises from the sanitizeUrl function within the @braintree/sanitize-url package, which fails to adequately sanitize input URLs. This oversight allows attackers to inject malicious scripts into web applications that utilize this package, potentially leading to unauthorized access, data theft, or other harmful actions. The vulnerability is classified with a CVSS score of 6.1, indicating a moderate severity level that requires prompt attention.

How To Fix

Minimum fixed version

8.7.0+ds+~cs27.17.17-3+deb11u1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade node-mermaid

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If immediate upgrading is not feasible, consider implementing a custom URL sanitization function that thoroughly checks and cleans input URLs before processing them. Below is an example of a simple workaround function:

function customSanitizeUrl(url) {
    // Basic validation to check if the URL starts with http or https
    if (!/^https?:///i.test(url)) {
        throw new Error('Invalid URL');
    }
    return url;
}

Conclusion

The CVE-2021-23648 vulnerability in the @braintree/sanitize-url package poses a significant risk due to its potential for XSS attacks. Users are strongly advised to update to version 6.0.0 or later to mitigate this risk. Implementing a custom sanitization function can serve as a temporary measure until an upgrade is possible. Utilizing tools like Vulert can further enhance your security posture by providing real-time vulnerability monitoring.

See every vulnerability recorded for node-mermaid →

Share this vulnerability

FAQ

The vulnerability can lead to Cross-site Scripting (XSS) attacks, allowing attackers to execute malicious scripts in the context of the user's browser.

You can use the Vulert platform to monitor and alert for open-source vulnerabilities in your software. Simply upload your manifest file like package-lock.json to check for vulnerabilities.

Versions of @braintree/sanitize-url prior to 6.0.0 are vulnerable to this issue.

Yes, you can implement a custom URL sanitization function as a temporary workaround until you can upgrade the package.

Vulert is a tool that monitors open-source vulnerabilities in your software using a manifest file. It provides real-time alerts for vulnerabilities without requiring code access or installation.

Related vulnerabilities

Recent vulnerabilities recorded for node-mermaid.

How To Fix

Minimum fixed version

8.7.0+ds+~cs27.17.17-3+deb11u1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade node-mermaid

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback