GHSA-4m3g-6r7g-jv4f: Gradio pdf Arbitrary JavaScript Execution Due To Vulnerability

LOW
CVSS 3.6
CWE-79
Published
Advisory Summary

GHSA-4m3g-6r7g-jv4f is a LOW (CVSS 3.6) arbitrary javascript execution due to vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Gradio pdf libraries in the PyPI ecosystem. The issue involves arbitrary javascript execution due to using outdated libraries. Remediation is available by upgrading affected packages to version 0.0.10.

GHSA-4m3g-6r7g-jv4f at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-4m3g-6r7g-jv4f
Severity LOW
CVSS v3.1 Base Score 3.6
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Gradio pdf
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 3.6

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:L/I:N/A:N).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity None (I:N)
Availability None (A:N)

How to Fix GHSA-4m3g-6r7g-jv4f

To remediate this vulnerability, upgrade all affected Gradio 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.

gradio_pdf fixed: 0.0.10
pip install gradio_pdf>=0.0.10
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show gradio_pdf

How to Check if You Are Affected

To determine whether your Python environment is affected by GHSA-4m3g-6r7g-jv4f, inspect your installed packages using pip:

pip show gradio_pdf

Analyze the terminal output to locate any version of Gradio pdf in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.0.10), your application is affected.

Note: The pip show gradio_pdf command checks currently installed packages in your active Python environment.

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 Gradio 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 gradio-pdf projects with dependencies on the pdf.js library are vulnerable to CVE-2024-4367, which allows arbitrary JavaScript execution. ### PoC 1. Generate a pdf file with a malicious script in the fontmatrix. (This will run `alert(‘XSS’)`.) [poc.pdf](https://github.com/user-attachments/files/15516798/poc.pdf) 2. Run the app. In this PoC, I've used the demo for a simple proof. ![1](https://github.com/freddyaboulton/gradio-pdf/assets/114328108/d1bb7626-3d0f-4984-8873-297658d6e77e) 3. Upload a PDF file containing the script. ![2](https://github.com/freddyaboulton/gradio-pdf/assets/114328108/803d8080-c946-446e-bb34-cf5640e1b4de) 4. Check that the script is running. ![3](https://github.com/freddyaboulton/gradio-pdf/assets/114328108/4956b95f-acca-4bb1-a3c2-7dfc96adf890) ### Impact Malicious scripts can be injected into the code, and when linked with vulnerabilities such as CSRF, it can cause even greater damage. In particular, It can become a source of further attacks, especially when linked to social engineering. ### Mitigation Upgrade the pdf.js to v4.2.67, which removes the vulnerability. (or set the option `isEvalSupported` to `false`.) ### Reference 1. https://codeanlabs.com/blog/research/cve-2024-4367-arbitrary-js-execution-in-pdf-js/ 2. https://github.com/mozilla/pdf.js/pull/18015

GHSA-4m3g-6r7g-jv4f Affected Gradio pdf Versions

1 component(s)
Fixed Versions:
0.0.10
Product / Package Ecosystem Affected Versions Fixed Version
gradio_pdf
PyPI
< 0.0.10
0.0.10

References

Frequently Asked Questions

What is GHSA-4m3g-6r7g-jv4f?
GHSA-4m3g-6r7g-jv4f is a security vulnerability in Gradio pdf involving Arbitrary JavaScript execution due to using outdated libraries under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Gradio pdf versions are affected?
Affected versions include releases prior to 0.0.10 across affected packages: gradio_pdf.
What version fixes GHSA-4m3g-6r7g-jv4f?
Upgrading to 0.0.10 (or the latest patched release for your respective branch) resolves the vulnerability.
Is gradio_pdf affected?
Yes, gradio_pdf is affected in releases prior to 0.0.10. Upgrade your dependency to 0.0.10 or later.
What is the CVSS score of GHSA-4m3g-6r7g-jv4f?
GHSA-4m3g-6r7g-jv4f has a CVSS v3.1 base score of 3.6 (LOW) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:L/I:N/A:N.
What CWE is associated with GHSA-4m3g-6r7g-jv4f?
GHSA-4m3g-6r7g-jv4f 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 PyPI dependencies for GHSA-4m3g-6r7g-jv4f?
Run the dependency tree command: 'pip show gradio_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-4m3g-6r7g-jv4f",
  "modified" : "2024-06-05T14:15:50Z",
  "published" : "2024-06-05T14:15:50Z",
  "aliases" : [ ],
  "summary" : "Arbitrary JavaScript execution due to using outdated libraries",
  "details" : "### Summary\ngradio-pdf projects with dependencies on the pdf.js library are vulnerable to CVE-2024-4367, which allows arbitrary JavaScript execution.\n\n### PoC\n1. Generate a pdf file with a malicious script in the fontmatrix. (This will run `alert(‘XSS’)`.)\n[poc.pdf](https://github.com/user-attachments/files/15516798/poc.pdf)\n\n2. Run the app. In this PoC, I've used the demo for a simple proof.\n![1](https://github.com/freddyaboulton/gradio-pdf/assets/114328108/d1bb7626-3d0f-4984-8873-297658d6e77e)\n\n3. Upload a PDF file containing the script.\n![2](https://github.com/freddyaboulton/gradio-pdf/assets/114328108/803d8080-c946-446e-bb34-cf5640e1b4de)\n\n4. Check that the script is running.\n![3](https://github.com/freddyaboulton/gradio-pdf/assets/114328108/4956b95f-acca-4bb1-a3c2-7dfc96adf890)\n\n\n### Impact\nMalicious scripts can be injected into the code, and when linked with vulnerabilities such as CSRF, it can cause even greater damage. In particular, It can become a source of further attacks, especially when linked to social engineering.\n\n### Mitigation\nUpgrade the pdf.js to v4.2.67, which removes the vulnerability. (or set the option `isEvalSupported` to `false`.)\n\n### Reference\n1. https://codeanlabs.com/blog/research/cve-2024-4367-arbitrary-js-execution-in-pdf-js/\n2. https://github.com/mozilla/pdf.js/pull/18015",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "gradio_pdf"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.0.10"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/freddyaboulton/gradio-pdf/security/advisories/GHSA-4m3g-6r7g-jv4f"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/freddyaboulton/gradio-pdf/commit/67edd0c625fae7b855186727ee9678297602ee45"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/freddyaboulton/gradio-pdf"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-06-05T14:15:50Z",
    "nvd_published_at" : null
  }
}