CVE-2020-7690: Cross-site scripting in jspdf

jspdf Updated 02 Oct 2025

Summary

17/05/2021
Yes i
Moderate
6.1

CVE-2020-7690: Cross-site scripting in jspdf. Affects jspdf versions < 2.0.0. Fixed in 2.0.0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

The jspdf package is an open-source library for generating PDF files in JavaScript. It provides a simple and convenient way to create PDF documents programmatically. However, a vulnerability has been discovered in jspdf that allows for cross-site scripting (XSS) attacks. This means that an attacker can inject malicious JavaScript code into the generated PDF, potentially leading to unauthorized access, data theft, or other malicious activities.

Vulnerability Detail

The vulnerability in jspdf arises from the html method, which is used to insert HTML content into the PDF document. Due to insufficient input sanitization, it is possible for an attacker to inject JavaScript code through this method. When the PDF is opened and rendered, the injected code will be executed within the context of the user's browser, allowing the attacker to manipulate the page, steal sensitive information, or perform other malicious actions. This vulnerability has a CVSS score of 6.1, indicating a moderate severity level.

How To Fix

Latest published version: 4.2.1 as of 23 Oct 2026

npm install jspdf@4.2.1

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

2.0.0

This is the first release that contains the fix.

npm install jspdf@2.0.0

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If upgrading to the latest version of jspdf is not immediately feasible, a temporary workaround is to manually sanitize any HTML content before passing it to the html method. This can be done using a library or function that properly escapes or removes any potentially malicious JavaScript code. Here is an example of how to sanitize HTML content using the DOMPurify library:

const DOMPurify = require('dompurify');

const sanitizedHtml = DOMPurify.sanitize(htmlContent);

// Pass the sanitized HTML to jspdf
pdf.html(sanitizedHtml);

Conclusion

In conclusion, the jspdf package is vulnerable to cross-site scripting (XSS) attacks due to insufficient input sanitization in the html method. To mitigate this vulnerability, it is crucial to upgrade to jspdf version 2.0.0 or later. Alternatively, you can manually sanitize HTML content before using it with jspdf. If you have any further questions or need assistance with vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for jspdf →

Share this vulnerability

FAQ

jspdf is an open-source JavaScript library for generating PDF files programmatically.

Cross-site scripting is a type of security vulnerability that allows attackers to inject malicious scripts into web pages viewed by other users.

The vulnerability in jspdf allows attackers to execute arbitrary JavaScript code within the context of a user's browser, potentially leading to unauthorized access, data theft, or other malicious activities.

To fix this vulnerability, it is recommended to upgrade to jspdf version 2.0.0 or later.

Yes, a temporary workaround is to manually sanitize any HTML content before passing it to the html method in jspdf.

Related vulnerabilities

Recent vulnerabilities recorded for jspdf.

How To Fix

Latest published version: 4.2.1 as of 23 Oct 2026

npm install jspdf@4.2.1

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

2.0.0

This is the first release that contains the fix.

npm install jspdf@2.0.0

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback