CVE-2026-22787: Html2pdf.js Cross-Site Scripting Vulnerability
HIGHCVE-2026-22787 is a HIGH cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Html2pdf.js libraries in the npm ecosystem. The issue involves html2pdf.js contains a cross-site scripting vulnerability. Remediation is available by upgrading affected packages to version 0.14.0.
CVE-2026-22787 at a Glance
How to Fix CVE-2026-22787
To remediate this vulnerability, upgrade all affected Html2pdf.js dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install html2pdf.js@0.14.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls html2pdf.js
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2026-22787, inspect your project dependencies using npm:
npm ls html2pdf.js
Analyze the terminal output to locate any version of Html2pdf.js in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.14.0), your application is affected.
Note: The npm ls html2pdf.js command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Html2pdf.js, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-22787 Affected Html2pdf.js Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
html2pdf.js
|
npm |
< 0.14.0
|
0.14.0
|
References
Frequently Asked Questions
What is CVE-2026-22787?
Which Html2pdf.js versions are affected?
What version fixes CVE-2026-22787?
Is html2pdf.js affected?
What CWE is associated with CVE-2026-22787?
How can I check npm dependencies for CVE-2026-22787?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-w8x4-x68c-m6fc",
"modified" : "2026-01-21T16:37:34Z",
"published" : "2026-01-14T16:53:10Z",
"aliases" : [ "CVE-2026-22787" ],
"summary" : "html2pdf.js contains 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",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "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"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "html2pdf.js"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.14.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"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" : "WEB",
"url" : "https://github.com/eKoopmans/html2pdf.js/issues/865"
}, {
"type" : "WEB",
"url" : "https://github.com/eKoopmans/html2pdf.js/pull/877"
}, {
"type" : "WEB",
"url" : "https://github.com/eKoopmans/html2pdf.js/commit/988826e336035b39a8608182d7b73c0e3cd78c7b"
}, {
"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"
}, {
"type" : "WEB",
"url" : "https://github.com/eKoopmans/html2pdf.js/releases/tag/v0.14.0"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-01-14T16:53:10Z",
"nvd_published_at" : "2026-01-14T17:16:09Z"
}
}