Cross-Site Scripting (XSS) Vulnerability in mustache

mustache Updated 02 Oct 2025

Summary

09/10/2018
MODERATE
Yes i
Moderate
Not published

GHSA-3233-rgx3-c2wh: Moderate severity vulnerability that affects mustache. Affects mustache versions < 2.2.1. Fixed in 2.2.1. 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 Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

mustache is an npm package used for logic-less templates. It allows developers to separate the presentation layer from the data in their applications. The package provides a simple and lightweight templating engine that can be used in various programming languages. However, versions before 2.2.1 for Node.js are vulnerable to a cross-site scripting (XSS) attack.

Vulnerability Detail

The vulnerability in mustache arises from a lack of proper attribute quoting in templates. An attacker can exploit this by crafting a malicious template with an unquoted attribute, which can lead to the execution of arbitrary JavaScript code in the context of the victim's browser. This can result in various security issues, such as session hijacking, data theft, or the injection of malicious content.

How To Fix

Latest published version: 4.2.0 as of 22 Oct 2026

npm install mustache@4.2.0

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

2.2.1

This is the first release that contains the fix.

npm install mustache@2.2.1

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

Workaround

If updating to the latest version is not immediately feasible, developers can mitigate the risk by manually quoting all attributes in their templates. This can be done by adding double quotes around attribute values in the template code. For example, instead of {{name}}, use {{"name"}}. However, it is strongly recommended to update to the latest version as soon as possible.

Conclusion

The cross-site scripting (XSS) vulnerability in mustache versions prior to 2.2.1 for Node.js can have serious security implications. It is crucial for developers to update their mustache package to the latest version or manually quote attributes in their templates to prevent exploitation. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for mustache →

Share this vulnerability

FAQ

Cross-site scripting (XSS) is a type of security vulnerability that allows attackers to inject malicious scripts into web pages viewed by other users. This can lead to the execution of arbitrary code in the victim's browser, compromising their data and potentially enabling further attacks.

The vulnerability affects mustache versions prior to 2.2.1 for Node.js. It allows remote attackers to conduct cross-site scripting (XSS) attacks by leveraging a template with an unquoted attribute. This can lead to the execution of arbitrary JavaScript code in the victim's browser.

Exploiting this vulnerability can have various consequences, including session hijacking, data theft, and the injection of malicious content. Attackers can use the XSS vulnerability to steal sensitive information, manipulate the appearance of web pages, or perform actions on behalf of the victim.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability. Vulert analyzes your package-lock.json file and provides real-time alerts for open-source vulnerabilities, including this XSS vulnerability in mustache.

If updating to mustache version 2.2.1 or higher is not immediately feasible, you can manually quote all attributes in your templates to mitigate the risk. This involves adding double quotes around attribute values in the template code. However, it is strongly recommended to update to the latest version as soon as possible.

Related vulnerabilities

Recent vulnerabilities recorded for mustache.

How To Fix

Latest published version: 4.2.0 as of 22 Oct 2026

npm install mustache@4.2.0

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

2.2.1

This is the first release that contains the fix.

npm install mustache@2.2.1

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