CVE-2026-22787

html2pdf.js has a cross-site scripting vulnerability

Published Jan 14, 2026 CVSS 4.0 · 8.7 High EPSS < 1% KEV · Not listed
Description
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.

Analysis

AI-generated

Technical impact

html2pdf.js is a client‑side library that converts web content into PDF documents. Versions prior to 0.14.0 embed supplied text directly into the DOM without proper sanitization. This flaw allows an attacker to inject malicious scripts that execute in the user’s browser, potentially exposing or altering sensitive data and disrupting page functionality.

Affected Systems

The vulnerability affects the eKoopmans html2pdf.js library on any Node.js environment that uses the library before version 0.14.0. Users who incorporate the old code into web pages or web applications are at risk.

Risk and Exploitability

The flaw scores 8.7 on the CVSS scale, indicating high severity, and the EPSS probability is low (<1%). It is not listed in the CISA KEV catalog. Exploitation requires delivery of malicious text to the application, which is then processed by html2pdf.js when a user initiates a PDF conversion. Because the attack occurs entirely on the client side, it can occur without additional network interaction once the code is loaded into the browser.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade the html2pdf.js library to version 0.14.0 or later, which removes the XSS vector
  • If an upgrade is not immediately feasible, never pass untrusted text sources to the library; validate or sanitize all input before calling html2pdf.js
  • Implement a Content Security Policy that disallows inline script execution to mitigate any residual injection risk

Generated by OpenCVE AI on April 18, 2026 at 06:20 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Github GHSA Github GHSA GHSA-w8x4-x68c-m6fc html2pdf.js contains a cross-site scripting vulnerability
History
Type Values Removed Values Added
CPEs cpe:2.3:a:ekoopmans:html2pdf.js:*:*:*:*:*:node.js:*:*
Metrics cvssV3_1

{'score': 6.1, 'vector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N'}

Type Values Removed Values Added
First Time appeared Ekoopmans
Ekoopmans html2pdf.js
Vendors & Products Ekoopmans
Ekoopmans html2pdf.js
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'poc', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
Description 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.
Title html2pdf.js has a cross-site scripting vulnerability
Weaknesses CWE-79
References
Metrics cvssV4_0

{'score': 8.7, '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'}

Weaknesses
  • CWE-79

    Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Jan 20, 2026, 6:37 PM
Reserved
Jan 9, 2026, 6:27 PM
Status
Analyzed
Published
Jan 14, 2026, 5:16 PM
Modified
Jun 17, 2026, 10:20 AM