# CVE-2020-11888: XSS in python-markdown2

> An attacker can execute arbitrary JavaScript in the context of users viewing markdown content due to improper element name handling in the python-markdown2 library.

- **Severity:** Medium 6.1 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/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:** 20 Apr 2020
- **Updated:** 4 Aug 2024
- **Also known as:** DEBIAN-CVE-2020-11888, GHSA-fv3h-8x5j-pvgq, PYSEC-2020-65, UBUNTU-CVE-2020-11888, openSUSE-SU-2020:0651-1, openSUSE-SU-2020:0656-1

## What is CVE-2020-11888?

CVE-2020-11888 is a medium-severity cross-site scripting vulnerability in n/a, published on 20 Apr 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

python-markdown2 through 2.3.8 allows XSS because element names are mishandled unless a \w+ match succeeds. For example, an attack might use elementname@ or elementname- with an onclick attribute.

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

## Which versions are affected by CVE-2020-11888?

3 open source packages ship an affected version, including markdown2. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `markdown2` | PyPI | All versions | 2.3.9 |
| `markdown2` | PyPI | All versions | 2.3.9 |
| `markdown2` | PyPI | All versions | 2.3.9 |
| `python-markdown2` | SUSE:Package Hub 15 SP1 | All versions | 2.3.7-bp151.2.3.1 |
| `python-markdown2` | openSUSE:Leap 15.1 | All versions | 2.3.7-lp151.2.3.1 |

Products: Python-Markdown2 Project Python-Markdown2.

## How do I fix CVE-2020-11888?

Upgrade markdown2 to 2.3.9 or later.

## Is CVE-2020-11888 being exploited?

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

## Other vulnerabilities in n/a

- [CVE-2009-3724](https://insights.sbomify.com/CVE-2009-3724/): Cross-site scripting in markdown2 for python (medium 6.1)
- [CVE-2018-5773](https://insights.sbomify.com/CVE-2018-5773/): markdown2 is vulnerable to cross-site scripting (medium 6.1)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2020-11888 and fix it if it is affected.

What it is: CVE-2020-11888 is a medium-severity cross-site scripting vulnerability in n/a, published on 20 Apr 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 CVE-2020-11888 in the wild and no public exploit code.

Affected packages and fixed versions:
- markdown2 (PyPI): affected all versions; fixed in 2.3.9
- markdown2 (PyPI): affected all versions; fixed in 2.3.9
- markdown2 (PyPI): affected all versions; fixed in 2.3.9

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

## Sources

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

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