# GHSA-8fw4-xh83-3j6q: Cross-Site Scripting in diagram-js

> Attackers can execute arbitrary JavaScript via unescaped input in search-pad, affecting users of the diagram-js library.

- **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:** 11 Sep 2020

## What is GHSA-8fw4-xh83-3j6q?

GHSA-8fw4-xh83-3j6q is a cross-site scripting vulnerability in diagram-js, published on 11 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 `diagram-js` prior to 3.3.1 (for 3.x) and 2.6.2 (for 2.x) are vulnerable to Cross-Site Scripting. The package fails to escape output of user-controlled input in `search-pad`, allowing attackers to execute arbitrary JavaScript.

## Recommendation

If you are using diagram-js 3.x, upgrade to version 3.3.1.
If you are using diagram-js 2.x, upgrade to version 2.6.2.

## Which versions are affected by GHSA-8fw4-xh83-3j6q?

4 open source packages ship an affected version, including diagram-js.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `diagram-js` | npm | All versions | 2.6.2 |
| `diagram-js` | npm | All versions | 2.6.2 |
| `diagram-js` | npm | From 3.0.0 | 3.3.1 |
| `diagram-js` | npm | From 3.0.0 | 3.3.1 |

## How do I fix GHSA-8fw4-xh83-3j6q?

Upgrade diagram-js to a fixed version for your release line: 2.6.2 or 3.3.1.

## Is GHSA-8fw4-xh83-3j6q being exploited?

There is no known exploitation of GHSA-8fw4-xh83-3j6q in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-8fw4-xh83-3j6q and fix it if it is affected.

What it is: GHSA-8fw4-xh83-3j6q is a cross-site scripting vulnerability in diagram-js, published on 11 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-8fw4-xh83-3j6q in the wild and no public exploit code.

Affected packages and fixed versions:
- diagram-js (npm): affected all versions; fixed in 2.6.2
- diagram-js (npm): affected all versions; fixed in 2.6.2
- diagram-js (npm): affected from 3.0.0; fixed in 3.3.1
- diagram-js (npm): affected from 3.0.0; fixed in 3.3.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-8fw4-xh83-3j6q/ (Markdown: https://insights.sbomify.com/GHSA-8fw4-xh83-3j6q/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-8fw4-xh83-3j6q

---
From sbomify Insights: https://insights.sbomify.com/GHSA-8fw4-xh83-3j6q/
Summaries are generated and may contain mistakes; the official description above is the record.
