CVE-2024-34342 react-pdf's PDF.js vulnerable to arbitrary JavaScript execution upon opening a malicious PDF

High 7.1 Published Updated

Attackers can execute arbitrary JavaScript in the hosting domain by tricking users into opening malicious PDFs with react-pdf.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
A user has to click or open something
Fix
Available

What is CVE-2024-34342?

CVE-2024-34342 is a high-severity cross-site scripting vulnerability in wojtekmaj react-pdf, published on 7 May 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

Official description

react-pdf displays PDFs in React apps. 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. This vulnerability is fixed in 7.7.3 and 8.0.2.

Weakness: CWE-79

Which versions are affected by CVE-2024-34342?

4 open source packages ship an affected version, including react-pdf.

PackageAffectedFixed in
react-pdf npmAll versions7.7.3
react-pdf npmAll versions7.7.3
react-pdf npmFrom 8.0.08.0.2
react-pdf npmFrom 8.0.08.0.2

How do I fix CVE-2024-34342?

Upgrade react-pdf to a fixed version for your release line: 7.7.3 or 8.0.2.

Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.

Is CVE-2024-34342 being exploited?

There is no known exploitation of CVE-2024-34342 in the wild and no public exploit code.

Sources

Also known as CLSA-2026-1775781167, GHSA-87hq-q4gp-9wr4, ROOT-APP-NPM-CVE-2024-34342.

Is CVE-2024-34342 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free