# GHSA-cg48-9hh2-x6mx: HTML Injection in preact

> Attackers can inject JavaScript via unsanitized JSON input in preact, leading to Cross-Site Scripting and potential code execution.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 2 Sep 2020

## What is GHSA-cg48-9hh2-x6mx?

GHSA-cg48-9hh2-x6mx is a cross-site scripting vulnerability in preact, published on 2 Sep 2020. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

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.

## Which versions are affected by GHSA-cg48-9hh2-x6mx?

2 open source packages ship an affected version, including preact.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `preact` | npm | From 10.0.0-alpha.0 | 10.0.0-beta.1 |
| `preact` | npm | From 10.0.0-alpha.0 | 10.0.0-beta.1 |

## How do I fix GHSA-cg48-9hh2-x6mx?

Upgrade preact to 10.0.0-beta.1 or later.

## Is GHSA-cg48-9hh2-x6mx being exploited?

There is no known exploitation of GHSA-cg48-9hh2-x6mx in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-cg48-9hh2-x6mx and fix it if it is affected.

What it is: GHSA-cg48-9hh2-x6mx is a cross-site scripting vulnerability in preact, published on 2 Sep 2020. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-cg48-9hh2-x6mx in the wild and no public exploit code.

Affected packages and fixed versions:
- preact (npm): affected from 10.0.0-alpha.0; fixed in 10.0.0-beta.1
- preact (npm): affected from 10.0.0-alpha.0; fixed in 10.0.0-beta.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-cg48-9hh2-x6mx/ (Markdown: https://insights.sbomify.com/GHSA-cg48-9hh2-x6mx/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-cg48-9hh2-x6mx

---
From sbomify Insights: https://insights.sbomify.com/GHSA-cg48-9hh2-x6mx/
Summaries are generated and may contain mistakes; the official description above is the record.
