6.5medium
Clipboard-based DOM-XSS
- Severity
- 6.5medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 1.66% (higher than 77% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-gpfj-4j6g-c4w9
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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| github paste-markdown | < 0.3.4 | CVE List |
| @github/paste-markdown (npm) | before 0.3.4 | GitHub Advisory Database |
| paste-markdown_project paste-markdown | before 0.3.4 | NVD |
All scores
| GitHub_M | 6.5medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N |
| GitHub | 6.5medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N |
| NVD | 6.1medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N |
| NVD | 4.3medium CVSS:2.0 | AV:N/AC:M/Au:N/C:N/I:P/A:N |
Classification
What each source says
CVE List
@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.
GitHub Advisory Database
Impact
A self Cross-Site Scripting vulnerability exists in the @github/paste-markdown library. 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.
The following @github/paste-markdown code snippet is triggered when the user pastes something and the browser's clipboard data contains an entry whose content-type is text/HTML.
function generateText(transfer: DataTransfer): string | undefined {
if (Array.from(transfer.types).indexOf('text/html') === -1) return
let html = transfer.getData('text/html')
if (!/<table/i.test(html)) return
html = html.replace(/<meta.*?>/, '')
const el = document.createElement('div')
el.innerHTML = html
const tables = el.querySelectorAll('table')
for (const table of tables) {
if (table.closest('[data-paste-markdown-skip]')) {
table.replaceWith(new Text(table.textContent || ''))
}
const formattedTable = tableMarkdown(table)
table.replaceWith(new Text(formattedTable))
}
return el.innerHTML
}
Patches
A security patch was released in version 0.3.4.
Workarounds
A Content Security Policy that prevents unsafe-inline helps reduce the likelihood of this vulnerability being exploited in modern browsers.
NVD (es)
@github/paste-markdown es un paquete npm para pegar objetos markdown. Se presenta una vulnerabilidad de tipo Cross-Site Scripting en @github/paste-markdown versiones anteriores a 0.3.4. Si los datos del portapapeles contienen la cadena "(table)", se crea dinámicamente un **div**, y el contenido del portapapeles es copiado en su propiedad **innerHTML** sin ningún tipo de saneo, resultando en una ejecución inapropiada de JavaScript en el navegador de la víctima (el usuario que pegó el código). Están afectados los usuarios a los que se les indica que copien texto de un sitio web malicioso y lo peguen en páginas que usan esta biblioteca. Esto se ha corregido en la versión 0.3.4. Consulte el aviso de GitHub al que se hace referencia para obtener más detalles, incluido un ejemplo de explotación.
References
| https://github.com/github/paste-markdown/security/advisories/GHSA-gpfj-4j6g-c4w9 | exploit, third-party-advisory, web | |
| https://github.com/github/paste-markdown/commit/32b7ea3f29ae8f256f9d19768387be42678ddf30 | patch, third-party-advisory, web | |
| https://github.com/github/paste-markdown/releases/tag/v0.3.4 | release-notes, third-party-advisory, web | |
| https://www.npmjs.com/package/%40github/paste-markdown | ||
| https://nvd.nist.gov/vuln/detail/CVE-2021-37700 | advisory | |
| https://github.com/github/paste-markdown | package | |
| https://www.npmjs.com/package/@github/paste-markdown | web | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-37700 changed 2024-08-04 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-gpfj-4j6g-c4w9 changed 2026-07-08 | CC-BY-4.0 |
| NVD | CVE-2021-37700 changed 2026-06-17 | Public domain |