Arbitrary Code Execution in handlebars

handlebars Updated 02 Oct 2025

Summary

04/09/2020
HIGH
Yes i
High
7.3

GHSA-2cf5-4w76-r9qv: Arbitrary Code Execution in handlebars. Affects handlebars across 2 version ranges.

< 3.0.8 >= 4.0.0, < 4.5.2

Fixed in 3.0.8 or 4.5.2, depending on the release line you run. 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 Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

Background

Handlebars is a popular templating engine for JavaScript that allows developers to build dynamic HTML templates. It provides a simple and intuitive syntax for rendering data in HTML. However, versions of handlebars prior to 3.0.8 or 4.5.2 are vulnerable to Arbitrary Code Execution. This vulnerability arises from the package's lookup helper failing to properly validate templates, enabling attackers to submit templates that execute arbitrary JavaScript in the system. This can lead to the execution of arbitrary code in a server processing Handlebars templates or on a victim's browser, effectively serving as Cross-Site Scripting (XSS).

Vulnerability Detail

The vulnerability in handlebars allows attackers to inject and execute arbitrary JavaScript code through the package's lookup helper. By submitting a specially crafted template, an attacker can exploit this vulnerability to run arbitrary code on the server or in a victim's browser. This can lead to various malicious activities, such as stealing sensitive information, modifying web content, or performing unauthorized actions on behalf of the victim. The vulnerability affects versions of handlebars prior to 3.0.8 or 4.5.2.

How To Fix

Latest published version: 4.7.10 as of 22 Oct 2026

npm install handlebars@4.7.10

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

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 3.0.8 3.0.8
    npm install handlebars@3.0.8
  • >= 4.0.0, < 4.5.2 4.5.2
    npm install handlebars@4.5.2

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

There is no known workaround for this vulnerability. It is crucial to update to the fixed versions of handlebars to mitigate the risk of arbitrary code execution.

Conclusion

The vulnerability in handlebars allows for Arbitrary Code Execution, enabling attackers to inject and execute arbitrary JavaScript code. To mitigate this risk, it is essential to update to the fixed versions of handlebars (3.0.8, 4.5.2, or later). Regularly reviewing and updating dependencies is a good practice to ensure the security of your application. For further support on vulnerability remediation, you can reach out to DevNack.com.

See every vulnerability recorded for handlebars →

Share this vulnerability

FAQ

Handlebars is a templating engine for JavaScript that allows developers to build dynamic HTML templates. It provides a simple and intuitive syntax for rendering data in HTML.

Arbitrary Code Execution refers to the ability of an attacker to execute arbitrary code on a target system. In the case of handlebars, this vulnerability allows attackers to inject and execute arbitrary JavaScript code through the package's lookup helper.

The consequences of this vulnerability can be severe. Attackers can use it to steal sensitive information, modify web content, or perform unauthorized actions on behalf of the victim. It can also lead to Cross-Site Scripting (XSS) attacks, compromising the security and integrity of the affected system.

Versions of handlebars prior to 3.0.8 or 4.5.2 are vulnerable to this Arbitrary Code Execution vulnerability.

To protect your application, it is crucial to update the handlebars package to version 3.0.8, 4.5.2, or any later secure release. Regularly reviewing and updating your dependencies is also recommended to ensure the use of secure and up-to-date packages.

Related vulnerabilities

Recent vulnerabilities recorded for handlebars.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

How To Fix

Latest published version: 4.7.10 as of 22 Oct 2026

npm install handlebars@4.7.10

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

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 3.0.8 3.0.8
    npm install handlebars@3.0.8
  • >= 4.0.0, < 4.5.2 4.5.2
    npm install handlebars@4.5.2

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. 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