Back to blog
IA & LLMsupply chaintechnique

Hugging Face Diffusers "FaceHugger": three flaws bypassing trust_remote_code in AI pipelines

Published on 2026-08-036 min readCleanIssue

> In short: Three high-severity security flaws in Hugging Face's Diffusers library — collectively named FaceHugger — bypass trust_remote_code, the safeguard designed to stop unreviewed code from running during custom pipeline loading. A crafted model repository can stealthily execute arbitrary code on any machine that loads it. Found by Zafran Labs researchers Gal Zaban and Ido Shani.

Why this matters to you

If you read our article on the Hugging Face breach, you know HF's dataset loaders are attack surface. FaceHugger extends the problem to the model-loading path: Diffusers is the Python library that loads state-of-the-art diffusion models (Stable Diffusion, FLUX, etc.) into production pipelines, CI/CD systems, and container images. A bypass of trust_remote_code means the guardrail that most teams rely on to safely load third-party models is, in three separate ways, defeatable.

For a SaaS vendor with AI features — chatbots, image generation, document processing — this is a direct supply-chain risk. If you pull model weights from HF Hub and load them with Diffusers, you are in the affected population.

The flaw class

trust_remote_code is the flag that controls whether Diffusers will execute Python code shipped inside a model repository (custom pipeline code). The intent: default to False, require explicit opt-in, and the user accepts the risk. FaceHugger demonstrates three ways to execute code *despite* the safeguard being disabled — meaning the flag gives a false sense of security.

The specifics matter less than the structural lesson: when a security control is a boolean flag on a data-loading path, the question is not *whether* it can be bypassed but *how many ways* exist to bypass it. Each new serialization format, each new loading hook, each new attribute resolver is a new candidate path.

What to do

  • Patch Diffusers to the fixed version.
  • Stop loading untrusted model repositories on production infrastructure. Load models in an isolated environment (container, sandbox, ephemeral VM), not on the same server that runs your application.
  • Pin model commits. Don't load model:latest from HF Hub — pin to a specific commit hash that you've reviewed. This prevents a repository from being updated with malicious code after your initial pull.
  • Scan model files before loading. Treat a model file like any other untrusted binary: scan it, inspect its structure, and run it in a sandbox before it touches production data.
  • Separate model storage from code execution. The ideal architecture loads weights as pure data tensors (.safetensors), not as Python pickle or custom code. If the model needs custom code to load, that code should be reviewed and vendored into your repository — not pulled from a remote repo at runtime.
  • The AI supply chain pattern

    FaceHugger follows the Hugging Face breach (dataset loaders) and the broader MCP/injection pattern. The AI supply chain — datasets, model weights, tokenizers, pipeline code — is rapidly becoming the most-targeted surface for SaaS products with AI features. The defense principle is the same one we apply to npm/PyPI: treat every remote artifact as untrusted, pin to reviewed versions, and execute in isolation. The difference is that the AI ecosystem has younger tooling and weaker defaults — which means the burden is on you, the SaaS vendor, to apply the discipline the ecosystem hasn't built in yet.

    Building HR, payroll, or recruiting software? CleanIssue performs security audits for HR SaaS in real-world conditions, no source code access needed. For a first read of your exposure, start with an external review of your application.

    Sources

    Written by CleanIssue
    Reviewed on 2026-08-03

    Related services

    If this topic maps to a real risk in your stack, these are the most relevant CleanIssue audits.

    Need an external review of your HR SaaS?

    Share your product, stack, and client context. We will come back with the right review scope.

    Discuss your audit