{"id":"CVE-2026-22787","aliases":["CVE-2026-22787","GHSA-w8x4-x68c-m6fc"],"related":[],"kind":"vulnerability","state":"published","title":"html2pdf.js has a cross-site scripting vulnerability","summary":"html2pdf.js converts any webpage or element into a printable PDF entirely client-side. Prior to 0.14.0, html2pdf.js contains a cross-site scripting (XSS) vulnerability when given a text source rather than an element. This text is not sufficiently sanitized before being attached to the DOM, allowing malicious scripts to be run on the client browser and risking the confidentiality, integrity, and availability of the page's data. This vulnerability has been fixed in html2pdf.js@0.14.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"html2pdf.js converts any webpage or element into a printable PDF entirely client-side. Prior to 0.14.0, html2pdf.js contains a cross-site scripting (XSS) vulnerability when given a text source rather than an element. This text is not sufficiently sanitized before being attached to the DOM, allowing malicious scripts to be run on the client browser and risking the confidentiality, integrity, and availability of the page's data. This vulnerability has been fixed in html2pdf.js@0.14.0.","source":"cvelist"},{"lang":"en","text":"### Impact\nhtml2pdf.js contains a cross-site scripting (XSS) vulnerability when given a text source rather than an element. This text is not sufficiently sanitized before being attached to the DOM, allowing malicious scripts to be run on the client browser and risking the confidentiality, integrity, and availability of the page's data.\n\nExample attack vector:\n\n```js\nimport html2pdf from 'html2pdf.js/src/index.js';\n\nconst maliciousHTML = '<img src=x onerror=\"alert(document.cookie)\">';\nhtml2pdf(maliciousHTML);\n// or html2pdf().from(maliciousHTML);\n```\n\n### Patches\nThis vulnerability has been fixed in html2pdf.js@0.14.0 to sanitize text sources using DOMPurify. There are no other breaking changes in this version.\n\n### Workarounds\nUsers of earlier versions of html2pdf.js must safely sanitize any text before using it as a source in html2pdf.js.\n\n### References\n- Initial report: https://github.com/eKoopmans/html2pdf.js/issues/865\n- Fix: https://github.com/eKoopmans/html2pdf.js/pull/877, [v0.14.0](https://github.com/eKoopmans/html2pdf.js/releases/tag/v0.14.0)\n- CVE-2026-22787: https://nvd.nist.gov/vuln/detail/CVE-2026-22787","format":"markdown","source":"ghsa"},{"lang":"es","text":"html2pdf.js convierte cualquier página web o elemento en un PDF imprimible completamente del lado del cliente. Antes de 0.14.0, html2pdf.js contiene una vulnerabilidad de cross-site scripting (XSS) cuando se le proporciona una fuente de texto en lugar de un elemento. Este texto no se sanea suficientemente antes de ser adjuntado al DOM, permitiendo que se ejecuten scripts maliciosos en el navegador del cliente y poniendo en riesgo la confidencialidad, integridad y disponibilidad de los datos de la página. Esta vulnerabilidad ha sido corregida en html2pdf.js@0.14.0.","source":"nvd"}],"published":"2026-01-14T16:52:38.372Z","modified":"2026-06-17T10:20:25.633Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:L/SC:N/SI:N/SA:N","score":8.7,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:L/SC:N/SI:N/SA:N","score":8.7,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:L/SC:N/SI:N/SA:N","rating":"HIGH"},{"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"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":"< 0.14.0","status":"affected"}],"vendor":"eKoopmans","product":"html2pdf.js","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.14.0"}],"ecosystem":"npm","package":"html2pdf.js","purl":"pkg:npm/html2pdf.js","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"0.14.0"}],"vendor":"ekoopmans","product":"html2pdf.js","cpe":"cpe:2.3:a:ekoopmans:html2pdf.js:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/eKoopmans/html2pdf.js/security/advisories/GHSA-w8x4-x68c-m6fc","tags":["patch","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/eKoopmans/html2pdf.js/issues/865","tags":["issue-tracking","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/eKoopmans/html2pdf.js/pull/877","tags":["issue-tracking","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/eKoopmans/html2pdf.js/commit/988826e336035b39a8608182d7b73c0e3cd78c7b","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/eKoopmans/html2pdf.js/releases/tag/v0.14.0","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://aydinnyunus.github.io/2026/01/17/cve-2026-22787-html2pdf-xss-vulnerability/","tags":["exploit","mitigation","third-party-advisory"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-22787","tags":["advisory"],"sources":["ghsa"]},{"url":"https://aydinnyunus.github.io/2026/01/17/cve-2026-22787-html2pdf-xss-vulnerability","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/eKoopmans/html2pdf.js","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-01-14T21:02:44.599Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-22787","url":"https://www.cve.org/CVERecord?id=CVE-2026-22787","licence":"CVE Terms of Use","modified":"2026-01-20T18:37:09.279Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-w8x4-x68c-m6fc","url":"https://github.com/advisories/GHSA-w8x4-x68c-m6fc","licence":"CC-BY-4.0","modified":"2026-02-03T03:11:31.431Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-22787","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-22787","licence":"Public domain","modified":"2026-06-17T10:20:25.633Z"}],"updatedAt":"2026-11-25T22:59:12.832Z","epss":{"score":0.0039,"percentile":0.35298,"date":"2026-12-01T12:00:22.000Z"}}