CVE-2021-23369: Remote Code Execution in Handlebars
Summary
Your scan reports handlebars 4.7.6. Fixed in 4.7.7.
CVE-2021-23369: Remote code execution in handlebars when compiling templates. Affects handlebars versions < 4.7.7. Fixed in 4.7.7. How to fix ↓
Also tracked for
- node-handlebars · Debian:11
The same CVE-2021-23369 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Background
Handlebars is a popular templating engine used in web development. It allows developers to create dynamic HTML templates by combining static HTML with variables and logic. Handlebars is widely used in both npm and Maven ecosystems. However, versions of Handlebars prior to 4.7.7 are vulnerable to Remote Code Execution (RCE) when certain compiling options are selected to compile templates from untrusted sources.
Vulnerability Detail
The vulnerability in Handlebars arises from a lack of proper input validation and sanitization when compiling templates. An attacker can exploit this vulnerability by injecting malicious code into a template, which is then executed on the server-side when the template is rendered. This can lead to arbitrary code execution, enabling the attacker to perform unauthorized actions, access sensitive data, or compromise the entire system. The severity of this vulnerability is rated as CRITICAL with a CVSS score of 9.8.
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 version below is the minimum fixed release for this vulnerability.
If you need the minimum change
4.7.7
This is the first release that contains the fix.
npm install handlebars@4.7.7
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If upgrading to the latest version is not immediately feasible, a temporary workaround is to avoid using Handlebars to compile templates from untrusted sources. Instead, restrict template compilation to trusted sources or implement additional input validation and sanitization measures to mitigate the risk of code injection.
Conclusion
The vulnerability in Handlebars can be mitigated by upgrading to the latest secure version or implementing appropriate input validation and sanitization measures. It is crucial for developers to promptly address this vulnerability to prevent potential unauthorized access and code execution. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for handlebars →
FAQ
Handlebars is a templating engine used in web development to create dynamic HTML templates.
The vulnerability allows remote code execution, which can lead to unauthorized actions, data breaches, and system compromise.
Upgrade to Handlebars version 4.7.7 or later, which includes patches to address the vulnerability.
If immediate upgrade is not possible, restrict template compilation to trusted sources or implement additional input validation and sanitization measures.
The severity of this vulnerability is rated as CRITICAL with a CVSS score of 9.8.
References
Related vulnerabilities
Recent vulnerabilities recorded for handlebars.
Follow Vulert in Google
Get more Vulert vulnerability and dependency-security updates in Google Search and AI results.