CVE-2024-3924: Text generation Code Injection Vulnerability Exists Vulnerability

MODERATE
Advisory Identifier: GHSA-qq99-p57r-g3v7
CVSS 4.4
CWE-94
Published
Advisory Summary

CVE-2024-3924 is a MODERATE (CVSS 4.4) code injection vulnerability exists vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Text generation libraries in the PyPI ecosystem. The issue involves code injection vulnerability exists in the huggingface/text-generation-inference repository. Remediation is available by upgrading affected packages to version 2.0.0.

CVE-2024-3924 at a Glance

CVE Identifier CVE-2024-3924
GHSA Identifier GHSA-qq99-p57r-g3v7
Severity MODERATE
CVSS v3.1 Base Score 4.4
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Text generation
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 4.4

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

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

How to Fix CVE-2024-3924

To remediate this vulnerability, upgrade all affected Text generation dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

text-generation fixed: 2.0.0
pip install text-generation>=2.0.0
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 text-generation

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2024-3924, inspect your installed packages using pip:

pip show text-generation

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Text generation, 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

A code injection vulnerability exists in the huggingface/text-generation-inference repository, specifically within the `autodocs.yml` workflow file. The vulnerability arises from the insecure handling of the `github.head_ref` user input, which is used to dynamically construct a command for installing a software package. An attacker can exploit this by forking the repository, creating a branch with a malicious payload as the name, and then opening a pull request to the base repository. Successful exploitation could lead to arbitrary code execution within the context of the GitHub Actions runner. This issue affects versions up to and including v2.0.0 and was fixed in version 2.0.0.

CVE-2024-3924 Affected Text generation Versions

1 component(s)
Fixed Versions:
2.0.0
Product / Package Ecosystem Affected Versions Fixed Version
text-generation
PyPI
< 2.0.0
2.0.0

References

Frequently Asked Questions

What is CVE-2024-3924?
CVE-2024-3924 is a security vulnerability in Text generation involving code injection vulnerability exists in the huggingface/text-generation-inference repository under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Text generation versions are affected?
Affected versions include releases prior to 2.0.0 across affected packages: text-generation.
What version fixes CVE-2024-3924?
Upgrading to 2.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is text-generation affected?
Yes, text-generation is affected in releases prior to 2.0.0. Upgrade your dependency to 2.0.0 or later.
What is the CVSS score of CVE-2024-3924?
CVE-2024-3924 has a CVSS v3.1 base score of 4.4 (MODERATE) with vector string CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2024-3924?
CVE-2024-3924 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check PyPI dependencies for CVE-2024-3924?
Run the dependency tree command: 'pip show text-generation'. 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-qq99-p57r-g3v7",
  "modified" : "2024-06-02T22:30:17Z",
  "published" : "2024-06-02T22:30:17Z",
  "aliases" : [ "CVE-2024-3924" ],
  "summary" : "code injection vulnerability exists in the huggingface/text-generation-inference repository",
  "details" : "A code injection vulnerability exists in the huggingface/text-generation-inference repository, specifically within the `autodocs.yml` workflow file. The vulnerability arises from the insecure handling of the `github.head_ref` user input, which is used to dynamically construct a command for installing a software package. An attacker can exploit this by forking the repository, creating a branch with a malicious payload as the name, and then opening a pull request to the base repository. Successful exploitation could lead to arbitrary code execution within the context of the GitHub Actions runner. This issue affects versions up to and including v2.0.0 and was fixed in version 2.0.0.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.0/AV:N/AC:H/PR:L/UI:R/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "text-generation"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-3924"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/huggingface/text-generation-inference/commit/88702d876383f7200eccf67e28ba00500dc804bb"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/huggingface/text-generation-inference"
  }, {
    "type" : "WEB",
    "url" : "https://huntr.com/bounties/8af92fc2-0103-4d29-bb28-c3893154c422"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-06-02T22:30:17Z",
    "nvd_published_at" : "2024-05-30T15:15:49Z"
  }
}