Advisory Database
  • Advisories
  • Dependency Scanning
  1. npm
  2. ›
  3. html2pdf.js
  4. ›
  5. CVE-2026-22787

CVE-2026-22787: html2pdf.js contains a cross-site scripting vulnerability

January 14, 2026 (updated January 21, 2026)

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 →

Affected versions

All versions before 0.14.0

Fixed versions

  • 0.14.0

Solution

Upgrade to version 0.14.0 or above.

Impact 8.3 HIGH

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:L

Learn more about CVSS

Weakness

  • CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

Source file

npm/html2pdf.js/CVE-2026-22787.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 04 Feb 2026 00:36:18 +0000.