CVE-2024-34342: React pdf React-pdf Vulnerable To Arbitrary JavaScript Vulnerability
HIGHCVE-2024-34342 is a HIGH (CVSS 7.1) react-pdf vulnerable to arbitrary javascript vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting React pdf libraries in the npm ecosystem. The issue involves react-pdf vulnerable to arbitrary javascript execution upon opening a malicious pdf with pdf.js. Remediation is available by upgrading affected packages to version 7.7.3, 8.0.2.
CVE-2024-34342 at a Glance
Security Impact
CVSS: 7.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:L).
How to Fix CVE-2024-34342
To remediate this vulnerability, upgrade all affected React pdf dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install react-pdf@7.7.3
npm install react-pdf@8.0.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls react-pdf
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2024-34342, inspect your project dependencies using npm:
npm ls react-pdf
Analyze the terminal output to locate any version of React pdf in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 7.7.3), your application is affected.
Note: The npm ls react-pdf command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In React pdf, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-34342 Affected React pdf Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
react-pdf
|
npm |
< 7.7.3
|
7.7.3
|
|
react-pdf
|
npm |
≥ 8.0.0
< 8.0.2
|
8.0.2
|
References
Frequently Asked Questions
What is CVE-2024-34342?
Which React pdf versions are affected?
What version fixes CVE-2024-34342?
Is react-pdf affected?
What is the CVSS score of CVE-2024-34342?
What CWE is associated with CVE-2024-34342?
How can I check npm dependencies for CVE-2024-34342?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-87hq-q4gp-9wr4",
"modified" : "2024-05-29T22:12:45Z",
"published" : "2024-05-07T16:48:59Z",
"aliases" : [ "CVE-2024-34342" ],
"summary" : "react-pdf vulnerable to arbitrary JavaScript execution upon opening a malicious PDF with PDF.js",
"details" : "### Summary\n\nIf 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.\n\n### Patches\n[This patch](https://github.com/wojtekmaj/react-pdf/commit/671e6eaa2e373e404040c13cc6b668fe39839cad) forces `isEvalSupported` to `false`, removing the attack vector.\n\n### Workarounds\nSet `options.isEvalSupported` to `false`, where `options` is `Document` component prop.\n\n### References\n- [GHSA-wgrm-67xf-hhpq](https://github.com/mozilla/pdf.js/security/advisories/GHSA-wgrm-67xf-hhpq)\n- https://github.com/mozilla/pdf.js/pull/18015\n- https://github.com/mozilla/pdf.js/commit/85e64b5c16c9aaef738f421733c12911a441cec6\n- https://bugzilla.mozilla.org/show_bug.cgi?id=1893645",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:L"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "react-pdf"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "7.7.3"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "react-pdf"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "8.0.0"
}, {
"fixed" : "8.0.2"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/mozilla/pdf.js/security/advisories/GHSA-wgrm-67xf-hhpq"
}, {
"type" : "WEB",
"url" : "https://github.com/wojtekmaj/react-pdf/security/advisories/GHSA-87hq-q4gp-9wr4"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-34342"
}, {
"type" : "WEB",
"url" : "https://github.com/mozilla/pdf.js/pull/18015"
}, {
"type" : "WEB",
"url" : "https://github.com/mozilla/pdf.js/commit/85e64b5c16c9aaef738f421733c12911a441cec6"
}, {
"type" : "WEB",
"url" : "https://github.com/wojtekmaj/react-pdf/commit/208f28dd47fe38c33ce4bac4205b2b0a0bb207fe"
}, {
"type" : "WEB",
"url" : "https://github.com/wojtekmaj/react-pdf/commit/671e6eaa2e373e404040c13cc6b668fe39839cad"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/wojtekmaj/react-pdf"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2024-05-07T16:48:59Z",
"nvd_published_at" : "2024-05-07T15:15:09Z"
}
}