GHSA-cg48-9hh2-x6mx: Preact HTML Injection Vulnerability

MODERATE
CWE-74
Published
Advisory Summary

GHSA-cg48-9hh2-x6mx is a MODERATE html injection vulnerability (CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')) affecting Preact libraries in the npm ecosystem. The issue involves html injection in preact. Remediation is available by upgrading affected packages to version 10.0.0-beta.1.

GHSA-cg48-9hh2-x6mx at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-cg48-9hh2-x6mx
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
Affected Product Preact
Package Ecosystem npm
Published Date
Last Updated

How to Fix GHSA-cg48-9hh2-x6mx

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

preact fixed: 10.0.0-beta.1
npm install preact@10.0.0-beta.1
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 preact

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-cg48-9hh2-x6mx, inspect your project dependencies using npm:

npm ls preact

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

Note: The npm ls preact 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-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection'), where the product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. In Preact, 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

Versions of `preact` 10.x on prerelease tags alpha and beta prior to 10.0.0-beta.1 are vulnerable to HTML Injection. Due to insufficient input validation the package allows attackers to inject JavaScript objects as virtual-dom nodes, which may lead to Cross-Site Scripting. This requires user input parsed with `JSON.parse()` to be passed directly into JSX without sanitization. ## Recommendation Upgrade to version 10.0.0-beta.1.

GHSA-cg48-9hh2-x6mx Affected Preact Versions

1 component(s)
Fixed Versions:
10.0.0-beta.1
Product / Package Ecosystem Affected Versions Fixed Version
preact
npm
≥ 10.0.0-alpha.0
< 10.0.0-beta.1
10.0.0-beta.1

References

Frequently Asked Questions

What is GHSA-cg48-9hh2-x6mx?
GHSA-cg48-9hh2-x6mx is a security vulnerability in Preact involving HTML Injection in preact under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection').
Which Preact versions are affected?
Affected versions include releases prior to 10.0.0-beta.1 across affected packages: preact.
What version fixes GHSA-cg48-9hh2-x6mx?
Upgrading to 10.0.0-beta.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is preact affected?
Yes, preact is affected in releases prior to 10.0.0-beta.1. Upgrade your dependency to 10.0.0-beta.1 or later.
What CWE is associated with GHSA-cg48-9hh2-x6mx?
GHSA-cg48-9hh2-x6mx is classified under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') (The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.).
How can I check npm dependencies for GHSA-cg48-9hh2-x6mx?
Run the dependency tree command: 'npm ls preact'. 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-cg48-9hh2-x6mx",
  "modified" : "2021-09-27T20:53:56Z",
  "published" : "2020-09-02T18:28:58Z",
  "aliases" : [ ],
  "summary" : "HTML Injection in preact",
  "details" : "Versions of `preact` 10.x on prerelease tags alpha and beta prior to 10.0.0-beta.1 are vulnerable to HTML Injection. Due to insufficient input validation the package allows attackers to inject JavaScript objects as virtual-dom nodes, which may lead to Cross-Site Scripting. This requires user input parsed with `JSON.parse()` to be passed directly into JSX without sanitization.\n\n\n## Recommendation\n\nUpgrade to version 10.0.0-beta.1.",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "preact"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "10.0.0-alpha.0"
      }, {
        "fixed" : "10.0.0-beta.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 10.0.0-beta.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/developit/preact/pull/1528"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/developit/preact"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/developit/preact/releases/tag/10.0.0-beta.1"
  }, {
    "type" : "WEB",
    "url" : "https://medium.com/dailyjs/exploiting-script-injection-flaws-in-reactjs-883fb1fe36c1"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/advisories/835"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-74" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-08-31T18:37:35Z",
    "nvd_published_at" : null
  }
}