Skip to main content

Hugging Face diffusers CVE-2026-45804

| EUVDEUVD-2026-44711 HIGH
Time-of-check Time-of-use (TOCTOU) Race Condition (CWE-367)
2026-05-20 https://github.com/huggingface/diffusers GHSA-7wx4-6vff-v64p PYSEC-2026-2446
7.5
CVSS 3.1 · Vendor: https://github.com/huggingface/diffusers
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Recon
    Publish malicious Hub repo with clean model_index.json
  2. Delivery
    Victim calls from_pretrained without revision pin
  3. Exploit
    hf_hub_download fetches commit A, trust check passes
  4. Install
    Attacker pushes commit B adding pipeline.py and list _class_name
  5. C2
    snapshot_download fetches commit B
  6. Execute
    _resolve_custom_pipeline_and_cls imports pipeline.py
  7. Impact
    Arbitrary code executes in victim process

Vulnerability Assessment

Weakness
CWE
ASVS 5.0
V15 - Secure Coding and Architecture TOCTOU prevention
Exploitation Conditions

Requires the victim to call DiffusionPipeline.from_pretrained against an attacker-controlled (or attacker-compromised) Hub repository with revision left unpinned (revision=None / branch or tag reference, not a commit SHA), and the relevant files must NOT be fully present in the local Hugging Face cache - otherwise download() takes its early-return path at pipeline_utils.py:1767 before snapshot_download runs, closing the race. The attacker must win a ~0.5-second race window between hf_hub_download(model_index.json) and snapshot_download() by pushing commit B during that interval; CVSS PR:N means no Hub authentication on the victim side beyond normal Hub access, but UI:R captures the required victim action of initiating the load. Exploitation does NOT apply when loading from a local directory or when the repo revision is pinned to a specific commit hash.

Impact

CVSS 7.5 (AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H) reflects a genuinely network-reachable RCE but with two real dampeners: AC:H captures the ~0.5-second race window the reporter measured, and UI:R captures the requirement that a victim invoke from_pretrained against the attacker's repo without revision pinning and without a fully populated local cache. There is no EPSS, KEV, or SSVC data supplied, and no evidence of in-the-wild abuse - exploitation status is best described as publicly available exploit code exists (the GHSA PoC), not active exploitation. The reporter notes statistical success is plausible against high-traffic repos by flipping repo state periodically, so for organizations that auto-pull popular community pipelines without commit pinning the practical risk is meaningfully higher than AC:H alone suggests; for teams that pin revisions or load only from trusted/local sources the residual risk is low.

Exploit ScenarioDerived

An attacker publishes (or compromises) a popular-looking diffusion model repo whose model_index.json declares a benign string _class_name, then continuously flips the repo between that clean state and a malicious state where _class_name is a list and a pipeline.py drops a payload. A victim running DiffusionPipeline.from_pretrained("attacker/repo") without revision pinning and without a pre-warmed cache occasionally lands inside the race window, at which point snapshot_download pulls the malicious commit and the imported pipeline.py executes arbitrary code in the victim's Python process. The reporter has published a working PoC in the GHSA advisory demonstrating the file-write primitive.

This Week Schedule remediation this week. Why: HIGH severity (CVSS 7.0-8.9).
Patch available 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – May 20, 2026

Remote code execution in Hugging Face diffusers (Python package, versions < 0.38.0) is achievable via a TOCTOU race between two sequential Hub downloads inside DiffusionPipeline.from_pretrained, letting a malicious repo owner bypass the trust_remote_code guard and silently execute arbitrary Python during model loading. Exploitation requires user interaction (loading a malicious repo without pinning a revision) and high attack complexity due to a sub-second race window, but no public exploit beyond the reporter's PoC is identified at time of analysis. Affected users running diffusers <0.38.0 should upgrade to 0.38.0 where the issue is fixed.

RemediationAI

