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

jspdf Updated 02 Oct 2025

Summary

11/05/2021
Yes i
Moderate
6.1

CVE-2020-7691: 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 Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

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, the package is vulnerable to a cross-site scripting (XSS) attack.

Vulnerability Detail

The vulnerability in jspdf allows an attacker to use nested script tags to bypass the filtering regex. This can lead to the execution of arbitrary JavaScript code in the context of a victim's browser, potentially compromising their sensitive information or performing malicious actions on their behalf. The 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 updating to the latest version is not immediately feasible, a temporary workaround is to manually sanitize user input before using it with jspdf. This can be done by using a trusted library or implementing custom sanitization functions to remove or escape any potentially malicious script tags or other HTML elements.

Conclusion

In conclusion, the jspdf package is vulnerable to a cross-site scripting (XSS) attack. It is crucial to update to the latest version of the package or apply proper input sanitization to mitigate the risk. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for jspdf →

Share this vulnerability

FAQ

The vulnerability allows an attacker to execute arbitrary JavaScript code in the victim's browser, potentially leading to the theft of sensitive information or unauthorized actions on behalf of the victim.

At the time of this advisory, there are no known public exploits specifically targeting this vulnerability. However, it is important to promptly apply the recommended fix to mitigate any potential risks.

Yes, this vulnerability can be exploited remotely. An attacker can craft a malicious PDF file or inject malicious code into a website that uses jspdf, and then trick a victim into opening the file or visiting the compromised website.

The primary mitigation is to update the jspdf package to the latest version, which includes a fix for the vulnerability. Additionally, implementing proper input sanitization and validation practices can help reduce the risk of XSS attacks.

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