{"id":"CVE-2021-37700","aliases":["CVE-2021-37700","GHSA-gpfj-4j6g-c4w9"],"related":[],"kind":"vulnerability","state":"published","title":"Clipboard-based DOM-XSS","summary":"@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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"@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.","source":"cvelist"},{"lang":"en","text":"### Impact\n\nA 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.\n\nThe 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**.\n\n```typescript\nfunction generateText(transfer: DataTransfer): string | undefined {\n  if (Array.from(transfer.types).indexOf('text/html') === -1) return\n\n  let html = transfer.getData('text/html')\n  if (!/<table/i.test(html)) return\n\n  html = html.replace(/<meta.*?>/, '')\n\n  const el = document.createElement('div')\n  el.innerHTML = html\n  const tables = el.querySelectorAll('table')\n\n  for (const table of tables) {\n    if (table.closest('[data-paste-markdown-skip]')) {\n      table.replaceWith(new Text(table.textContent || ''))\n    }\n    const formattedTable = tableMarkdown(table)\n    table.replaceWith(new Text(formattedTable))\n  }\n\n  return el.innerHTML\n}\n```\n\n### Patches\nA security patch was released in [version 0.3.4](https://github.com/github/paste-markdown/releases/tag/v0.3.4).\n\n### Workarounds\nA Content Security Policy that prevents `unsafe-inline` helps reduce the likelihood of this vulnerability being exploited in modern browsers.\n\n<!--\n### References\n_Are there any links users can visit to find out more?_\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [example link to repo](http://example.com)\n* Email us at [example email address](mailto:example@example.com)\n*\n-->","format":"markdown","source":"ghsa"},{"lang":"es","text":"@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.","source":"nvd"}],"published":"2021-08-12T20:42:17.000Z","modified":"2026-07-08T06:28:23.280Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N","score":6.5,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N","score":6.5,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N","score":6.5,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:M/Au:N/C:N/I:P/A:N","score":4.3,"rating":"MEDIUM"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":"< 0.3.4","status":"affected"}],"vendor":"github","product":"paste-markdown","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.3.4"}],"ecosystem":"npm","package":"@github/paste-markdown","purl":"pkg:npm/%40github/paste-markdown","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"0.3.4"}],"vendor":"paste-markdown_project","product":"paste-markdown","cpe":"cpe:2.3:a:paste-markdown_project:paste-markdown:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/github/paste-markdown/security/advisories/GHSA-gpfj-4j6g-c4w9","tags":["exploit","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/github/paste-markdown/commit/32b7ea3f29ae8f256f9d19768387be42678ddf30","tags":["patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/github/paste-markdown/releases/tag/v0.3.4","tags":["release-notes","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://www.npmjs.com/package/%40github/paste-markdown","tags":["x-refsource-misc","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-37700","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/github/paste-markdown","tags":["package"],"sources":["ghsa"]},{"url":"https://www.npmjs.com/package/@github/paste-markdown","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-37700","url":"https://www.cve.org/CVERecord?id=CVE-2021-37700","licence":"CVE Terms of Use","modified":"2024-08-04T01:23:01.457Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-gpfj-4j6g-c4w9","url":"https://github.com/advisories/GHSA-gpfj-4j6g-c4w9","licence":"CC-BY-4.0","modified":"2026-07-08T06:28:23.280Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-37700","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-37700","licence":"Public domain","modified":"2026-06-17T04:01:00.793Z"}],"updatedAt":"2026-11-25T22:58:03.191Z","epss":{"score":0.0166,"percentile":0.77373,"date":"2026-12-01T12:00:22.000Z"}}