CVE-2021-32817: Express hbs Insecure Template Handling Vulnerability
MODERATECVE-2021-32817 is a MODERATE (CVSS 5.4) insecure template handling vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Express hbs libraries in the npm ecosystem. The issue involves insecure template handling in express-hbs. Remediation is available in the latest vendor maintenance releases.
CVE-2021-32817 at a Glance
Security Impact
CVSS: 5.4
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N).
How to Fix CVE-2021-32817
To remediate this vulnerability, upgrade all affected Express hbs dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install express-hbs@Latest secure release
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls express-hbs
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2021-32817, inspect your project dependencies using npm:
npm ls express-hbs
Analyze the terminal output to locate any version of Express hbs in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.
Note: The npm ls express-hbs command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Express hbs, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2021-32817 Affected Express hbs Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
express-hbs
|
npm |
≤ 2.4.0
|
|
References
Frequently Asked Questions
What is CVE-2021-32817?
Which Express hbs versions are affected?
What version fixes CVE-2021-32817?
Is express-hbs affected?
What is the CVSS score of CVE-2021-32817?
What CWE is associated with CVE-2021-32817?
How can I check npm dependencies for CVE-2021-32817?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-rwxp-hwwf-653v",
"modified" : "2023-04-04T17:30:41Z",
"published" : "2021-05-17T20:58:51Z",
"aliases" : [ "CVE-2021-32817" ],
"summary" : "Insecure template handling in express-hbs",
"details" : "express-hbs is an Express handlebars template engine. express-hbs mixes pure template data with engine configuration options through the Express render API. More specifically, the layout parameter may trigger file disclosure vulnerabilities in downstream applications. This potential vulnerability is somewhat restricted in that only files with existing extentions (i.e. file.extension) can be included, files that lack an extension will have .hbs appended to them. For complete details refer to the referenced GHSL-2021-019 report. Notes in documentation have been added to help users of express-hbs avoid this potential information exposure vulnerability.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "express-hbs"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"last_affected" : "2.4.0"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-32817"
}, {
"type" : "WEB",
"url" : "https://github.com/TryGhost/express-hbs/commit/ff6fad6e357699412d4e916273314e5e7af1500e"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/TryGhost/express-hbs"
}, {
"type" : "WEB",
"url" : "https://github.com/TryGhost/express-hbs#%EF%B8%8F-this-creates-a-potential-security-vulnerability"
}, {
"type" : "ADVISORY",
"url" : "https://securitylab.github.com/advisories/GHSL-2021-019-express-hbs"
}, {
"type" : "WEB",
"url" : "https://www.npmjs.com/package/express-hbs"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-200", "CWE-94" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2021-05-17T19:09:07Z",
"nvd_published_at" : "2021-05-14T19:15:00Z"
}
}