CVE-2026-22787: html2pdf.js contains a cross-site scripting vulnerability
(updated )
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.
Example attack vector:
import html2pdf from 'html2pdf.js/src/index.js';
const maliciousHTML = '<img src=x onerror="alert(document.cookie)">';
html2pdf(maliciousHTML);
// or html2pdf().from(maliciousHTML);
References
- aydinnyunus.github.io/2026/01/17/cve-2026-22787-html2pdf-xss-vulnerability
- github.com/advisories/GHSA-w8x4-x68c-m6fc
- github.com/eKoopmans/html2pdf.js
- github.com/eKoopmans/html2pdf.js/commit/988826e336035b39a8608182d7b73c0e3cd78c7b
- github.com/eKoopmans/html2pdf.js/issues/865
- github.com/eKoopmans/html2pdf.js/pull/877
- github.com/eKoopmans/html2pdf.js/releases/tag/v0.14.0
- github.com/eKoopmans/html2pdf.js/security/advisories/GHSA-w8x4-x68c-m6fc
- nvd.nist.gov/vuln/detail/CVE-2026-22787
Code Behaviors & Features
Detect and mitigate CVE-2026-22787 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →