CVE-2026-45804 is a high-severity (CVSS 7.5) CWE-367 vulnerability in diffusers. A fix is available for diffusers — see the affected versions and patch details below.
Diffusers: TOCTOU Trust Remote Code Bypass
Exploitation Status
Proof-of-concept exploit code exists
- CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
- A successful exploit gives an attacker total control of the affected component, not partial access.
Exploitation and automatability from CISA’s SSVC triage for CVE-2026-45804.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
CVE-2026-45804 by exploitation likelihood (EPSS) against impact (CVSS). Outside the shaded patch-first corner.
Where this sits among everything scored
Of 381,682 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Counts from FIRST.org, log-scaled.
Real-World Exposure
diffusersReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects PyPI packages — download data is not available via public APIs for these ecosystems.
Description
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:
# 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:
# 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:
# 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:
# 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:
# 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():
# 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:
{
"_class_name": "FluxPipeline",
"_diffusers_version": "0.31.0"
}
Commit B - model_index.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
- Create a Hub repo with commit A’s
model_index.json(plain string_class_name). - Run
DiffusionPipeline.from_pretrained("attacker/repo")with a breakpoint set atpipeline_utils.py:1778(thesnapshot_downloadcall). This is for the window to be large enough to manually respond to it. - When execution pauses at the breakpoint, push commit B: update
model_index.jsonto use a list_class_nameand addpipeline.py. - Resume execution.
snapshot_downloadfetches commit B;/tmp/pwnedis written during the subsequent_get_pipeline_classcall.
Constraints
- Does not apply when
revisionis 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 reachingsnapshot_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.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐍PyPI | diffusers | all versions | 0.38.0pip install --upgrade 'diffusers==0.38.0' |
Affected Products
diffusershuggingfaceDetection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for diffusers, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update diffusers to 0.38.0 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2026-45804 is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
Fixing This On Your OS
If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.
This Important flaw in Diffusers, as used in Red Hat AI Inference Server, Red Hat OpenShift AI, and Red Hat Enterprise Linux AI, allows for arbitrary code execution. A remote attacker could exploit this by convincing a user to load a specially crafted model from a malicious Hub repository, bypassing the…
| Product | Fixed in | Advisory |
|---|---|---|
| Red Hat AI Inference Server 3.4 | rhaii/vllm-cpu-rhel9:1789681128 | RHSA-2026:69466 |
| Red Hat AI Inference Server 3.4 | rhaii/vllm-cuda-rhel9:1789681126 | RHSA-2026:69467 |
| Red Hat AI Inference Server 3.4 | rhaii/vllm-cpu-rhel9:1790075793 | RHSA-2026:70965 |
| Red Hat AI Inference Server 3.4 | rhaii/vllm-cuda-rhel9:1790090131 | RHSA-2026:70979 |
| Red Hat OpenShift AI 3.4 | rhoai/odh-th06-cuda130-torch210-py312-rhel9:1787077779 | RHSA-2026:60520 |
Frequently Asked Questions
Is CVE-2026-45804 in your dependencies?
Find it across PyPI, including transitive dependencies.