<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Cpe:2.3:a:huggingface:diffusers:*:*:*:*:*:python:*:* - CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/cpes/cpe2.3ahuggingfacediffuserspython/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata. Fed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Wed, 20 May 2026 15:32:30 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/cpes/cpe2.3ahuggingfacediffuserspython/feed.xml" rel="self" type="application/rss+xml"/><item><title>Diffusers TOCTOU Vulnerability Leads to Remote Code Execution</title><link>https://feed.craftedsignal.io/briefs/2026-05-diffusers-rce/</link><pubDate>Wed, 20 May 2026 15:32:30 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2026-05-diffusers-rce/</guid><description>A Time-of-Check Time-of-Use (TOCTOU) vulnerability in the `diffusers` package allows arbitrary code execution via a race condition when loading pipelines from the Hugging Face Hub, bypassing trust checks.</description><content:encoded><![CDATA[<p>A TOCTOU vulnerability exists in the <code>diffusers</code> package (versions prior to 0.38.0), a library used for diffusion models. The vulnerability resides within the <code>DiffusionPipeline.from_pretrained</code> function, which is responsible for loading pipelines from the Hugging Face Hub. This function has a <code>trust_remote_code</code> guard intended to prevent the execution of untrusted code from custom pipelines. However, a race condition between two HTTP calls (<code>hf_hub_download</code> and <code>snapshot_download</code>) allows an attacker to introduce malicious code into the repository between the calls, effectively bypassing the trust check and enabling remote code execution. This occurs because the vulnerability allows arbitrary code to be loaded through the custom pipeline flow from a Hub repo, even without explicitly passing <code>custom_pipeline</code> or <code>trust_remote_code</code> arguments.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An attacker creates a Hugging Face Hub repository with a <code>model_index.json</code> file containing a plain string <code>_class_name</code> value, indicating no custom pipeline code.</li>
<li>A user attempts to load the pipeline using <code>DiffusionPipeline.from_pretrained(&quot;attacker/repo&quot;)</code>.</li>
<li>The <code>hf_hub_download</code> function fetches the <code>model_index.json</code> file (commit A) and the trust check passes because no custom pipeline is detected.</li>
<li>Before the <code>snapshot_download</code> function is called, the attacker pushes a new commit (commit B) to the repository, modifying the <code>model_index.json</code> file to use a list <code>_class_name</code> and adding a malicious <code>pipeline.py</code> file.</li>
<li>The <code>snapshot_download</code> function fetches commit B, including the malicious <code>pipeline.py</code> file.</li>
<li>The <code>_resolve_custom_pipeline_and_cls</code> function reads the updated <code>model_index.json</code> and resolves the custom pipeline to the local path of the <code>pipeline.py</code> file.</li>
<li>The <code>_get_pipeline_class</code> function imports the malicious <code>pipeline.py</code> file without any further trust checks.</li>
<li>The malicious code within <code>pipeline.py</code> is executed, resulting in arbitrary code execution on the user's machine.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation of this vulnerability allows an attacker to execute arbitrary code on the victim's machine. The vulnerability is a silent RCE meaning that the from_pretrained call succeeds and returns a fully functional pipeline even when malicious code has been injected. This could lead to data exfiltration, system compromise, or other malicious activities. The impact is significant as it undermines the trust mechanisms designed to protect users from running untrusted code.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade to <code>diffusers</code> version 0.38.0 or later to patch the vulnerability.</li>
<li>When using <code>DiffusionPipeline.from_pretrained</code>, pin the <code>revision</code> argument to a specific commit hash to avoid race conditions, as described in the overview.</li>
<li>Deploy the Sigma rule &quot;Detect Diffusers from_pretrained with trust_remote_code&quot; to detect potential exploitation attempts by identifying calls to <code>DiffusionPipeline.from_pretrained</code> without explicit trust settings.</li>
<li>Monitor network connections for unexpected outbound traffic originating from processes associated with the <code>diffusers</code> library, using the network connection Sigma rule in this brief to identify potential command and control activity.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>toctou</category><category>rce</category><category>huggingface</category></item></channel></rss>