CVE-2024-34342: React pdf React-pdf Vulnerable To Arbitrary JavaScript Vulnerability

HIGH
Advisory Identifier: GHSA-87hq-q4gp-9wr4
CVSS 7.1
CWE-79
Published
Advisory Summary

CVE-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

CVE Identifier CVE-2024-34342
GHSA Identifier GHSA-87hq-q4gp-9wr4
Severity HIGH
CVSS v3.1 Base Score 7.1
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product React pdf
Package Ecosystem npm
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability Low (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.

react-pdf fixed: 7.7.3
npm install react-pdf@7.7.3
react-pdf fixed: 8.0.2
npm install react-pdf@8.0.2
Verify Direct and Transitive Dependencies

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

### 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](https://github.com/wojtekmaj/react-pdf/commit/671e6eaa2e373e404040c13cc6b668fe39839cad) forces `isEvalSupported` to `false`, removing the attack vector. ### Workarounds Set `options.isEvalSupported` to `false`, where `options` is `Document` component prop. ### References - [GHSA-wgrm-67xf-hhpq](https://github.com/mozilla/pdf.js/security/advisories/GHSA-wgrm-67xf-hhpq) - https://github.com/mozilla/pdf.js/pull/18015 - https://github.com/mozilla/pdf.js/commit/85e64b5c16c9aaef738f421733c12911a441cec6 - https://bugzilla.mozilla.org/show_bug.cgi?id=1893645

CVE-2024-34342 Affected React pdf Versions

2 component(s)
Fixed Versions:
7.7.38.0.2
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?
CVE-2024-34342 is a security vulnerability in React pdf involving react-pdf vulnerable to arbitrary JavaScript execution upon opening a malicious PDF with PDF.js under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which React pdf versions are affected?
Affected versions include releases prior to 7.7.3, 8.0.2 across affected packages: react-pdf.
What version fixes CVE-2024-34342?
Upgrading to 7.7.3, 8.0.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is react-pdf affected?
Yes, react-pdf is affected in releases prior to 7.7.3, 8.0.2. Upgrade your dependency to 7.7.3, 8.0.2 or later.
What is the CVSS score of CVE-2024-34342?
CVE-2024-34342 has a CVSS v3.1 base score of 7.1 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:L.
What CWE is associated with CVE-2024-34342?
CVE-2024-34342 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (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.).
How can I check npm dependencies for CVE-2024-34342?
Run the dependency tree command: 'npm ls react-pdf'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}