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

Source: https://junglewise.ai/threats/cve-2026-4372-huggingface-transformers-remote-code-execution-via-config-json  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-05-24. Updated: 2026-07-01  
License: CC BY 4.0 with a link back

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](https://junglewise.ai/threats/technologies/transformers), [transformers (PyPI)](https://junglewise.ai/threats/technologies/pypi-transformers). Vendors: [Hugging Face](https://junglewise.ai/threats/vendors/hugging-face), [PyPI](https://junglewise.ai/threats/vendors/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

  ```sh
  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

- [https://api.github.com/users/aaronmaxlevy](https://api.github.com/users/aaronmaxlevy)
- [https://github.com/aaronmaxlevy](https://github.com/aaronmaxlevy)
- [https://api.github.com/users/aaronmaxlevy/gists%7B/gist_id%7D](https://api.github.com/users/aaronmaxlevy/gists%7B/gist_id%7D)
- [https://api.github.com/users/aaronmaxlevy/repos](https://api.github.com/users/aaronmaxlevy/repos)
- [https://avatars.githubusercontent.com/u/3342097?v=4](https://avatars.githubusercontent.com/u/3342097?v=4)
- [https://api.github.com/users/aaronmaxlevy/events%7B/privacy%7D](https://api.github.com/users/aaronmaxlevy/events%7B/privacy%7D)

## Related threats

- [Hugging Face Transformers arbitrary file write via load_custom_generate](https://junglewise.ai/threats/cve-2026-80047-hugging-face-transformers-arbitrary-file-write-via-load-custom)
- [Hugging Face Transformers path traversal in save_pretrained](https://junglewise.ai/threats/cve-2026-9856-hugging-face-transformers-path-traversal-in-save-pretrained)
- [Hugging Face Transformers vulnerable to Regular Expression Denial of Service (ReDoS) in the AdamWeightDecay optimizer](https://junglewise.ai/threats/cve-2025-6921-hugging-face-transformers-vulnerable-to-regular-expression-denial)
- [PYSEC-2026-1988 - Hugging Face Transformers library has Regular Expression Denial of Service](https://junglewise.ai/threats/cve-2025-6051-hugging-face-transformers-library-has-regular-expression-denial-of)
- [PYSEC-2026-1981 - Hugging Face Transformers is vulnerable to ReDoS through its MarianTokenizer](https://junglewise.ai/threats/cve-2025-6638-hugging-face-transformers-is-vulnerable-to-redos-through-its)
