CVE-2021-37700
JSON

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 packageVersionsReported by
github paste-markdown< 0.3.4CVE List
@github/paste-markdown (npm)before 0.3.4GitHub Advisory Database
paste-markdown_project paste-markdownbefore 0.3.4NVD

All scores

GitHub_M6.5medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N
GitHub6.5medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N
NVD6.1medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
NVD4.3medium CVSS:2.0AV: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.

<!-- ### References _Are there any links users can visit to find out more?_ ### For more information If you have any questions or comments about this advisory: * Open an issue in [example link to repo](http://example.com) * Email us at [example email address](mailto:example@example.com) * -->
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

Sources

SourceRecordLicence
CVE ListCVE-2021-37700 changed 2024-08-04CVE Terms of Use
GitHub Advisory DatabaseGHSA-gpfj-4j6g-c4w9 changed 2026-07-08CC-BY-4.0
NVDCVE-2021-37700 changed 2026-06-17Public domain