CVE-2020-7691: Cross-site scripting in jspdf
Summary
CVE-2020-7691: Cross-site scripting in jspdf. Affects jspdf versions < 2.0.0. Fixed in 2.0.0. How to fix ↓
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.
No signup required · Results in about 60 seconds
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 →
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.
For more information about this vulnerability, you can refer to the GitHub advisory database entry at: https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2021/05/GHSA-3q6f-8grx-pr4v/GHSA-3q6f-8grx-pr4v.json
References
Related vulnerabilities
Recent vulnerabilities recorded for jspdf.