Vulnerabilities in pkg:npm/express-hbs

PACKAGE
Advisory Identifier: GHSA-rwxp-hwwf-653v
Advisory Summary

CVE-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.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/express-hbs

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/express-hbs. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-rwxp-hwwf-653v CVE-2021-32817 MODERATE Insecure template handling in express-hbs

CVE-2021-32817 at a Glance

CVE Identifier CVE-2021-32817
GHSA Identifier GHSA-rwxp-hwwf-653v
Severity MODERATE
CVSS v3.1 Base Score 5.4
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Express hbs
Package Ecosystem npm
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (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.

express-hbs fixed: Latest secure release
npm install express-hbs@Latest secure release
Verify Direct and Transitive Dependencies

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

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.

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?
CVE-2021-32817 is a security vulnerability in Express hbs involving Insecure template handling in express-hbs under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Express hbs versions are affected?
Affected versions include releases prior to current release patches across affected packages: express-hbs.
What version fixes CVE-2021-32817?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is express-hbs affected?
Yes, express-hbs is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2021-32817?
CVE-2021-32817 has a CVSS v3.1 base score of 5.4 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2021-32817?
CVE-2021-32817 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (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.).
How can I check npm dependencies for CVE-2021-32817?
Run the dependency tree command: 'npm ls express-hbs'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}