CVE-2024-34342 is a high-severity (CVSS 7.1) Cross-site Scripting (XSS) vulnerability in react-pdf. A fix is available for react-pdf — see the affected versions and patch details below.
react-pdf's PDF.js vulnerable to arbitrary JavaScript execution upon opening a malicious PDF
Exploitation Status
No confirmed exploitation observed yet
- A successful exploit gives an attacker total control of the affected component, not partial access.
- CISA’s own triage has not observed active exploitation or public proof-of-concept code for this CVE as of its last assessment.
Exploitation and automatability from CISA’s SSVC triage for CVE-2024-34342.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
Where this sits among everything scored
Real-World Exposure
How broadly this vulnerability is actually deployed: weekly install volume shows current usage, and reverse-dependency count shows how many other packages break if it stays unpatched.
react-pdfnpmDescription
Summary
If PDF.js is used to load a malicious PDF, and PDF.js is configured with isEvalSupported set to true (which is the default value), unrestricted attacker-controlled JavaScript will be executed in the context of the hosting domain.
Patches
This patch forces isEvalSupported to false, removing the attack vector.
Workarounds
Set options.isEvalSupported to false, where options is Document component prop.
References
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | react-pdf | all versions | 7.7.3npm install react-pdf@7.7.3 |
| 📦npm | react-pdf | ≥ 8.0.0&&< 8.0.2 | 8.0.2npm install react-pdf@8.0.2 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for react-pdf, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update react-pdf to 7.7.3 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2024-34342 is resolved across your whole dependency graph.
Workarounds
Escape or sanitise the affected output on the server side rather than relying on client-side filtering, and add a Content-Security-Policy that blocks inline script execution so injected markup cannot run even if it reaches the page.
Frequently Asked Questions
Is CVE-2024-34342 in your dependencies?
Find it across npm, including transitive dependencies.