Vulnerabilities in pkg:maven/org.webjars/handlebars

PACKAGE
Advisory Identifier: GHSA-f2jv-r9rf-7988
Advisory Summary

CVE-2021-23369 is a CRITICAL (CVSS 9.8) remote code execution vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Handlebars libraries in the npm ecosystem. The issue involves remote code execution in handlebars when compiling templates. Remediation is available by upgrading affected packages to version 4.7.7.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:maven/org.webjars/handlebars

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:maven/org.webjars/handlebars. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-f2jv-r9rf-7988 CVE-2021-23369 CRITICAL Remote code execution in handlebars when compiling templates

CVE-2021-23369 at a Glance

CVE Identifier CVE-2021-23369
GHSA Identifier GHSA-f2jv-r9rf-7988
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Handlebars
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 9.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2021-23369

To remediate this vulnerability, upgrade all affected Handlebars dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

handlebars fixed: 4.7.7
npm install handlebars@4.7.7
org.webjars:handlebars fixed: 4.7.7
<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>handlebars</artifactId>
    <version>4.7.7</version>
</dependency>
org.webjars.npm:handlebars fixed: 4.7.7
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>handlebars</artifactId>
    <version>4.7.7</version>
</dependency>
org.webjars.bowergithub.wycats:handlebars.js fixed: 4.7.7
<dependency>
    <groupId>org.webjars.bowergithub.wycats</groupId>
    <artifactId>handlebars.js</artifactId>
    <version>4.7.7</version>
</dependency>
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 handlebars

How to Check if You Are Affected

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

npm ls handlebars

Analyze the terminal output to locate any version of Handlebars in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.7.7), your application is affected.

Note: The npm ls handlebars 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 Handlebars, 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 package handlebars before 4.7.7 are vulnerable to Remote Code Execution (RCE) when selecting certain compiling options to compile templates coming from an untrusted source.

CVE-2021-23369 Affected Handlebars Versions

4 component(s)
Fixed Versions:
4.7.7
Product / Package Ecosystem Affected Versions Fixed Version
handlebars
npm
< 4.7.7
4.7.7
org.webjars:handlebars
Maven
< 4.7.7
4.7.7
org.webjars.npm:handlebars
Maven
< 4.7.7
4.7.7
org.webjars.bowergithub.wycats:handlebars.js
Maven
< 4.7.7
4.7.7

References

Frequently Asked Questions

What is CVE-2021-23369?
CVE-2021-23369 is a security vulnerability in Handlebars involving Remote code execution in handlebars when compiling templates under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Handlebars versions are affected?
Affected versions include releases prior to 4.7.7 across affected packages: handlebars, org.webjars:handlebars, org.webjars.npm:handlebars, org.webjars.bowergithub.wycats:handlebars.js.
What version fixes CVE-2021-23369?
Upgrading to 4.7.7 (or the latest patched release for your respective branch) resolves the vulnerability.
Is handlebars affected?
Yes, handlebars is affected in releases prior to 4.7.7. Upgrade your dependency to 4.7.7 or later.
Is handlebars.js affected?
Yes, org.webjars.bowergithub.wycats:handlebars.js is affected in releases prior to 4.7.7. Upgrade your dependency to 4.7.7 or later.
What is the CVSS score of CVE-2021-23369?
CVE-2021-23369 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2021-23369?
CVE-2021-23369 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-23369?
Run the dependency tree command: 'npm ls handlebars'. 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-f2jv-r9rf-7988",
  "modified" : "2022-10-04T16:29:30Z",
  "published" : "2021-05-06T15:57:44Z",
  "aliases" : [ "CVE-2021-23369" ],
  "summary" : "Remote code execution in handlebars when compiling templates",
  "details" : "The package handlebars before 4.7.7 are vulnerable to Remote Code Execution (RCE) when selecting certain compiling options to compile templates coming from an untrusted source.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "handlebars"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.7.7"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.webjars:handlebars"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.7.7"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.webjars.npm:handlebars"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.7.7"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.webjars.bowergithub.wycats:handlebars.js"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.7.7"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-23369"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/handlebars-lang/handlebars.js/commit/b6d3de7123eebba603e321f04afdbae608e8fea8"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/handlebars-lang/handlebars.js/commit/f0589701698268578199be25285b2ebea1c1e427"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/wycats/handlebars.js"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20210604-0008"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARS-1074950"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSBOWER-1074951"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSNPM-1074952"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JS-HANDLEBARS-1056767"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-04-13T22:07:10Z",
    "nvd_published_at" : "2021-04-12T14:15:00Z"
  }
}