# CVE-2021-37700: Clipboard-based DOM-XSS

> An attacker can execute arbitrary JavaScript in a victim's browser by tricking them into pasting malicious clipboard data into applications using this library.

- **Severity:** Medium 6.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N`)
- **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:** 12 Aug 2021
- **Updated:** 4 Aug 2024
- **Also known as:** GHSA-gpfj-4j6g-c4w9

## What is CVE-2021-37700?

CVE-2021-37700 is a medium-severity cross-site scripting vulnerability in github paste-markdown, published on 12 Aug 2021. 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

@github/paste-markdown is an npm package for pasting markdown objects. A self Cross-Site Scripting vulnerability exists in the @github/paste-markdown before version 0.3.4. If the clipboard data contains the string `<table>`, a **div** is dynamically created, and the clipboard content is copied into its **innerHTML** property without any sanitization, resulting in improper execution of JavaScript in the browser of the victim (the user who pasted the code). Users directed to copy text from a malicious website and paste it into pages that utilize this library are affected. This is fixed in version 0.3.4. Refer the to the referenced GitHub Advisory for more details including an example exploit.

Weakness: CWE-79 (Improper Neutralization of Input During Web Page Generation)

## Which versions are affected by CVE-2021-37700?

2 open source packages ship an affected version, including @github/paste-markdown. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `@github/paste-markdown` | npm | All versions | 0.3.4 |
| `@github/paste-markdown` | npm | All versions | 0.3.4 |

Products: Paste-Markdown Project Paste-Markdown.

## How do I fix CVE-2021-37700?

Upgrade @github/paste-markdown to 0.3.4 or later.

## Is CVE-2021-37700 being exploited?

There is no known exploitation of CVE-2021-37700 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-37700 and fix it if it is affected.

What it is: CVE-2021-37700 is a medium-severity cross-site scripting vulnerability in github paste-markdown, published on 12 Aug 2021. 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 CVE-2021-37700 in the wild and no public exploit code.

Affected packages and fixed versions:
- @github/paste-markdown (npm): affected all versions; fixed in 0.3.4
- @github/paste-markdown (npm): affected all versions; fixed in 0.3.4

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/CVE-2021-37700/ (Markdown: https://insights.sbomify.com/CVE-2021-37700/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2021-37700
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2021-37700
- OSV: https://osv.dev/vulnerability/CVE-2021-37700

---
From sbomify Insights: https://insights.sbomify.com/CVE-2021-37700/
Summaries are generated and may contain mistakes; the official description above is the record.
