{"id":"CVE-2026-22787","aliases":["GHSA-w8x4-x68c-m6fc"],"url":"https://o3.security/vulnerability/CVE-2026-22787","summary":"html2pdf.js has a cross-site scripting vulnerability","details":"### 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","published":"2026-01-14T16:52:38.372Z","modified":"2026-08-12T03:51:44.928064763Z","cvss":null,"epss":null,"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"npm","name":"html2pdf.js","fixedVersion":"0.14.0"}],"fix":{"url":"https://github.com/eKoopmans/html2pdf.js/commit/988826e336035b39a8608182d7b73c0e3cd78c7b","label":"eKoopmans/html2pdf.js@988826e"},"references":[{"type":"WEB","url":"https://aydinnyunus.github.io/2026/01/17/cve-2026-22787-html2pdf-xss-vulnerability/"},{"type":"WEB","url":"https://github.com/eKoopmans/html2pdf.js/releases/tag/v0.14.0"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/22xxx/CVE-2026-22787.json"},{"type":"ADVISORY","url":"https://github.com/eKoopmans/html2pdf.js/security/advisories/GHSA-w8x4-x68c-m6fc"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-22787"},{"type":"REPORT","url":"https://github.com/eKoopmans/html2pdf.js/issues/865"},{"type":"FIX","url":"https://github.com/eKoopmans/html2pdf.js/commit/988826e336035b39a8608182d7b73c0e3cd78c7b"},{"type":"FIX","url":"https://github.com/eKoopmans/html2pdf.js/pull/877"},{"type":"WEB","url":"https://aydinnyunus.github.io/2026/01/17/cve-2026-22787-html2pdf-xss-vulnerability"},{"type":"PACKAGE","url":"https://github.com/eKoopmans/html2pdf.js"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T03:51:44.928064763Z"}}