Upgrade to diffusers 0.38.0 or later (Vendor-released patch: 0.38.0) per the GHSA advisory at https://github.com/huggingface/diffusers/security/advisories/GHSA-7wx4-6vff-v64p. Until the upgrade lands, eliminate the race by always passing an explicit revision pinned to a full commit SHA (not a branch name or tag) to from_pretrained, which forces both hf_hub_download and snapshot_download to resolve to identical content; the trade-off is that consumers lose automatic upstream updates and must rotate pins manually. Additional compensating controls: restrict from_pretrained usage to vetted, internally mirrored repositories rather than arbitrary Hub paths (trade-off: operational overhead of mirroring), pre-populate the local HF cache so download() takes the early-return path before snapshot_download (trade-off: only protects already-cached models), and run any first-time loads of untrusted repos inside an isolated sandbox or container without network/credential access (trade-off: friction for experimentation workflows).

Affected VersionsENISA

Diffusers < 0.38.0

Affected Packages

pypi diffusers fix: 0.38.0

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in pypi

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

The diffusers library is the de facto loader for diffusion-model pipelines from the Hugging Face Hub and mirrors transformers' from_pretrained pattern. The flaw is a CWE-367 Time-of-Check Time-of-Use race: download() calls hf_hub_download to fetch model_index.json (commit A) and enforces the trust_remote_code check on that content, then calls snapshot_download separately which independently resolves the branch HEAD and may fetch a different commit (commit B). Because both calls resolve revision=None to whatever the branch points to at call time, an attacker who pushes between them can swap a benign string _class_name for a list that points to a freshly added pipeline.py; the downstream _resolve_custom_pipeline_and_cls in pipeline_loading_utils.py then imports the attacker-controlled .py without re-running the trust gate. Affected CPE is pkg:pip/diffusers.

