CVE-2026-4372: Transformers Remote Code Execution Vulnerability

HIGH
Advisory Identifier: GHSA-29pf-2h5f-8g72
CVSS 7.8
CWE-502 CWE-1066
Published
Advisory Summary

CVE-2026-4372 is a HIGH (CVSS 7.8) remote code execution vulnerability (CWE-502: Deserialization of Untrusted Data) affecting Transformers libraries in the PyPI ecosystem. The issue involves huggingface transformers vulnerable to remote code execution. Remediation is available by upgrading affected packages to version 5.3.0.

CVE-2026-4372 at a Glance

CVE Identifier CVE-2026-4372
GHSA Identifier GHSA-29pf-2h5f-8g72
Severity HIGH
CVSS v3.1 Base Score 7.8
CWE Classification CWE-502: Deserialization of Untrusted Data
Affected Product Transformers
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.8

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

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

How to Fix CVE-2026-4372

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

transformers fixed: 5.3.0
pip install transformers>=5.3.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 transformers

How to Check if You Are Affected

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

pip show transformers

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-502: Deserialization of Untrusted Data, where the product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid. In Transformers, 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 critical remote code execution vulnerability exists in all versions of the HuggingFace transformers library prior to version 5.3.0. The vulnerability allows an attacker to craft a malicious `config.json` file containing the `_attn_implementation_internal` field set to an attacker-controlled HuggingFace Hub repository ID. When a victim loads this model using the standard `AutoModelForCausalLM.from_pretrained()` API, the library downloads and executes arbitrary Python code from the attacker's repository with the victim's full OS privileges. This issue arises due to unfiltered deserialization of configuration attributes, insufficient sanitization of internal fields, and unsandboxed execution of downloaded kernels. The vulnerability bypasses the `trust_remote_code` security mechanism, is invisible to the victim, and exploits the standard documented usage pattern, making it particularly severe. Users are advised to upgrade to version 5.3.0 or later to mitigate this issue.

CVE-2026-4372 Affected Transformers Versions

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

References

Frequently Asked Questions

What is CVE-2026-4372?
CVE-2026-4372 is a security vulnerability in Transformers involving HuggingFace transformers vulnerable to remote code execution under CWE-502: Deserialization of Untrusted Data.
Which Transformers versions are affected?
Affected versions include releases prior to 5.3.0 across affected packages: transformers.
What version fixes CVE-2026-4372?
Upgrading to 5.3.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is transformers affected?
Yes, transformers is affected in releases prior to 5.3.0. Upgrade your dependency to 5.3.0 or later.
What is the CVSS score of CVE-2026-4372?
CVE-2026-4372 has a CVSS v3.1 base score of 7.8 (HIGH) with vector string CVSS:3.0/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-4372?
CVE-2026-4372 is classified under CWE-502: Deserialization of Untrusted Data (The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.).
How can I check PyPI dependencies for CVE-2026-4372?
Run the dependency tree command: 'pip show transformers'. 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-29pf-2h5f-8g72",
  "modified" : "2026-07-01T18:00:10Z",
  "published" : "2026-05-26T13:30:33Z",
  "aliases" : [ "CVE-2026-4372" ],
  "summary" : "HuggingFace transformers vulnerable to remote code execution",
  "details" : "A critical remote code execution vulnerability exists in all versions of the HuggingFace transformers library prior to version 5.3.0. The vulnerability allows an attacker to craft a malicious `config.json` file containing the `_attn_implementation_internal` field set to an attacker-controlled HuggingFace Hub repository ID. When a victim loads this model using the standard `AutoModelForCausalLM.from_pretrained()` API, the library downloads and executes arbitrary Python code from the attacker's repository with the victim's full OS privileges. This issue arises due to unfiltered deserialization of configuration attributes, insufficient sanitization of internal fields, and unsandboxed execution of downloaded kernels. The vulnerability bypasses the `trust_remote_code` security mechanism, is invisible to the victim, and exploits the standard documented usage pattern, making it particularly severe. Users are advised to upgrade to version 5.3.0 or later to mitigate this issue.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.0/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "transformers"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.3.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-4372"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/huggingface/transformers/commit/a7f8e7ff37d87d1a1a0c8cf607971c607741452f"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/huggingface/transformers"
  }, {
    "type" : "WEB",
    "url" : "https://huntr.com/bounties/1f693a6e-6836-4b8b-a0bd-ca036fba8884"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1066", "CWE-502" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-01T18:00:10Z",
    "nvd_published_at" : "2026-05-24T14:16:16Z"
  }
}