The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2026-31898

CVE-2026-31898: jsPDF Library XSS Vulnerability

CVE-2026-31898 is an XSS flaw in jsPDF library that allows injection of arbitrary PDF objects like JavaScript actions via the createAnnotation method. This article covers technical details, affected versions, and mitigations.

Published: March 20, 2026

CVE-2026-31898 Overview

CVE-2026-31898 is a PDF Object Injection vulnerability in jsPDF, a popular JavaScript library used to generate PDF documents in client-side and server-side JavaScript applications. Prior to version 4.2.1, the createAnnotation method is vulnerable to arbitrary PDF object injection through unsanitized user input in the color parameter. This allows attackers to inject malicious JavaScript actions into generated PDF documents that execute when the PDF is opened or when users interact with annotated elements.

Critical Impact

Attackers can inject arbitrary PDF JavaScript actions through the vulnerable createAnnotation method, potentially executing malicious code when victims open compromised PDF documents. This can lead to data theft, phishing attacks, or further exploitation of the user's system.

Affected Products

  • jsPDF versions prior to 4.2.1
  • Applications using the createAnnotation API with unsanitized user input
  • Web applications generating PDFs with user-controlled annotation parameters

Discovery Timeline

  • 2026-03-18 - CVE CVE-2026-31898 published to NVD
  • 2026-03-18 - Last updated in NVD database

Technical Details for CVE-2026-31898

Vulnerability Analysis

This vulnerability is classified under CWE-116 (Improper Encoding or Escaping of Output), which occurs when the application fails to properly sanitize user-controlled input before including it in PDF output structures. The createAnnotation method in jsPDF constructs PDF annotation objects by directly incorporating user-supplied values, specifically the color parameter, without adequate validation or encoding.

When generating FreeText annotations, the vulnerable code path allows specially crafted input in the color parameter to break out of the intended context and inject arbitrary PDF objects. PDF format supports embedded JavaScript through action objects, and attackers can leverage this injection point to include malicious /JS (JavaScript) actions that execute automatically when the PDF is opened or when users interact with the annotation.

The attack is network-exploitable and requires user interaction—specifically, the victim must open the malicious PDF document. Once opened, the injected JavaScript executes within the PDF reader's JavaScript context, which could lead to information disclosure or serve as a vector for social engineering attacks.

Root Cause

The root cause lies in improper output encoding when constructing PDF annotation objects in the src/modules/annotations.js file. The color parameter from user input is concatenated directly into PDF object strings without proper escaping or validation, allowing attackers to inject additional PDF syntax and objects beyond the intended color value.

Attack Vector

An attacker can exploit this vulnerability by providing a maliciously crafted color value to the createAnnotation method. The injected payload can include PDF object syntax that terminates the color attribute and introduces arbitrary PDF structures, such as JavaScript action objects (/S /JavaScript /JS). When the generated PDF is opened by a victim, any injected JavaScript will execute within the PDF reader's scripting environment.

The attack is delivered through the network (AV:N) and requires no special privileges (PR:N), but does require user interaction (UI:R) as the victim must open the malicious PDF. Successful exploitation can result in high confidentiality (C:H) and integrity (I:H) impacts.

javascript
               getVerticalCoordinateString(anno.bounds.y + anno.bounds.h) +
               "] ";
             var color = anno.color || "#000000";
+            var defaultStyle =
+              "font: Helvetica,sans-serif 12.0pt; text-align:left; color:#" +
+              color;
             line =
               "<</Type /Annot /Subtype /" +
               "FreeText" +

Source: jsPDF Commit History

Detection Methods for CVE-2026-31898

Indicators of Compromise

  • PDF documents containing unexpected JavaScript actions within annotation objects
  • Anomalous PDF structure with JavaScript (/JS) or action (/S /JavaScript) objects embedded in annotations
  • Generated PDFs with malformed or suspicious color values containing PDF syntax characters

Detection Strategies

  • Scan application dependencies for jsPDF versions prior to 4.2.1 using software composition analysis (SCA) tools
  • Monitor PDF generation logs for annotation requests with unusual color parameter values containing special characters like >>, /, or <<
  • Implement output inspection for generated PDFs to detect embedded JavaScript actions
  • Review application code for calls to createAnnotation that pass user-controlled data without sanitization

Monitoring Recommendations

  • Implement application-level logging for all createAnnotation API calls with parameter values
  • Configure web application firewalls to detect PDF injection patterns in request parameters
  • Enable PDF content scanning on email gateways and file storage systems to detect malicious JavaScript in PDF documents

How to Mitigate CVE-2026-31898

Immediate Actions Required

  • Upgrade jsPDF to version 4.2.1 or later immediately
  • Audit application code for any usage of the createAnnotation method with user-controlled input
  • Implement input validation and sanitization for all data passed to jsPDF annotation methods
  • Review and quarantine any PDFs generated with potentially malicious input while using vulnerable versions

Patch Information

The vulnerability has been fixed in jsPDF version 4.2.1. The security patch properly handles the color parameter to prevent PDF object injection. Organizations should update their jsPDF dependency to the patched version. For more details, refer to the GitHub Security Advisory GHSA-7x6v-j9x4-qf24 and the jsPDF Release v4.2.1.

Workarounds

  • Sanitize all user input before passing to the createAnnotation method by removing or encoding special PDF syntax characters
  • Implement allowlist validation for color values, accepting only valid hexadecimal color codes (e.g., /^#[0-9A-Fa-f]{6}$/)
  • Disable or restrict the createAnnotation functionality if not required by the application until patching is possible
bash
# Configuration example
# Update jsPDF to patched version using npm
npm update jspdf@4.2.1

# Or install specifically
npm install jspdf@4.2.1 --save

# Verify installed version
npm list jspdf

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeXSS

  • Vendor/TechJspdf

  • SeverityHIGH

  • CVSS Score8.1

  • EPSS Probability0.03%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityHigh
  • AvailabilityNone
  • CWE References
  • CWE-116
  • Technical References
  • jsPDF Code Annotation Example

  • jsPDF Commit History

  • jsPDF Release v4.2.1

  • GitHub Security Advisory GHSA-7x6v-j9x4-qf24
  • Related CVEs
  • CVE-2026-31938: Parall Jspdf XSS Vulnerability

  • CVE-2026-25940: jsPDF Acroform XSS Vulnerability

  • CVE-2026-24737: jsPDF Library XSS Vulnerability

  • CVE-2026-25535: jsPDF Library DoS Vulnerability
Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English