CVE-2020-7773 Cross-site Scripting (XSS)
An attacker can inject malicious JavaScript via the lang attribute in inline code highlighting, leading to cross-site scripting attacks.
- 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
What is CVE-2020-7773?
CVE-2020-7773 is a medium-severity cross-site scripting vulnerability in markdown-it-highlightjs, published on 16 Nov 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
This affects the package markdown-it-highlightjs before 3.3.1. It is possible insert malicious JavaScript as a value of lang in the markdown-it-highlightjs Inline code highlighting feature. const markdownItHighlightjs = require("markdown-it-highlightjs"); const md = require('markdown-it'); const reuslt_xss = md() .use(markdownItHighlightjs, { inline: true }) .render('console.log(42){.">js}'); console.log(reuslt_xss);
Weakness: CWE-79
Which versions are affected by CVE-2020-7773?
2 open source packages ship an affected version, including markdown-it-highlightjs. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
markdown-it-highlightjs npm | All versions | 3.3.1 |
markdown-it-highlightjs npm | All versions | 3.3.1 |
Products include Markdown-It-Highlightjs Project Markdown-It-Highlightjs.
How do I fix CVE-2020-7773?
Upgrade markdown-it-highlightjs to 3.3.1 or later.
Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.
Is CVE-2020-7773 being exploited?
There is no known exploitation of CVE-2020-7773 in the wild and no public exploit code.
Sources
Also known as GHSA-f246-xrrj-g8j6, SNYK-JS-MARKDOWNITHIGHLIGHTJS-1040461.