CVE-2026-44513: Diffusers: `trust_remote_code` bypass via `custom_pipeline` and local custom components
Impact
A trustremotecode bypass in DiffusionPipeline.frompretrained allows arbitrary remote code execution despite the user passing trustremotecode=False (or omitting it, which is the default). The vulnerability has three variants, all sharing the same root cause — the trustremotecode gate was implemented inside DiffusionPipeline.download() rather than at the actual dynamic-module load site, so any code path that bypassed or short-circuited download() also bypassed the security check:
1. Cross-repo custompipeline. DiffusionPipeline.frompretrained('repoA', custompipeline='attacker/repoB', trustremotecode=False) — the gate evaluated against repoA's file list rather than repoB's, so repoB's pipeline.py was loaded and executed. 2. Local snapshot + Hub custompipeline. DiffusionPipeline.frompretrained('/local/snapshot', custompipeline='attacker/repoB', trustremotecode=False) — the local-path branch never invoked download(), so the gate was never reached and remote code from repoB executed. 3. Local snapshot with custom components. DiffusionPipeline.frompretrained('/local/snapshot', trustremotecode=False) where the snapshot contains custom component files (e.g. unet/myunetmodel.py) referenced from modelindex.json — same root cause; the local path skipped download() and custom component code executed.
Silent remote code execution on the victim's machine. Anyone calling DiffusionPipeline.frompretrained with custom pipelines is impacted.
Patches
Yes. Fixed in diffusers 0.38.0 via PR #13448. All users on versions < 0.38.0 should upgrade:
bash pip install --upgrade "diffusers>=0.38.0"
The fix moves the trustremotecode gate out of DiffusionPipeline.download() and into getcachedmodulefile in src/diffusers/utils/dynamicmodulesutils.py, which is the actual chokepoint for every dynamic module load (local, Hub, or community mirror). All three variants now raise ValueError instead of executing untrusted code.
Workarounds
If upgrading immediately is not possible:
- Only call frompretrained with pretrainedmodelnameorpath, custompipeline, and local snapshot directories from fully trusted sources that have been audited. - Do not pass custompipeline= pointing at a Hub repository different from the primary pretrainedmodelnameorpath before reading its pipeline.py. - Before calling frompretrained on a local snapshot, inspect the snapshot for unexpected .py files, especially under component subdirectories (unet/, scheduler/, etc.) and at the snapshot root.
These are mitigations, not fixes — the only complete remediation is upgrading to 0.38.0.
Resources
- Fix: https://github.com/huggingface/diffusers/pull/13448 - Original issue: https://github.com/huggingface/diffusers/issues/13446 - Release notes: https://github.com/huggingface/diffusers/releases/tag/v0.38.0 - CWE-94: https://cwe.mitre.org/data/definitions/94.html
Other sources
Diffusers is the a library for pretrained diffusion models. Prior to 0.38.0, a trustremotecode bypass in DiffusionPipeline.frompretrained allows arbitrary remote code execution despite the user passing trustremotecode=False (or omitting it, which is the default). The vulnerability has three variants, all sharing the same root cause — the trustremotecode gate was implemented inside DiffusionPipeline.download() rather than at the actual dynamic-module load site, so any code path that bypassed or short-circuited download() also bypassed the security check. DiffusionPipeline.frompretrained('repoA', custompipeline='attacker/repoB', trustremotecode=False) — the gate evaluated against repoA's file list rather than repoB's, so repoB's pipeline.py was loaded and executed. DiffusionPipeline.frompretrained('/local/snapshot', custompipeline='attacker/repoB', trustremotecode=False) — the local-path branch never invoked download(), so the gate was never reached and remote code from repoB executed. DiffusionPipeline.frompretrained('/local/snapshot', trustremotecode=False) where the snapshot contains custom component files (e.g. unet/myunetmodel.py) referenced from modelindex.json — same root cause; the local path skipped download() and custom component code executed. This vulnerability is fixed in 0.38.0.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/diffusersto a version that resolves this vulnerability.Fixed in 0.38.0 - Upgrade
Upgrade
diffusersto a version that resolves this vulnerability.Fixed in 0.38.0Patch PR #13448 - Configuration
Before calling DiffusionPipeline.from_pretrained, do not set custom_pipeline to a Hub repository different from the primary pretrained_model_name_or_path (this prevents loading attacker-controlled pipeline.py).
DiffusionPipeline.from_pretrained custom_pipeline = Do not pass custom_pipeline pointing at a Hub repository different from the primary pretrained_model_name_or_path before reading its pipeline.py - Configuration
Before calling DiffusionPipeline.from_pretrained on a local snapshot, inspect the snapshot for unexpected *.py files, especially under component subdirectories (e.g., unet/, scheduler/) and at the snapshot root.
DiffusionPipeline.from_pretrained (local snapshot) snapshot contents validation = Inspect for unexpected *.py files under component subdirectories and at the snapshot root - Compensating control
Only call DiffusionPipeline.from_pretrained with pretrained_model_name_or_path, custom_pipeline, and local snapshot directories from fully trusted sources that have been audited.
Event History
Frequently Asked Questions
What is the severity of CVE-2026-44513?
CVE-2026-44513 has a critical severity level due to its potential for arbitrary remote code execution.
How do I fix CVE-2026-44513?
To fix CVE-2026-44513, update the 'diffusers' package to version 0.38.1 or higher.
What is the impact of CVE-2026-44513?
CVE-2026-44513 allows attackers to execute arbitrary code remotely despite the user setting 'trust_remote_code=False'.
Which versions of the 'diffusers' package are affected by CVE-2026-44513?
CVE-2026-44513 affects the 'diffusers' package versions up to and including 0.38.0.
What variants exist for CVE-2026-44513?
CVE-2026-44513 has three variants, all stemming from the same underlying issue with remote code execution.