Skip to main content

Malicious GGUF Models on Hugging Face Hid Malware in Chat Templates

Security researcher Malspark scanned every public Hugging Face model repository on 26 November and found five malicious GGUF models with 2,428 downloads. Two hid a Windows trojan after the final tensor and used the chat template to make the model print a PowerShell command that unpacks it. Three told tool-using agents to fetch a script. Hugging Face has since disabled all five.

On this page

What the Hugging Face scan found

On 26 November, the security researcher behind Malspark scanned all 3,273,389 public model repositories on Hugging Face, including 226,310 GGUF repositories, using HTTP range requests so that no model had to be fully downloaded. The scan parsed 572,184 chat templates without running them. It turned up five malicious GGUF models from two accounts, Mir2k and timdedid, with a combined 2,428 downloads by 27 November.

The bait was familiar to anyone who runs models locally. Mir2k posted an "abliterated" Huihui Qwen3.5 9B build and an "uncensored" Inkling 2 Mini, uploaded on 22 and 24 November. The timdedid account posted three "cyber uncensored" Qwen3 builds aimed at security users, plus a copy on Ollama's model library. When we checked the Hugging Face Hub API on 28 November, all five repositories were flagged as disabled. The Ollama library page for the timdedid copy still loaded, though we did not check whether it carries the same template.

How the malware hid inside the model file

A GGUF file is mostly a header and tensors, and runtimes such as llama.cpp and LM Studio read only the byte ranges the header points to. Anything appended after the last tensor is ignored and no runtime warns about it, so the file still loads and chats normally. Mir2k used that dead space to carry a Windows program of about 11.5 MB, stored plain in one model and compressed in the other.

The trigger lived in the chat template, the small Jinja program in the file's metadata that formats every conversation before the model reads it. On 26 November, both Mir2k templates were edited to add a hidden instruction telling the model to begin every reply with one line: a PowerShell command that finds the largest GGUF file in the user's profile, reads the trailing bytes and writes them out as an executable in the temp folder. Anyone who pasted that "setup" line into a terminal ran the payload. Downloads before 26 November held the payload but not the trigger.

Malspark describes the payload as a remote access trojan that bundles its own Tor client, checks for virtual machines and sandboxes, persists through a scheduled task, and steals saved browser passwords and crypto wallet data. It also logs keystrokes, captures screens and the webcam, and mines Monero when the machine is idle.

A template aimed at AI agents

The timdedid models went after agents rather than people. Their template stays quiet until the latest message contains "What is", then inserts a fake system directive telling any agent with a PowerShell tool to download a script from a WordPress site and run it hidden. Malspark could not recover that second-stage script. The attack needs no exploit: it relies on an agent obeying text it believes came from its own system prompt.

Poisoned chat templates are not a new idea. Pillar Security described inference-level template backdoors in GGUF files in July 2025. What is new here is finding them in the wild, paired with a payload that standard antivirus and tail-of-file checks missed.

How to protect a local model setup

  • Treat any command a model tells you to run as untrusted, however helpful it sounds.
  • For agents with shell or PowerShell tools, replace the embedded template with one you have read: llama.cpp accepts --chat-template-file, and an Ollama Modelfile can set its own TEMPLATE.
  • Be wary of "uncensored" or "abliterated" reuploads from new accounts, especially of freshly launched models.
  • Scan files before use. Malspark has released gguf-radar, an MIT-licensed tool that checks GGUF files and Hugging Face repos for appended data and poisoned templates without running them, and can write a cleaned copy.

The researcher also asks hubs and runtimes to reject GGUF files with bytes after the last tensor and to scan templates for hidden directives. Until that happens, private local inference still depends on trusting what you download.

CuriousLM runs supported AI models locally on your device. Try CuriousLM.