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

High 8.7 Published Updated

An XSS vulnerability in html2pdf.js allows attackers to execute malicious scripts via unsanitized text input, compromising client-side data integrity and confidentiality.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
A user has to click or open something
Fix
Available

What is CVE-2026-22787?

CVE-2026-22787 is a high-severity cross-site scripting vulnerability in eKoopmans html2pdf.js, published on 14 Jan 2026. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

Official 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 [email protected].

Weakness: CWE-79

Which versions are affected by CVE-2026-22787?

2 open source packages ship an affected version, including html2pdf.js. It affects 1 product.

PackageAffectedFixed in
html2pdf.js npmAll versions0.14.0
html2pdf.js npmAll versions0.14.0

Products include Ekoopmans Html2pdf.js.

How do I fix CVE-2026-22787?

Upgrade html2pdf.js to 0.14.0 or later.

Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.

Is CVE-2026-22787 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-22787 exists.

Sources

Also known as GHSA-w8x4-x68c-m6fc.

Is CVE-2026-22787 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free