CVE-2026-31938 — jsPDF has HTML Injection in jspdf — CVE Details
jsPDF has HTML Injection in New Window paths
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (0.48%). Schedule for your next planned update.
Does your project use an affected jspdf version?
Paste your package-lock.json to check it for CVE-2026-31938 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Impact
User control of the options argument of the output function allows attackers to inject arbitrary HTML (such as scripts) into the browser context the created PDF is opened in. The affected overloads and options are:
"pdfobjectnewwindow": thepdfObjectUrloption and the entire options object, which is JSON-serialized and included verbatim in the generated HTML-string."pdfjsnewwindow": thepdfJsUrlandfilenameoptions"dataurlnewwindow": thefilenameoption
The vulnerability can be exploited in the following scenario: the attacker provides values for the output options, for example via a web interface. These values are then passed unsanitized (automatically or semi-automatically) to the attack victim. The victim creates and opens a PDF with the attack vector using one of the vulnerable method overloads inside their browser. The attacker can thus inject scripts that run in the victims browser context and can extract or modify secrets from this context.
Example attack vector:
import { jsPDF } from 'jspdf';
const doc = new jsPDF();
const payload = 'x\"></iframe><script>window.__n=1</script><iframe src="';
doc.output('pdfjsnewwindow', {
filename: payload,
pdfJsUrl: 'viewer.html'
});
Patches
The vulnerability has been fixed in jspdf@4.2.1.
Workarounds
Sanitize user input before passing it to the output method.
Advisory Timeline
- First published March 17, 2026 (254 days ago).
- Last revised September 10, 2026 — 176 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
npm install jspdf@4.2.1
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: npm (1).
| Package | Fixed In |
|---|---|
| jspdf npm · Affected: All versions | 4.2.1 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-79Cross-site Scripting (XSS)MITRE
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 9.6 score means for each attack dimension.
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:L
References
- https://github.com/parallax/jsPDF/security/advisories/GHSA-wfv2-pwc8-crg5WEB
- https://nvd.nist.gov/vuln/detail/CVE-2026-31938ADVISORY
- https://github.com/parallax/jsPDF/commit/87a40bbd07e6b30575196370670b41f264aa78d7WEB
- https://github.com/parallax/jsPDFPACKAGE
- https://github.com/parallax/jsPDF/releases/tag/v4.2.1WEB
Frequently Asked Questions
- What is CVE-2026-31938?
- jsPDF has HTML Injection in New Window paths. This vulnerability has been assigned a severity rating of CRITICAL (CVSS score: 9.6/10).
- How do I check if my project is affected by CVE-2026-31938?
- CVE-2026-31938 affects jspdf. It has a 0.5% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-31938 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Maximum impact if exploited, often with little effort or access required.
This is a below-median EPSS score — only 34% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.
Also Known As
Related CVEs
- CVE-2026-76807CRITICAL
Todoist MCP Server: Browser DNS rebinding lets websites write and delete Todoist data through local MCP server
- CVE-2026-114516CRITICAL
Etherpad: Pre-auth arbitrary file read