CVE-2026-4372: HuggingFace transformers remote code execution via config.json

CVE-2026-4372 · Severity: high · CVSS 7.8 · Published 2026-05-24

HuggingFace transformers, a widely used library for machine learning and artificial intelligence, is vulnerable to a flaw that allows attackers to execute malicious code on a user's system. By tricking a user into loading a specially crafted model configuration file, an attacker can gain full control over the victim's computer with their existing permissions. This could lead to the theft of sensitive data, installation of malware, or complete system compromise.

Technologies: Hugging Face Transformers, transformers (PyPI). Vendors: Hugging Face, PyPI.

Quick answers

Is CVE-2026-4372 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-4372 being exploited in the wild.
How severe is CVE-2026-4372?
High severity, with a CVSS score of 7.8, published 24 May 2026.
Which products and versions are affected?
Hugging Face Transformers < 5.3.0; transformers (PyPI) ECOSYSTEM:introduced=0,fixed=5.3.0.
Is there a fix for CVE-2026-4372?
Yes. transformers (PyPI): upgrade to 5.3.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-4372 attacked?
It is attacked with local access, in a software library.
Am I affected by CVE-2026-4372?
Check whether you run Hugging Face Transformers or transformers (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • transformers (PyPI): upgrade to 5.3.0 or later
    pip install "transformers>=5.3.0"

Technical details

A remote code execution vulnerability exists in HuggingFace transformers due to insecure deserialization of configuration attributes. An attacker can craft a 'config.json' file where the '_attn_implementation_internal' field points to a malicious HuggingFace Hub repository. When a victim uses the 'AutoModelForCausalLM.from_pretrained()' API to load the model, the library downloads and executes arbitrary Python code from the attacker-controlled repository. This exploit bypasses the 'trust_remote_code' security flag because it leverages internal fields that are not properly sanitized or sandboxed. The issue is addressed in version 5.3.0.

Affected products

  • HuggingFace transformers < 5.3.0

Identifiers

  • CVE-2026-4372
  • GHSA-29pf-2h5f-8g72
  • PYSEC-2026-2289

Timeline

  • 2026-05-24: advisory: NVD publication date
  • 2026-05-26: disclosed: GitHub Advisory published
  • 2026-07-01: patched: GitHub Advisory updated and reviewed

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.