Skip to main content

CVE-2026-31898

MEDIUM
Improper Encoding or Escaping of Output (CWE-116)
2026-03-17 https://github.com/parallax/jsPDF GHSA-7x6v-j9x4-qf24
6.5
CVSS 3.1 · NVD
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Pass unsanitized input to createAnnotation
  2. Exploit
    Inject malicious PDF objects via color parameter
  3. Impact
    Execute arbitrary JavaScript when PDF opened

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Output encoding for downstream
Exploitation Conditions

Application must use jsPDF library and pass user-controlled input directly to createAnnotation method's color parameter without sanitization. Victim must open the generated PDF document.

Impact

Despite the high CVSS score of 8.1 indicating significant theoretical impact, the real-world risk requires careful consideration. The CVSS vector shows this is a network-accessible vulnerability (AV:N) with low complexity (AC:L) requiring no privileges (PR:N) but does require user interaction (UI:R) to trigger. The lack of KEV listing suggests no confirmed in-the-wild exploitation yet. The publicly available proof-of-concept increases exploitation likelihood, though successful attacks require an application to pass unsanitized user input to the vulnerable method and a victim to open the resulting PDF. The attack's dependency on user interaction and the specific coding pattern reduces the likelihood of widespread automated exploitation, making this a medium-priority issue for most organizations despite the high CVSS score.

Exploit ScenarioDerived

An attacker could exploit this vulnerability by submitting malicious input through a web form that generates PDF reports, injecting a payload like '000000) /AA <</E <</S /Launch /F (calc.exe)>>>> (' into a color field. When an employee or customer opens the generated PDF, the injected JavaScript action executes, potentially launching system commands or exfiltrating data. The publicly available proof-of-concept demonstrates this exact attack pattern, making exploitation straightforward for attackers with basic knowledge of PDF internals.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Mar 17, 2026

A code injection vulnerability in the jsPDF library allows attackers to inject arbitrary PDF objects, including malicious JavaScript actions, through unsanitized user input to the createAnnotation method. The vulnerability affects jsPDF versions prior to 4.2.1 and enables remote attackers to execute arbitrary code when a victim opens or interacts with a maliciously crafted PDF file. A proof-of-concept exploit is publicly available demonstrating how to launch system executables like calc.exe through PDF action injection.

RemediationAI

Upgrade jsPDF to version 4.2.1 or later immediately, as confirmed in the vendor's security advisory at https://github.com/parallax/jsPDF/security/advisories/GHSA-7x6v-j9x4-qf24 and release notes at https://github.com/parallax/jsPDF/releases/tag/v4.2.1. If immediate patching is not possible, implement strict input validation and sanitization for any user-supplied data passed to the createAnnotation method, particularly the color parameter, ensuring no PDF object syntax can be injected. Review all code paths that generate PDFs with user input and implement defense-in-depth measures such as content security policies for generated PDFs.

Affected Packages

npm jspdf fix: 4.2.1

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in npm

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

jsPDF is a popular JavaScript library for generating PDF documents in web browsers and Node.js environments, identified by CPE pkg:npm/jspdf. The vulnerability stems from improper output neutralization (CWE-116) in the createAnnotation method, specifically in how the 'color' parameter is processed without adequate sanitization. When creating PDF annotations, the library fails to properly escape or validate user-supplied input, allowing injection of raw PDF object syntax that can include action dictionaries with launch commands or JavaScript code that execute when the PDF is rendered or interacted with.

Know when the next one hits your stack

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

NVD PRIMARY 6.5 MEDIUM
AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N
Red Hat 8.1 HIGH

Primary rating from NVD.

CVSS VectorNVD

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
Required
Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
None

Lifecycle Timeline

4
Severity Changed
Jun 30, 2026 - 03:24 NVD
HIGH MEDIUM
CVSS changed
Jun 30, 2026 - 03:24 NVD
8.1 (HIGH) 6.5 (MEDIUM)
Patch released
Mar 17, 2026 - 20:30 nvd
Patch available
CVE Published
Mar 17, 2026 - 17:07 nvd
HIGH 8.1

DescriptionNVD

Impact

User control of arguments of the createAnnotation method allows users to inject arbitrary PDF objects, such as JavaScript actions.

If given the possibility to pass unsanitized input to the following method, a user can inject arbitrary PDF objects, such as JavaScript actions, which might trigger when the PDF is opened or interacted with..

  • createAnnotation: color parameter

Example attack vector:

js
import { jsPDF } from 'jspdf'

const doc = new jsPDF();

const payload = '000000) /AA <</E <</S /Launch /F (calc.exe)>>>> (';

doc.createAnnotation({
  type: 'freetext',
  bounds: { x: 10, y: 10, w: 120, h: 20 },
  contents: 'hello',
  color: payload
});

doc.save('test.pdf');

Patches

The vulnerability has been fixed in jsPDF@4.2.1.

Workarounds

Sanitize user input before passing it to the vulnerable API members.

Blast Radius

ecosystem impact
† from your stack dependencies † transitive graph · vuln.today resolves 4-path depth
  • 810 npm packages depend on jspdf (518 direct, 297 indirect)

Ecosystem-wide dependent count for version 4.2.1.

Executive ViewAI

Why It Matters

A critical vulnerability in the jsPDF library (CVE-2026-31898) enables attackers to execute arbitrary code on systems that open maliciously crafted PDF files, posing a direct threat to any organization using this library in web applications or document processing workflows. With a publicly available exploit and CVSS score of 8.1, this vulnerability requires immediate patching to prevent potential data theft, system compromise, or lateral movement within the organization.

Business Impact: High
Compensating Controls

Apply vendor patch. If immediate patching is not feasible, implement compensating controls: (1) disable PDF annotation functionality if not business-critical, (2) apply input validation and sanitization to block special characters and script payloads before they reach the createAnnotation method, (3) deploy WAF rules to detect and block suspicious PDF generation requests, (4) restrict PDF file execution in endpoints through application whitelisting, and (5) segment systems that process untrusted PDFs from critical infrastructure.

Threat Intelligence Overview

EPSS Score
0.0%
Top 92% exploitable
Data Quality
6 sources
Confidence: High
NVD CVE.org EPSS Vendor GitHub VulDB

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.0%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
No
Human Impact
High

Priority Score

32
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +32
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Code Injection CRITICAL

Code injection occurs when an application accepts user input and passes it directly into a language interpreter or evaluator without proper sanitization.

Affected Products (CPE)NVD

pkg:npm/jspdf

Related Vulnerabilities in PDF Generation HTML Injection

View all 2

Vendor StatusVendor

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy