Every CVE Search/ Get API key

CVE-2026-31938

jsPDF has HTML Injection in New Window paths

9.6 CriticalFix available

jsPDF is a library to generate PDFs in JavaScript. Prior to version 4.2.1, 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 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. The vulnerability has been fixed in [email protected]. As a workaround, sanitize user input before passing it to the output method.

Attack profile

How easy it is to exploit

Attack vector
Network
Complexity
Low
Privileges needed
None
User interaction
Required

What an attacker can affect

Confidentiality
High
Integrity
High
Availability
Low

Exploit likelihood

0.28%Up 0.2 points since Mar 18, 2026
90%50%10%1%

What each source reports

CVE List Score used 9.6

jsPDF has HTML Injection in New Window paths

jsPDF is a library to generate PDFs in JavaScript. Prior to version 4.2.1, 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 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. The vulnerability has been fixed in [email protected]. As a workaround, sanitize user input before passing it to the output method.

Record
CVE-2026-31938
CVSS 3.1
9.6 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:L
CVSS 3.1
8.1 HighCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N
Weakness
CWE-79, CWE-79
Updated
2026-11-02
EUVDEUVD-2026-12755 9.6

jsPDF is a library to generate PDFs in JavaScript. Prior to version 4.2.1, 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 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. The vulnerability has been fixed in [email protected]. As a workaround, sanitize user input before passing it to the output method.

Record
EUVD-2026-12755
CVSS 3.1
9.6 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:L
Updated
2026-11-02
GitHub AdvisoriesGHSA-wfv2-pwc8-crg5 9.6

jsPDF has HTML Injection in New Window paths

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": the pdfObjectUrl option and the entire options object, which is JSON-serialized and included verbatim in the generated HTML-string.
  • "pdfjsnewwindow": the pdfJsUrl and filename options
  • "dataurlnewwindow": the filename option

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

Workarounds

Sanitize user input before passing it to the output method.

Record
GHSA-wfv2-pwc8-crg5
CVSS 3.1
9.6 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:L
Weakness
CWE-79
Updated
2026-11-02
NVD 9.6

jsPDF is a library to generate PDFs in JavaScript. Prior to version 4.2.1, 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 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. The vulnerability has been fixed in [email protected]. As a workaround, sanitize user input before passing it to the output method.

Record
CVE-2026-31938
CVSS 3.1
9.6 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:L
CVSS 3.1
6.1 MediumCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
CVSS 3.1
8.1 HighCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N
Weakness
CWE-79
Updated
2026-11-02
OSV 9.6

jsPDF has HTML Injection in New Window paths

jsPDF is a library to generate PDFs in JavaScript. Prior to version 4.2.1, 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 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. The vulnerability has been fixed in [email protected]. As a workaround, sanitize user input before passing it to the output method.

Record
CVE-2026-31938
CVSS 3.1
9.6 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:L
Weakness
CWE-79
Updated
2026-11-02
OSVGHSA-wfv2-pwc8-crg5 9.6

jsPDF has HTML Injection in New Window paths

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": the pdfObjectUrl option and the entire options object, which is JSON-serialized and included verbatim in the generated HTML-string.
  • "pdfjsnewwindow": the pdfJsUrl and filename options
  • "dataurlnewwindow": the filename option

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

Workarounds

Sanitize user input before passing it to the output method.

Record
GHSA-wfv2-pwc8-crg5
CVSS 3.1
9.6 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:L
Weakness
CWE-79
Updated
2026-11-02
Show 5 moreShow less
OSVCLSA-2026-1773620214 No score

TuxCare security update for jspdf (2 CVEs)

TuxCare rebuilt jspdf to address 2 CVEs. Fixed in 2.5.2-tuxcare.8.

Record
CLSA-2026-1773620214
Updated
2026-11-02
OSVCLSA-2026-1775176117 No score

TuxCare security update for jspdf (2 CVEs)

TuxCare rebuilt jspdf to address 2 CVEs. Fixed in 3.0.4-tuxcare.7.

Record
CLSA-2026-1775176117
Updated
2026-11-02
OSVCLSA-2026-1780534264 No score

TuxCare security update for jspdf (12 CVEs)

TuxCare rebuilt jspdf to address 12 CVEs. Fixed in 2.5.1-tuxcare.1.

Record
CLSA-2026-1780534264
Updated
2026-11-02
OSVCLSA-2026-1780966320 No score

TuxCare security update for jspdf (9 CVEs)

TuxCare rebuilt jspdf to address 9 CVEs. Fixed in 1.4.1-tuxcare.2.

Record
CLSA-2026-1780966320
Updated
2026-11-02
OSVROOT-APP-NPM-CVE-2026-31938 No score

CVE-2026-31938 in jspdf - Patched by Root

Root has patched CVE-2026-31938 in the jspdf package for Root:npm. Multiple fixed versions available.

Record
ROOT-APP-NPM-CVE-2026-31938
Updated
2026-11-02

Affected products

Affected packages

Affected packages
PackageAffectedFixed
jspdf
npm
through 4.2.0
4.2.1
jspdf
TuxCare:npm
From an advisory covering 2 CVEs
2.5.2-tuxcare.0 up to 2.5.2-tuxcare.8, plus listed versions
2.5.22.5.2-tuxcare.12.5.2-tuxcare.22.5.2-tuxcare.32.5.2-tuxcare.42.5.2-tuxcare.52.5.2-tuxcare.62.5.2-tuxcare.7
2.5.2-tuxcare.8
jspdf
TuxCare:npm
From an advisory covering 2 CVEs
3.0.4-tuxcare.0 up to 3.0.4-tuxcare.7, plus listed versions
3.0.43.0.4-tuxcare.13.0.4-tuxcare.23.0.4-tuxcare.33.0.4-tuxcare.43.0.4-tuxcare.53.0.4-tuxcare.6
3.0.4-tuxcare.7
jspdf
TuxCare:npm
From an advisory covering 12 CVEs
2.5.1-tuxcare.0 up to 2.5.1-tuxcare.1, plus listed versions
2.5.1
2.5.1-tuxcare.1
jspdf
TuxCare:npm
From an advisory covering 9 CVEs
1.4.1-tuxcare.0 up to 1.4.1-tuxcare.2, plus listed versions
1.4.11.4.1-tuxcare.1
1.4.1-tuxcare.2
jspdf
npm
before 4.2.1
4.2.1
jspdf
Root:npm
before 2.5.2-aikido.1
2.5.2-aikido.14.0.0-aikido.1
@rootio/jspdf
Root:npm
before 2.5.2-root.io.1
2.5.2-root.io.14.0.0-root.io.1

History

History
RecordedChangedSources
affected, facts
first indexedCVE List, EUVD, GitHub Advisories, NVD, OSV

Dates are when Every CVE recorded each change. Upstream dates may differ.

In short

CVE-2026-31938 is a critical vulnerability (CVSS 9.6) in Parall Jspdf, published March 17, 2026. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.28%, the 20th percentile. Fixed in jspdf 4.2.1.

References

Show 6 moreShow less
MoveEnter Open