CVE-2026-45804: diffusers: TOCTOU race bypasses trust_remote_code, RCE
GHSA-7wx4-6vff-v64p HIGH PoC AVAILABLE CISA: ATTENDA time-of-check/time-of-use race condition in HuggingFace diffusers allows an attacker-controlled Hub repository to silently execute arbitrary code during a routine DiffusionPipeline.from_pretrained() call, completely circumventing the trust_remote_code security guard. The attack exploits the ~0.5-second window between two independent Hub API calls: the trust check reads a clean model_index.json (commit A), but snapshot_download immediately after can silently fetch a malicious commit B containing a custom pipeline.py — no warning is shown and the pipeline loads and functions normally. With 393 downstream packages depending on diffusers and the library being central to generative AI workloads, any team running unversioned model loads in CI/CD, automated training, or inference pipelines is exposed; an attacker doesn't need per-victim timing precision against a popular repo, only statistical success across many concurrent downloads. Patch to diffusers >= 0.38.0 immediately, and as a compensating control pin all from_pretrained() calls with revision=<commit_sha> to eliminate the split-fetch window entirely.
What is the risk?
High risk for organizations running automated diffusion model pipelines that load from HuggingFace Hub without pinned commit revisions. CVSS 7.5 reflects AC:H for the timing requirement, but the statistical exploitation model against high-traffic repositories makes this operationally realistic — an attacker cycling repository state every few seconds against a popular model achieves meaningful hit rates at scale without targeting individual victims. The RCE is silent: the pipeline returns fully functional, making detection without process-level monitoring or egress filtering extremely difficult post-exploitation. OpenSSF Scorecard of 4.3/10 signals broader security hygiene concerns in the package. Risk is substantially lower for deployments using pinned revision hashes or loading from local directories, both of which close the race window entirely.
How does the attack unfold?
What systems are affected?
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| Diffusers | pip | < 0.38.0 | 0.38.0 |
Do you use Diffusers? You're affected.
How severe is it?
What is the attack surface?
What should I do?
6 steps-
Patch: Upgrade diffusers to >= 0.38.0 which resolves the race condition.
-
Immediate workaround: Pin all from_pretrained() calls with revision='<specific_commit_sha>' — both Hub calls resolve to identical content, eliminating the race window entirely.
-
Offline loading: Use local_files_only=True after a verified baseline download, or load from local directory paths to avoid Hub calls altogether.
-
Audit: Search codebases and CI/CD configs for DiffusionPipeline.from_pretrained() calls missing a revision= parameter; treat any dynamic Hub load as high-risk until patched.
-
Detection: Monitor for unexpected Python imports or outbound network connections spawned during model loading; alert on pipeline.py or similarly named files appearing in HuggingFace cache directories (~/.cache/huggingface/) post-download.
-
Supply chain hygiene: Enforce a policy of loading models only from organization-controlled forks with locked revisions for production workloads.
What does CISA's SSVC say?
Source: CISA Vulnrichment (SSVC v2.0). Decision based on the CISA Coordinator decision tree.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2026-45804?
A time-of-check/time-of-use race condition in HuggingFace diffusers allows an attacker-controlled Hub repository to silently execute arbitrary code during a routine DiffusionPipeline.from_pretrained() call, completely circumventing the trust_remote_code security guard. The attack exploits the ~0.5-second window between two independent Hub API calls: the trust check reads a clean model_index.json (commit A), but snapshot_download immediately after can silently fetch a malicious commit B containing a custom pipeline.py — no warning is shown and the pipeline loads and functions normally. With 393 downstream packages depending on diffusers and the library being central to generative AI workloads, any team running unversioned model loads in CI/CD, automated training, or inference pipelines is exposed; an attacker doesn't need per-victim timing precision against a popular repo, only statistical success across many concurrent downloads. Patch to diffusers >= 0.38.0 immediately, and as a compensating control pin all from_pretrained() calls with revision=<commit_sha> to eliminate the split-fetch window entirely.
Is CVE-2026-45804 actively exploited?
Proof-of-concept exploit code is publicly available for CVE-2026-45804, increasing the risk of exploitation.
How to fix CVE-2026-45804?
1. Patch: Upgrade diffusers to >= 0.38.0 which resolves the race condition. 2. Immediate workaround: Pin all from_pretrained() calls with revision='<specific_commit_sha>' — both Hub calls resolve to identical content, eliminating the race window entirely. 3. Offline loading: Use local_files_only=True after a verified baseline download, or load from local directory paths to avoid Hub calls altogether. 4. Audit: Search codebases and CI/CD configs for DiffusionPipeline.from_pretrained() calls missing a revision= parameter; treat any dynamic Hub load as high-risk until patched. 5. Detection: Monitor for unexpected Python imports or outbound network connections spawned during model loading; alert on pipeline.py or similarly named files appearing in HuggingFace cache directories (~/.cache/huggingface/) post-download. 6. Supply chain hygiene: Enforce a policy of loading models only from organization-controlled forks with locked revisions for production workloads.
What systems are affected by CVE-2026-45804?
This vulnerability affects the following AI/ML architecture patterns: Diffusion model inference pipelines, Generative AI training pipelines, MLOps CI/CD automation, Model evaluation and benchmarking workflows, HuggingFace Hub-integrated services.
What is the CVSS score for CVE-2026-45804?
CVE-2026-45804 has a CVSS v3.1 base score of 7.5 (HIGH). The EPSS exploitation probability is 0.38%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0010.001 AI Software AML.T0010.003 Model AML.T0011.000 Unsafe AI Artifacts AML.T0079 Stage Capabilities AML.T0109 AI Supply Chain Rug Pull Compliance Controls Affected
What are the technical details?
Original Advisory
Diffusers is the a library for pretrained diffusion models. Prior to 0.38.0, Diffusers' DiffusionPipeline.from_pretrained flow can bypass the trust_remote_code guard because download() validates model_index.json and custom pipeline code before later loading from a cached folder that can change, allowing a Hub repository with custom .py pipeline code to execute through the custom pipeline flow without passing custom_pipeline or trust_remote_code=True. This issue is fixed in version 0.38.0.
Exploitation Scenario
An adversary creates a convincing HuggingFace repository hosting a popular diffusion model (or compromises an existing one with significant traffic). They maintain commit A with a clean model_index.json where _class_name is a plain string — this ensures the trust check passes for all incoming downloads. They deploy automation that rapidly cycles the repository between commit A and a malicious commit B every few seconds: commit B changes _class_name to a list and adds a pipeline.py containing a reverse shell payload or credential harvester targeting cloud provider metadata endpoints. Against a repo receiving thousands of daily downloads, a statistically significant fraction of from_pretrained() calls hit the split-commit window: hf_hub_download resolves commit A (trust check passes), then snapshot_download resolves commit B (malicious pipeline.py downloaded). Victims' ML workers silently execute the payload — with no error, no warning, and a fully functional pipeline returned — giving the attacker persistent access to GPU clusters, training datasets, and cloud credentials before any detection occurs.
Weaknesses (CWE)
CWE-367 Time-of-check Time-of-use (TOCTOU) Race Condition
Primary
CWE-367 Time-of-check Time-of-use (TOCTOU) Race Condition
Primary
CWE-367 Time-of-check Time-of-use (TOCTOU) Race Condition CWE-367 — Time-of-check Time-of-use (TOCTOU) Race Condition: The product checks the state of a resource before using that resource, but the resource's state can change between the check and the use in a way that invalidates the results of the check.
- [Implementation] The most basic advice for TOCTOU vulnerabilities is to not perform a check before the use. This does not resolve the underlying issue of the execution of a function on a resource whose state and identity cannot be assured, but it does help to limit the false sense of security given by the check.
- [Implementation] When the file being altered is owned by the current user and group, set the effective gid and uid to that of the current user and group when executing this statement.
Source: MITRE CWE corpus.
CVSS Vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H References
- github.com/advisories/GHSA-7wx4-6vff-v64p
- github.com/huggingface/diffusers/security/advisories/GHSA-7wx4-6vff-v64p
- github.com/huggingface/diffusers/commit/a37f6f8394ac2a7ee8360c3abea811efe54512b1
- github.com/huggingface/diffusers/issues/13446
- github.com/huggingface/diffusers/pull/13448
- github.com/huggingface/diffusers/releases/tag/v0.38.0
Timeline
Related Vulnerabilities
GHSA-j7w6-vpvq-j3gm 8.8 diffusers: silent RCE via None.py trust_remote_code bypass
Same package: diffusers CVE-2026-44513 8.8 diffusers: trust_remote_code bypass enables silent RCE
Same package: diffusers CVE-2026-65920 4.3 Diffusers: path traversal via weight_map exposes files
Same package: diffusers CVE-2024-2912 10.0 BentoML: RCE via insecure deserialization (CVSS 10)
Same attack type: Supply Chain CVE-2025-5120 10.0 smolagents: sandbox escape enables unauthenticated RCE
Same attack type: Supply Chain