CVE-2021-32818: Haml coffee Insecure Template Handling Vulnerability

HIGH
Advisory Identifier: GHSA-m7mf-vm62-7x3q
CVSS 7.7
CWE-79
Published
Advisory Summary

CVE-2021-32818 is a HIGH (CVSS 7.7) insecure template handling vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Haml coffee libraries in the npm ecosystem. The issue involves insecure template handling in haml-coffee. Remediation is available in the latest vendor maintenance releases.

CVE-2021-32818 at a Glance

CVE Identifier CVE-2021-32818
GHSA Identifier GHSA-m7mf-vm62-7x3q
Severity HIGH
CVSS v3.1 Base Score 7.7
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Haml coffee
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.7

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

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

How to Fix CVE-2021-32818

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

haml-coffee fixed: Latest secure release
npm install haml-coffee@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 haml-coffee

How to Check if You Are Affected

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

npm ls haml-coffee

Analyze the terminal output to locate any version of Haml coffee 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 haml-coffee 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-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Haml coffee, 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

haml-coffee is a JavaScript templating solution. haml-coffee mixes pure template data with engine configuration options through the Express render API. More specifically, haml-coffee supports overriding a series of HTML helper functions through its configuration options. A vulnerable application that passes user controlled request objects to the haml-coffee template engine may introduce RCE vulnerabilities. Additionally control over the escapeHtml parameter through template configuration pollution ensures that haml-coffee would not sanitize template inputs that may result in reflected Cross Site Scripting attacks against downstream applications. There is currently no fix for these issues as of the publication of this CVE. The latest version of haml-coffee is currently 1.14.1. For complete details refer to the referenced GHSL-2021-025.

CVE-2021-32818 Affected Haml coffee Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
haml-coffee
npm
≤ 1.14.1

References

Frequently Asked Questions

What is CVE-2021-32818?
CVE-2021-32818 is a security vulnerability in Haml coffee involving Insecure template handling in haml-coffee under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Haml coffee versions are affected?
Affected versions include releases prior to current release patches across affected packages: haml-coffee.
What version fixes CVE-2021-32818?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is haml-coffee affected?
Yes, haml-coffee 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-32818?
CVE-2021-32818 has a CVSS v3.1 base score of 7.7 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:N.
What CWE is associated with CVE-2021-32818?
CVE-2021-32818 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check npm dependencies for CVE-2021-32818?
Run the dependency tree command: 'npm ls haml-coffee'. 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-m7mf-vm62-7x3q",
  "modified" : "2021-05-17T19:07:00Z",
  "published" : "2021-05-17T20:58:21Z",
  "aliases" : [ "CVE-2021-32818" ],
  "summary" : "Insecure template handling in haml-coffee",
  "details" : "haml-coffee is a JavaScript templating solution. haml-coffee mixes pure template data with engine configuration options through the Express render API. More specifically, haml-coffee supports overriding a series of HTML helper functions through its configuration options. A vulnerable application that passes user controlled request objects to the haml-coffee template engine may introduce RCE vulnerabilities. Additionally control over the escapeHtml parameter through template configuration pollution ensures that haml-coffee would not sanitize template inputs that may result in reflected Cross Site Scripting attacks against downstream applications. There is currently no fix for these issues as of the publication of this CVE. The latest version of haml-coffee is currently 1.14.1. For complete details refer to the referenced GHSL-2021-025.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "haml-coffee"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "1.14.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-32818"
  }, {
    "type" : "ADVISORY",
    "url" : "https://securitylab.github.com/advisories/GHSL-2021-025-haml-coffee"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/package/haml-coffee"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-05-17T19:07:00Z",
    "nvd_published_at" : "2021-05-14T19:15:00Z"
  }
}