Diffusers trust_remote_code Bypass Leads to Remote Code Execution
A `trust_remote_code` bypass vulnerability exists in the `DiffusionPipeline.from_pretrained` function of the diffusers library, allowing for arbitrary remote code execution when using `custom_pipeline` and local custom components, even when `trust_remote_code=False` is set.
CVE search metadata
CVE search record: CVE-2026-44513. KEV: no. Product: diffusers (< 0.38.0). Brief: Diffusers trust_remote_code Bypass Leads to Remote Code Execution. Brief link: https://feed.craftedsignal.io/briefs/2026-05-07-diffusers-rce/
Triage facts
Revision 2- Applicability
- diffusers (< 0.38.0)
- Evidence
- Unknown
- Severity
- High
- Sources
- 5 public sources
- Freshness
- Revision 2May 7, 05:31 UTC
- Detection
- 3 rules
- Vulnerabilities
- 1 CVE
Revision history 1 entry · Revision 2
- Revision 2
Repaired a legacy canonical identity collision
Changed: slug
A trust_remote_code bypass in DiffusionPipeline.from_pretrained allows arbitrary remote code execution despite the user passing trust_remote_code=False (or omitting it, which is the default). The vulnerability, impacting diffusers versions before 0.38.0, stems from the trust_remote_code gate being implemented inside DiffusionPipeline.download() rather than at the actual dynamic-module load site. This allows for bypasses using cross-repo custom_pipeline, local snapshots with Hub custom_pipeline, and local snapshots with custom components. Successful exploitation results in silent remote code execution on the victim's machine, affecting anyone calling DiffusionPipeline.from_pretrained with custom pipelines. The vulnerability is tracked as CVE-2026-44513.
Attack Chain
- A user calls
DiffusionPipeline.from_pretrainedwith a maliciouscustom_pipelinepointing to an attacker's repository (repoB) while settingtrust_remote_code=False. - The
DiffusionPipeline.download()function is invoked, but the trust check is performed against the primary repository (repoA) instead of the attacker's repository (repoB). - Alternatively, the user calls
DiffusionPipeline.from_pretrainedwith a local snapshot directory and a maliciouscustom_pipelinepointing to an attacker's repository. The local-path branch bypasses thedownload()function, thus skipping thetrust_remote_codegate. - As another alternative, the user calls
DiffusionPipeline.from_pretrainedwith a local snapshot directory containing custom component files (e.g.,unet/my_unet_model.py) referenced frommodel_index.json. The local path bypassesdownload(). - The attacker's
pipeline.pyor custom component files are loaded as dynamic modules. - The attacker's code is executed, granting the attacker arbitrary code execution privileges on the victim's machine.
- The attacker can then perform various malicious activities, such as installing malware, stealing data, or compromising the system.
Impact
Successful exploitation of this vulnerability allows for arbitrary remote code execution on the victim's machine. This could lead to complete system compromise, data theft, or other malicious activities. All users of diffusers versions before 0.38.0 who call DiffusionPipeline.from_pretrained with custom pipelines are potentially affected.
Recommendation
- Upgrade to diffusers version 0.38.0 or later to remediate the vulnerability. The fix moves the
trust_remote_codegate toget_cached_module_fileinsrc/diffusers/utils/dynamic_modules_utils.py(https://github.com/huggingface/diffusers/pull/13448). - If upgrading is not immediately possible, only call
from_pretrainedwithpretrained_model_name_or_path,custom_pipeline, and local snapshot directories from fully trusted sources that have been audited. - If a local snapshot is used, inspect it for unexpected
*.pyfiles, especially under component subdirectories (unet/,scheduler/, etc.) and at the snapshot root before callingfrom_pretrained. - Deploy the Sigma rule to detect execution of unexpected python files.
Detection coverage 3
Detect Python Execution from Suspicious Paths
highDetects the execution of Python files from world-writable directories, which may indicate a trust_remote_code bypass attack
Detect Suspicious File Creation in Diffusers Cache Directories
mediumDetects the creation of suspicious files (e.g., *.py) in Diffusers cache directories, indicating a potential `trust_remote_code` bypass.
Detect Diffusers Loading Remote Pipelines with Trust Disabled
highDetects the loading of remote custom pipelines in Diffusers while trust_remote_code is disabled or not explicitly enabled. This can indicate a potential vulnerability exploitation attempt.
Detection queries are available on the platform. Get full rules →