Vulnerabilities in pkg:npm/hbs

PACKAGE
Advisory Identifier: GHSA-7f5c-rpf4-86p8
Advisory Summary

CVE-2021-32822 is a MODERATE (CVSS 4.0) insertion of sensitive information into vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Hbs libraries in the npm ecosystem. The issue involves insertion of sensitive information into externally-accessible file or directory and exposure of sensitive information to an unauthorized actor in hbs. Remediation is available in the latest vendor maintenance releases.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/hbs

1 Known Advisory Record(s)

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

Advisory ID CVE / NVD Severity Summary
GHSA-7f5c-rpf4-86p8 CVE-2021-32822 MODERATE Insertion of Sensitive Information into Externally-Accessible File or Directory and Exposure of Sensitive Information to an Unauthorized Actor in hbs

CVE-2021-32822 at a Glance

CVE Identifier CVE-2021-32822
GHSA Identifier GHSA-7f5c-rpf4-86p8
Severity MODERATE
CVSS v3.1 Base Score 4.0
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Hbs
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 4.0

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:N/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 None (I:N)
Availability None (A:N)

How to Fix CVE-2021-32822

To remediate this vulnerability, upgrade all affected 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.

hbs fixed: Latest secure release
npm install 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 hbs

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2021-32822, inspect your project dependencies using npm:

npm ls hbs

Analyze the terminal output to locate any version of 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 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 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

The npm hbs package is an Express view engine wrapper for Handlebars. Depending on usage, users of hbs may be vulnerable to a file disclosure vulnerability. There is currently no patch for this vulnerability. hbs mixes pure template data with engine configuration options through the Express render API. By overwriting internal configuration options a file disclosure vulnerability may be triggered in downstream applications. For an example PoC see the referenced GHSL-2021-020.

CVE-2021-32822 Affected Hbs Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
hbs
npm
≤ 4.1.2

References

Frequently Asked Questions

What is CVE-2021-32822?
CVE-2021-32822 is a security vulnerability in Hbs involving Insertion of Sensitive Information into Externally-Accessible File or Directory and Exposure of Sensitive Information to an Unauthorized Actor in hbs under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Hbs versions are affected?
Affected versions include releases prior to current release patches across affected packages: hbs.
What version fixes CVE-2021-32822?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is hbs affected?
Yes, 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-32822?
CVE-2021-32822 has a CVSS v3.1 base score of 4.0 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:L/I:N/A:N.
What CWE is associated with CVE-2021-32822?
CVE-2021-32822 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-32822?
Run the dependency tree command: 'npm ls 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-7f5c-rpf4-86p8",
  "modified" : "2021-08-26T17:12:06Z",
  "published" : "2021-09-02T17:16:46Z",
  "aliases" : [ "CVE-2021-32822" ],
  "summary" : "Insertion of Sensitive Information into Externally-Accessible File or Directory and Exposure of Sensitive Information to an Unauthorized Actor in hbs",
  "details" : "The npm hbs package is an Express view engine wrapper for Handlebars. Depending on usage, users of hbs may be vulnerable to a file disclosure vulnerability. There is currently no patch for this vulnerability. hbs mixes pure template data with engine configuration options through the Express render API. By overwriting internal configuration options a file disclosure vulnerability may be triggered in downstream applications. For an example PoC see the referenced GHSL-2021-020.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "hbs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "4.1.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-32822"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pillarjs/hbs"
  }, {
    "type" : "ADVISORY",
    "url" : "https://securitylab.github.com/advisories/GHSL-2021-020-pillarjs-hbs"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-200", "CWE-538", "CWE-94" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-08-26T17:12:06Z",
    "nvd_published_at" : "2021-08-16T19:15:00Z"
  }
}