AI Security AI安全 22h ago Updated 15h ago 更新于 15小时前 53

Hugging Face Diffusers Flaws Could Let Model Repositories Execute Arbitrary Code Hugging Face Diffusers漏洞可能使模型仓库执行任意代码

Three high-severity vulnerabilities (CVE-2026-44827, CVE-2026-45804, CVE-2026-44513) in Hugging Face Diffusers allow arbitrary code execution by bypassing the trust_remote_code safeguard All flaws stem from a Time-of-Check to Time-of-Use (TOCTOU) race condition where the security gate runs only against the first of two non-atomic HTTP requests during model loading The vulnerabilities were patched in Diffusers version 0.38.0 released in early May 2026 Any user invoking DiffusionPipeline.from_pret Hugging Face Diffusers库存在三个高危安全漏洞(统称为"FaceHugger"),可绕过trust_remote_code安全机制执行任意代码 漏洞根因是Time-of-Check to Time-of-Use (TOCTOU)竞态条件,信任检查仅在第一阶段执行 三个CVE分别为:CVE-2026-44827(CVSS 8.8)、CVE-2026-45804(CVSS 7.5)、CVE-2026-44513(CVSS 8.8) 漏洞已在Diffusers 0.38.0版本修复,影响所有使用custom pipelines调用from_pretrained的用户 AI模型仓库

82
Hot 热度
70
Quality 质量
75
Impact 影响力

Analysis 深度分析

TL;DR

  • Three high-severity vulnerabilities (CVE-2026-44827, CVE-2026-45804, CVE-2026-44513) in Hugging Face Diffusers allow arbitrary code execution by bypassing the trust_remote_code safeguard
  • All flaws stem from a Time-of-Check to Time-of-Use (TOCTOU) race condition where the security gate runs only against the first of two non-atomic HTTP requests during model loading
  • The vulnerabilities were patched in Diffusers version 0.38.0 released in early May 2026
  • Any user invoking DiffusionPipeline.from_pretrained with custom pipelines is impacted, posing significant AI supply chain risks
  • Workarounds include auditing trusted sources, inspecting snapshots for unexpected .py files, and avoiding cross-repository custom_pipeline references

Why It Matters

This disclosure highlights a critical gap in AI supply chain security: model repositories are often treated as passive data when they can silently execute arbitrary code during routine loading operations. As Hugging Face becomes the de facto hub for AI model distribution in enterprise environments, vulnerabilities in widely adopted libraries like Diffusers (8.1+ million downloads in July 2026) can grant attackers extensive access through production pipelines, CI/CD systems, and container images.

Technical Details

  • CVE-2026-44827 (CVSS 8.8): Code injection via a crafted pipeline named "None.py" in the custom_pipeline flow, bypassing trust_remote_code=False by exploiting the TOCTOU gap between the two HTTP download phases.
  • CVE-2026-45804 (CVSS 7.5): Race condition allowing an attacker to modify the repository configuration between the hf_hub_download and snapshot_download HTTP calls, injecting arbitrary code into the loading process.
  • CVE-2026-44513 (CVSS 8.8): Another code injection variant through the custom_pipeline flow that similarly circumvents the trust_remote_code check due to the same root cause.
  • Root Cause: The trust_remote_code security gate operates only during the first phase of model loading, while the actual code execution occurs in a second, unmonitored phase—creating a classic TOCTOU vulnerability where the loader can see custom code that the initial trust check did not evaluate.
  • Affected Scope: Any invocation of DiffusionPipeline.from_pretrained with custom pipelines; patched in Diffusers 0.38.0 (May 2026).

Industry Insight

  • Enterprises relying on Hugging Face must treat all model repositories as untrusted code sources by default, implementing strict scanning and auditing of configuration files, loaders, and custom pipeline code before integration into production pipelines.
  • Security teams should enforce the recommended workarounds immediately for any systems unable to patch to Diffusers 0.38.0, including snapshot inspection for unexpected .py files in component subdirectories and restricting custom_pipeline references to fully audited repositories.
  • This incident underscores the broader need for AI supply chain security frameworks that address the unique risk of configuration-to-execution transitions in model loading workflows, prompting organizations to adopt zero-trust principles for AI artifact ingestion.

TL;DR

  • Hugging Face Diffusers库存在三个高危安全漏洞(统称为"FaceHugger"),可绕过trust_remote_code安全机制执行任意代码
  • 漏洞根因是Time-of-Check to Time-of-Use (TOCTOU)竞态条件,信任检查仅在第一阶段执行
  • 三个CVE分别为:CVE-2026-44827(CVSS 8.8)、CVE-2026-45804(CVSS 7.5)、CVE-2026-44513(CVSS 8.8)
  • 漏洞已在Diffusers 0.38.0版本修复,影响所有使用custom pipelines调用from_pretrained的用户
  • AI模型仓库正成为供应链攻击新目标,配置文件和自定义代码可将被动数据转化为可执行代码

为什么值得看

本文揭示了AI供应链安全的新威胁面,表明Hugging Face作为"AI时代的GitHub"正面临严峻的安全挑战。对于AI从业者而言,这提醒我们需重新审视模型仓库的信任边界,将AI artifacts视为潜在的可执行代码而非被动数据。

技术解析

  • 漏洞机制:三个漏洞均基于TOCTOU竞态条件,模型下载被设计为两个非原子的HTTP请求(hf_hub_download和snapshot_download),而trust_remote_code安全检查仅在第一阶段执行,攻击者可在两次请求之间修改配置实现代码注入。

  • CVE-2026-44827:通过构造名为"None.py"的pipeline文件,在custom_pipeline流程中绕过trust_remote_code=False限制,实现任意代码加载(CVSS 8.8)。

  • CVE-2026-45804:利用竞态条件,在hf_hub_download和snapshot_download两个HTTP调用之间修改仓库配置,引入恶意代码执行(CVSS 7.5)。

  • 缓解建议:仅从完全可信且经过审计的源调用from_pretrained;避免在读取pipeline.py之前将custom_pipeline指向不同的Hub仓库;在加载本地快照前检查是否有异常的*.py文件,特别是component子目录(unet/, scheduler/等)。

行业启示

  • AI供应链安全需重新定义信任模型:企业应将Hugging Face等平台的模型仓库视为不可信代码源,建立类似软件供应链的SBOM(软件物料清单)和签名验证机制,而非默认信任模型配置。

  • 安全开发实践需前置到AI项目:CI/CD管道和容器镜像中嵌入的Diffusers库成为攻击入口,建议将AI组件纳入现有的应用安全扫描和依赖审计流程,定期更新到安全版本。

  • 行业趋势:AI安全将成为企业级采用的关键门槛:随着AI在企业的普及,类似FaceHugger的漏洞将推动建立AI模型仓库的安全认证标准,建议组织制定内部AI资产安全策略和应急响应预案。

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

Security 安全 Open Source 开源 LLM 大模型