Five Trojanized GGUF Models Found on Hugging Face: Anatomy of a Supply Chain Attack Behind 2,428 Downloads

A security researcher’s automated scan of all 3,273,389 public model repositories on Hugging Face found five GGUF-format repositories carrying malicious co

On November 26, 2026, security researcher Root0ne completed an automated scan of all 3,273,389 public model repositories on Hugging Face. The results showed that five GGUF-format model repositories carried malicious code, and as of the 27th, the cumulative downloads of these five repositories had reached 2,428.

The technical core of this attack was the systematic exploitation of structural weaknesses in the GGUF file format—not tampering with the model weights themselves.

Two Attack Paths: Template Poisoning and Payloads Hidden After Tensors

The structure of a GGUF file follows a fixed order: file header, metadata table, tensor index, alignment padding, and finally the model weights. When loading, inference engines such as llama.cpp and LM Studio strictly read data according to the byte ranges specified in the file header and ignore all trailing bytes beyond those ranges.

According to a research report from malspark.com, an attacker codenamed “Mir2k” appended an 11.47 MB Windows remote access trojan to the end of two GGUF files disguised as popular models (Inkling-2-Mini and Huihui-Qwen3.5-9B). The trojan also embedded a Tor client to hide its communication channel. The models themselves run completely normally, and the inference engine detects no anomaly.

Hiding an executable alone was not enough. Mir2k then rewrote the chat templates of these two models on November 26, embedding logic that induces users to execute it: in each conversation, the model mixes PowerShell commands that unpack the trojan into its replies, inducing users or AI agents to run them voluntarily. This is the second attack path—chat template poisoning.

GGUF chat templates are stored as Jinja2 programs in the metadata field tokenizer.chat_template. Before each inference, the runtime formats the full conversation history through this template and passes it to the model. By modifying this Jinja2 code, an attacker can inject arbitrary instructions into the context at a layer invisible to the user, or splice malicious commands directly into the model output. Three repositories controlled by another attacker, “timdedid,” specifically targeted AI agent workflows with terminal access, using template hijacking to make agents actively execute shell commands.

GGUF’s Structural Weakness Was Already Addressed in Safetensors

The problem exposed by this attack is not a review oversight on the Hugging Face platform, but GGUF’s inherent design-level tolerance for trailing data. By contrast, the Safetensors format explicitly requires rejecting any file containing undeclared trailing bytes—the same attack technique would directly trigger a load failure under the Safetensors ecosystem.

This difference has non-negligible practical significance in the current local AI inference ecosystem. Thanks to its efficient quantization support and the widespread adoption of llama.cpp, GGUF has become the de facto standard format for locally deployed LLMs. Many users download and run models with one click through tools such as LM Studio and Ollama; these tools automatically load and prepare embedded templates for execution—including malicious templates—without any warning.

The malicious payload discovered this time is fully functional: according to AGI Hunt, the RAT can steal passwords stored in the Chrome, Edge, and Brave browsers, extract MetaMask and Phantom cryptocurrency wallet data, and mine Monero when the target machine is idle.

The Trust Deficit of Open-Source Distribution Platforms

As the world’s largest AI model hosting platform, Hugging Face’s openness is its core value and also the precondition that made this attack possible. Anyone can upload models, and the platform does not perform structural integrity verification of GGUF file contents. This is not a new problem in the software ecosystem: package management ecosystems such as npm and PyPI have similar histories of supply chain attacks. But the particularity of AI models is that users’ security expectations for “downloading a model file” are far lower than their vigilance toward “installing a software package.”

The scale of this incident—five repositories and 2,428 downloads—may seem insignificant against Hugging Face’s millions of repositories, but this logic itself is the problem: precisely because the platform is massive and content quality is uneven, the signal-to-noise ratio of an individual attack is extremely low, and routine monitoring has almost no way to detect it. Root0ne’s discovery of these five repositories relied on static parsing of 572,184 chat templates—a research-driven proactive scan, not the platform’s routine defense mechanism.

Defensive Tool Exists, but Not in the Default Workflow

While publishing the research, Root0ne also open-sourced a detection tool called gguf-radar under the MIT license. The tool can complete static analysis of GGUF files within seconds without running the model: it parses suspicious instructions in chat templates, detects hidden bytes after tensors, and rebuilds a clean file while preserving weight integrity.

But the problem is that it is not part of the default download workflow of any mainstream inference tool. When users of LM Studio and Ollama download models, they do not automatically pass through gguf-radar detection.

Assessment

The core lesson of this incident is that the attacker chose the path of least effort: do not tamper with model capabilities, do not trigger any inference anomaly, just hide an executable at the end of the file, then use a snippet of Jinja2 code to make the model speak for them. The entire attack chain costs very little, is extremely difficult to detect, and relies entirely on the target user’s default assumption that “a model file equals safe.”

The next security inflection point for the open-source AI ecosystem is not a better vulnerability scanner, but redefining model files from “trusted weight data” to “untrusted input requiring isolated execution.” Until this redefinition is complete, every user who downloads a GGUF file from a public platform should manually run a gguf-radar scan once before running it.