Know when Python gets its next vulnerability

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (https://github.com/huggingface/diffusers) PRIMARY 7.5 HIGH
AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H
Red Hat 7.5 HIGH

Primary rating from Vendor (https://github.com/huggingface/diffusers).

CVSS VectorVendor: https://github.com/huggingface/diffusers

Attack Vector
Network
Attack Complexity
High
Privileges Required
None
User Interaction
Required
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

DescriptionCVE.org

Background

This vulnerability is found in the diffusers package - the transformers-equivalent library for diffusion models.

It is found in the DiffusionPipeline.from_pretrained flow, which is used to load a pipeline from the HuggingFace Hub.

This function has a trust_remote_code guard: if the repository’s model_index.json references a custom pipeline class defined in a .py file in the repo, the load is blocked unless trust_remote_code=True is explicitly passed:

ValueError: The repository for attacker/repo contains custom code in pipeline.py
which must be executed to correctly load the model. You can inspect the repository
content at https://hf.co/attacker/repo/blob/main/pipeline.py.
Please pass the argument `trust_remote_code=True` to allow custom code to be run.

The vulnerability allows arbitrary code execution through the custom pipeline flow from a Hub repo, with no custom_pipeline or trust_remote_code kwargs passed. The from_pretrained call succeeds and returns a functional pipeline.

---

Naive Flow

DiffusionPipeline.from_pretrained begins by popping all relevant arguments from kwargs into local variables, then calls DiffusionPipeline.download() to fetch the repo files:

python
# pipeline_utils.py:853
cached_folder = cls.download(
    pretrained_model_name_or_path,
    ...
    custom_pipeline=custom_pipeline,
    trust_remote_code=trust_remote_code,
    ...
)

Inside download(), model_index.json is fetched first as a standalone file via hf_hub_download:

python
# pipeline_utils.py:1636
config_file = hf_hub_download(
    pretrained_model_name,
    cls.config_name,
    ...
)
config_dict = cls._dict_from_json_file(config_file)

This config is used to detect custom pipeline code and enforce the trust check:

python
# pipeline_utils.py:1672
if custom_pipeline is None and isinstance(config_dict["_class_name"], (list, tuple)):
    custom_pipeline = config_dict["_class_name"][0]

load_pipe_from_hub = custom_pipeline is not None and f"{custom_pipeline}.py" in filenames

if load_pipe_from_hub and not trust_remote_code:
    raise ValueError(...)

After the check passes, snapshot_download then fetches all files and saves them to disk:

python
# pipeline_utils.py:1778
cached_folder = snapshot_download(
    pretrained_model_name,
    ...
    revision=revision,
    allow_patterns=allow_patterns,
    ...
)

Back in from_pretrained, the config is read a second time from the downloaded snapshot, and_resolve_custom_pipeline_and_cls reads the config to re-check if custom code needs to be loaded:

python
# pipeline_loading_utils.py:974
def _resolve_custom_pipeline_and_cls(folder, config, custom_pipeline):
    custom_class_name = None
    if os.path.isfile(os.path.join(folder, f"{custom_pipeline}.py")):
        custom_pipeline = os.path.join(folder, f"{custom_pipeline}.py")
    elif isinstance(config["_class_name"], (list, tuple)) and os.path.isfile(
        os.path.join(folder, f"{config['_class_name'][0]}.py")
    ):
        custom_pipeline = os.path.join(folder, f"{config['_class_name'][0]}.py")
        custom_class_name = config["_class_name"][1]

    return custom_pipeline, custom_class_name

If the config points to a .py file, it is imported.

---

The Vulnerability

hf_hub_download and snapshot_download are two independent HTTP calls to the Hub, both resolving the repository’s default branch (if revision=None) to its current HEAD at call time. There is no atomicity guarantee between them - if the repository is updated between the two calls, they will resolve to different commits and download different content, with no warning displayed to the user.

The trust check in download() operates on the content fetched by hf_hub_download (commit A). The snapshot_download call that immediately follows can silently fetch a newer commit (commit B). The config in the newer commit will be the one parsed by _resolve_custom_pipeline_and_cls.

Therefore, it’s possible to introduce remote code into the repo between the two calls, bypassing the trust check.

The race window is everything between the two Hub calls inside download():

python
# pipeline_utils.py:1636
config_file = hf_hub_download(...)
# ← sees commit A, trust check passes
# ... filenames processing, pattern building, pipeline_is_cached check ...
# ~~~ ATTACKER PUSHES COMMIT B HERE ~~~
# pipeline_utils.py:1778
cached_folder = snapshot_download(...)
# ← sees commit B, downloads pipeline.py

For the exploit, commit A carries a clean config with _class_name as a plain string, which causes load_pipe_from_hub to be False and the trust check to pass. Commit B changes _class_name to a list and adds pipeline.py:

Commit A - model_index.json:

json
{
  "_class_name": "FluxPipeline",
  "_diffusers_version": "0.31.0"
}

Commit B - model_index.json:

json
{
  "_class_name": ["pipeline", "FluxPipeline"],
  "_diffusers_version": "0.31.0"
}

When from_pretrained reads the snapshot after download() returns, config["_class_name"] is now a list, pipeline.py exists on disk (fetched by snapshot_download), and _resolve_custom_pipeline_and_cls resolves custom_pipeline to the local path of that file. _get_pipeline_class then imports it - with no trust check at this point in the code.

---

PoC

  1. Create a Hub repo with commit A’s model_index.json (plain string _class_name).
  2. Run DiffusionPipeline.from_pretrained("attacker/repo") with a breakpoint set at pipeline_utils.py:1778 (the snapshot_download call). This is for the window to be large enough to manually respond to it.
  3. When execution pauses at the breakpoint, push commit B: update model_index.json to use a list _class_name and add pipeline.py.
  4. Resume execution.
  5. snapshot_download fetches commit B; /tmp/pwned is written during the subsequent _get_pipeline_class call.

---

Constraints

  • Does not apply when revision is pinned to a specific commit hash - both Hub calls resolve to the same content.
  • Does not apply when loading from a local directory.
  • If all expected files are already present in the local HF cache, download() returns early before reaching snapshot_download (line 1767 early-return), closing the race window. The exploit therefore requires a first (or forced) download.

---

Exploitability

The window between the two calls is very short. Local testing resulted in a window of approximately ~0.5 seconds for the attacker to push the change. This is, of course, unfeasible to accomplish for each and every new download. However, given a popular repo with many downloads per day, one may achieve statistical success by changing the repo’s state every once in a while or every few seconds, with some percentage of downloaders falling on the exact window.

---

Impact

The vulnerability is a silent RCE - it allows arbitrary code to be loaded through the custom pipeline flow from a Hub repo, with no custom_pipeline or trust_remote_code kwargs. The from_pretrained call succeeds and returns a fully functional pipeline.

Blast Radius

ecosystem impact
† from your stack dependencies † transitive graph · vuln.today resolves 4-path depth
  • 4 pypi packages depend on diffusers (3 direct, 1 indirect)

Ecosystem-wide dependent count for version 0.38.0.

Executive ViewAI

Why It Matters

Hugging Face diffusers, a widely-used Python package for machine learning workflows, contains a high-severity remote code execution vulnerability (CVE-2026-45804) permitting silent arbitrary code execution during model loading. Organizations using diffusers < 0.38.0 that load untrusted AI models face risk of compromised development infrastructure, exfiltrated training data, and embedded malicious code in production pipelines. Vendor patch is available and deployment should proceed urgently.

Business Impact: High
Compensating Controls

Apply vendor patch: upgrade Hugging Face diffusers to version 0.38.0 or later. If immediate patching is constrained: (1) require explicit model revision pinning in all load operations, (2) restrict model repository access to approved internal sources only, (3) isolate model-loading processes in sandboxed environments with minimal privilege, (4) implement network egress controls to limit outbound repository connections.

Threat Intelligence Overview

EPSS Score
0.0%
Top 85% exploitable
Threat Intel
1
1 source
Data Quality
7 sources
Confidence: High
EUVD NVD CVE.org EPSS GHSA Vendor GitHub VulDB

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity HIGH
CISA KEV No
Public POC No
EPSS 0.0%
Patch available Yes
Active threat No
Deciding rule
HIGH severity (CVSS 7.0-8.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
No
Human Impact
High

Priority Score

38
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +38
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.

More in Python

View all
CVE-2025-24016 CRITICAL POC
9.9 Feb 10

Wazuh SIEM platform versions 4.4.0 through 4.9.0 contain an unsafe deserialization vulnerability in the DistributedAPI t

CVE-2025-27520 CRITICAL POC
9.8 Apr 04

BentoML version 1.4.2 and earlier contains an unauthenticated remote code execution vulnerability through insecure deser

CVE-2025-2945 CRITICAL POC
9.9 Apr 03

pgAdmin 4 contains critical remote code execution vulnerabilities in the Query Tool download and Cloud Deployment endpoi

CVE-2013-5093 MEDIUM POC
6.8 Sep 27

The renderLocalView function in render/views.py in graphite-web in Graphite 0.9.5 through 0.9.10 uses the pickle Python

CVE-2025-32375 CRITICAL POC
9.8 Apr 09

BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Rated critica

CVE-2014-0224 HIGH POC
7.4 Jun 05

OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h does not properly restrict processing of ChangeCiph

CVE-2024-21644 HIGH POC
7.5 Jan 08

pyLoad download manager version prior to 0.5.0b3.dev77 exposes the Flask SECRET_KEY through an unauthenticated endpoint.

CVE-2026-33017 CRITICAL POC
9.3 Mar 17

Langflow (a visual LLM pipeline builder) contains a critical unauthenticated code execution vulnerability (CVE-2026-3301

CVE-2017-9462 HIGH POC
8.8 Jun 06

In Mercurial before 4.1.3, "hg serve --stdio" allows remote authenticated users to launch the Python debugger, and conse

CVE-2026-49869 CRITICAL POC
10.0 Jun 26

Unauthenticated remote code execution affects Kestra OSS (the open-source event-driven orchestration platform) prior to

CVE-2026-39987 CRITICAL POC
9.3 Apr 08

Unauthenticated remote code execution in Marimo ≤0.20.4 allows attackers to execute arbitrary system commands via the `/

CVE-2024-21645 MEDIUM POC
5.3 Jan 08

pyLoad is the free and open-source Download Manager written in pure Python. Rated medium severity (CVSS 5.3), this vulne

Vendor StatusVendor

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy