Research review / security

Malicious GGUF Models on Hugging Face Hid a Trojan After the Last Tensor and Armed the Chat Template Later

A November 27 report from the security project Malspark says a scan of 3.27 million public Hugging Face model repositories found five malicious GGUF models with 2,428 downloads. One campaign appended a Windows remote access trojan after the model weights, then rewrote the chat template so the model tells users to run the line that unpacks it.

By Sandeep Belgavi · Published 2026-11-29

The Malspark report is dated November 27, 2026. It says: "A scan of all 3273389 public Hugging Face model repositories on 26 November 2026 found 5 malicious GGUF models with 2428 downloads as of 27 November." It adds that "Hugging Face counts downloads, not people, so the number of affected users is lower or equal." The report reached 310 points on Hacker News on November 28.

Two hiding places in one file

  • The chat template. Every GGUF carries a Jinja2 template under tokenizer.chat_template. C++ runtimes render it in a restricted engine, so classic template injection does not reach the operating system. The attacks "do not need to escape that engine. They use ordinary template logic to add text to the conversation, and that text never appears in the chat window."
  • Bytes after the last tensor. The header defines where model data ends. "Anything after that point is never read, so it does not change how the model loads or behaves, and no runtime warns about it. An attacker can append a whole executable there." The report notes that Safetensors files do not allow this, because the loader rejects a file whose tensors do not fill it exactly.

The two campaigns

The larger one, which the report calls Mir2k, "uploaded two uncensored GGUF models with a Windows remote access trojan named ollie hidden at the end of each file, and on 26 November rewrote both templates so the model asks the user to run the line that unpacks it." One copy hid the payload behind about half a megabyte of filler, "so a scanner that reads only the last few kilobytes sees nothing." The second, timdedid, used a trigger phrase to make the template insert a fake "[SYSTEM DIRECTIVE]" that orders an agent with shell access to download and run a script.

The figures come from the vendor's own scan with its own open-source tool, gguf-radar, which the report says detects these patterns "without running anything" and rebuilds a clean file with unchanged weights. Independent confirmation was not available at the time of writing.

What this changes for local inference

Analysis: the attack splits the payload from the trigger, and that is the clever part. The weights behave normally, so evaluation finds nothing. The executable is inert because nothing reads it. The danger appears only when a template, which most users never inspect, adds an instruction. For agent setups with shell access, the template is effectively a hidden system prompt written by a stranger. Two checks follow: compare the declared end of tensor data with the file size, and diff the embedded chat template against the base model's published one.

Original exercise, not executed: Jenya keeps a model intake step for the Belgavi's Book Store offline catalogue assistant. Every downloaded GGUF is checked for trailing bytes past the last tensor and for any template that differs from the upstream model's. A mismatch, like the one logged in CASE-3961, blocks the file until a person has read the template line by line.

Sources accessed November 29, 2026. Views are my own and do not represent any employer, past or present.

Sources and evidence

Malspark's November 27 scan of 3.27 million Hugging Face repositories reports five malicious GGUF models with 2,428 downloads. One campaign appended a trojan after the last tensor and later rewrote the chat template to have the model print the unpack command. Check trailing bytes and diff templates before loading.