Skip to content
RCE Disclosed report Advanced CVE-2026-4372

HuggingFace transformers vulnerable to remote code execution

A remote code execution flaw in HuggingFace transformers before version 5.3.0 lets an attacker embed a malicious repository ID in a model's config file. When a victim loads the model with the standard API, the library downloads and runs arbitrary Python code from the attacker's repository with the victim's privileges.

huggingface/transformers

Originally disclosed on huntr

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.

From the GitHub Advisory Database (GHSA-29pf-2h5f-8g72, CC BY 4.0).

The original report as published on the GitHub Advisory Database. Images and videos are our own copies; raw HTML is shown as text. View it on GitHub Advisory Database.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely unfiltered deserialisation of configuration attributes combined with unsandboxed execution of downloaded kernels, which bypasses the trust_remote_code safeguard.

Impact

An attacker could run arbitrary code with the victim's full OS privileges, and the exploit bypasses trust_remote_code and is invisible to the victim.

What the attacker needed

Victim loads a malicious model config; attacker controls a HuggingFace Hub repository

The fix

The issue was fixed in version 5.3.0; users should upgrade to that version or later.

How it was found

  1. Craft a malicious config.json with the _attn_implementation_internal field set to an attacker-controlled repository ID.
  2. Victim loads the model using AutoModelForCausalLM.from_pretrained().
  3. The library downloads and executes arbitrary Python code from the attacker's repository.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A library for loading AI models can be tricked by a model's configuration file into fetching and running code from a repository the attacker controls. The victim just loads the model normally, and the code runs on their computer without any warning. This is dangerous because the attacker can then do anything the victim could do on that machine.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More from huggingface/transformers

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.