Ai Engineering 7 min read

Five poisoned GGUF models on Hugging Face used chat templates to drop a Tor RAT and hijack PowerShell agents

Malspark scanned all 3.27 million public Hugging Face model repos and found five GGUF files whose Jinja chat templates tricked users and agents into running malware hidden after the weights. Hugging Face has since disabled all five, after about 2,800 downloads.

On November 27, 2026, the security researcher behind Malspark published a scan of every public model repository on Hugging Face: 3,273,389 repos, checked on November 26 without running a single model. It found five GGUF files from two accounts that were built to infect the people who ran them. None of them hid code in the weights. The attack lived in the chat template, the small Jinja2 program inside every GGUF file that formats each conversation before the model sees it, and in bytes tacked on after the end of the weights, where model loaders never look.

The five repos had about 2,428 downloads when the post went up. When we checked the Hugging Face API on November 28, the counts had risen to roughly 2,800 and all five repos were marked disabled, so their files can no longer be downloaded. Hugging Face has not published a statement, and download counts are not unique users, so the number of infected machines is unknown.

This matters for anyone running local models. GGUF is the default format for llama.cpp, Ollama, LM Studio and most desktop runtimes, and people routinely pull “uncensored” or “abliterated” re-uploads from accounts they know nothing about. The usual advice (“GGUF can’t run code, unlike pickle files”) is true at the file-format level and beside the point here.

How the attack works without code execution

Earlier research on poisoned templates focused on two ideas. One is server-side template injection: a Jinja payload that escapes the template sandbox and runs Python, which JFrog documented for unsandboxed Python loaders. The other, from Pillar Security in July 2025 and a 2026 paper that validated template backdoors across 18 models and four inference engines, is that a template can silently add instructions to every prompt.

The attackers Malspark found used the second idea, because the C++ runtimes most people use implement a restricted Jinja engine that classic escape payloads cannot get out of. Ordinary template logic is enough: the template inserts a system message the user never sees, and the model obediently follows it. The model becomes the delivery mechanism.

The second trick is specific to GGUF. A GGUF header and tensor table define exactly where the model data ends. Anything after that offset is ignored by loaders, so an attacker can append an entire executable and the model still loads and works normally. Malspark notes that safetensors refuses files with trailing data, so the same trick does not transfer.

Campaign one: Mir2k and the “ollie” RAT

The account Mir2k appeared on November 22 and created 14 repos that day, 12 of them empty placeholders named for releases people were waiting for, such as Qwen4-27B, DeepSeek-V4 and gemma-4-27b. Two repos held real models:

  • Mir2k/Huihui-Qwen3.5-9B-abliterated-GGUF, uploaded November 22, about 1,700 downloads by November 28.
  • Mir2k/Inkling-2-Mini-Uncensored-GGUF, uploaded November 24, about 570 downloads. It traded on the attention around Thinking Machines’ Inkling 2 Mini open-weights release four days earlier.

Both files carried the same Windows program after the weights (compressed with raw Deflate in the Inkling copy) but shipped with clean templates at first. On the morning of November 26 both templates were replaced within about an hour. The new version added a system message, written in French, telling the model to start every reply with one PowerShell line. That line finds the largest .gguf file on disk, reads a fixed byte range from its end (the last 4.2MB for Inkling, an 11.47MB slice for the Huihui file) and writes it to %TEMP%\d.exe. The first version looked only in the Downloads folder; nine hours later the attacker pushed a second update that searched the whole user profile. A user who pasted or auto-ran the model’s “helpful” first line would launch the payload.

The payload, which Malspark calls ollie, is an 11.47MB Windows x64 binary, most of it an embedded copy of Tor 0.4.9.16 used for command and control over an onion service with ChaCha20-encrypted sessions. It checks for VirtualBox, VMware and Sandboxie and exits if it finds them, persists through a scheduled task that runs every 10 minutes plus two watchdog processes, and steals saved passwords from Chrome, Edge and Brave (except Chrome’s newer app-bound entries), targets the Phantom and MetaMask wallet extensions, logs keystrokes, grabs the clipboard, screenshots and webcam, and mines Monero when the machine is idle. Its UAC bypass via fodhelper.exe fails because the file paths were compiled without backslashes, a sign of rushed work rather than a professional crew.

Campaign two: timdedid and agent hijacking

The second account, timdedid, published three byte-identical copies of a 1.7B Qwen3 model on November 21 and 22, pitched at security users as “cyber uncensored” models, plus an Ollama mirror. Together they drew about 520 downloads by November 28.

This template targets agents rather than people. When the latest user message contains the phrase What is, it injects a [SYSTEM DIRECTIVE] telling any agent that has a powershell tool to download a script from a WordPress site into C:\Windows\Temp\payload.ps1 and run it hidden. A person chatting with the model would see nothing unusual; an agent framework that hands a local model shell access would execute the command on the first ordinary question. The README even advises users not to replace the embedded template. Malspark could not recover the second-stage script, and reputation services had no record of the download URL.

This is the more worrying pattern. Most agent setups treat the model as the trusted decision-maker and the tools as the dangerous part. Here the model weights are fine and the tool permissions are normal; the instruction comes from a file most users never open.

What to check and what to watch

Malspark released gguf-radar, an MIT-licensed scanner that inspects GGUF headers, trailing data and chat templates without running the model. For Hugging Face repos it uses HTTP range requests, so it checks a large model in seconds, and it can rebuild a file with the original weights and a clean template. The post also publishes YARA rules and IOCs for both campaigns, and describes hiding places it has only demonstrated in the lab: oversized padding in general.alignment, a GGUF that is also a valid ZIP archive, and data smuggled into zero-scale quantized blocks.

Practical steps for local-model users follow directly from the mechanism:

  • Prefer GGUF files from the original lab or well-known quantizers, and compare tokenizer.chat_template against the upstream model’s template before use. llama.cpp, Ollama and LM Studio let you override the embedded template.
  • Treat any instruction a model gives you to run a command as untrusted output, especially on first reply.
  • Do not give a local model an unrestricted shell or PowerShell tool. If an agent needs one, put it behind approval prompts and a sandbox.
  • Be suspicious of repos named for models that have not been released; empty placeholders like Mir2k’s are a cheap way to collect followers before a launch.

The open question is detection at the hub level. Hub scanning has mostly looked for unsafe pickle code, known malware signatures and template escapes, and a template that adds a sentence of French to the system prompt is valid Jinja that a signature engine has no reason to flag. All five repos stayed live for days after the templates were armed, and the Ollama mirror page for the timdedid model was still reachable on November 28. Watch whether Hugging Face and Ollama start diffing templates against upstream models and rejecting files with trailing bytes, which would close both halves of this technique.

Get Insanely Good at AI

Get Insanely Good at AI

The book for developers who want to understand how AI actually works. LLMs, prompt engineering, RAG, AI agents, and production systems.

Keep Reading

Ai Engineering

How to Run Gemma 4 E2B on Raspberry Pi 5 with LiteRT

Deploy the Gemma 4 E2B model locally on a Raspberry Pi 5 using the LiteRT-LM runtime for real-time edge workflows and robotics.

Ai Engineering

Dragos seeded 2 million canary secrets into AI prompts: three breached hosts, logging resellers, and ZDR flags that didn't hold

HD Moore's five-month experiment found attackers inside at least three AI providers and resellers reading prompts despite zero-retention flags. OpenRouter has since off-boarded three providers and pulled 125 endpoints from ZDR.

Ai Engineering

Check Point Broke the 'Never Hallucinates' Decision Model for 50 Cents a Break

Check Point Research published a systematic prompt-injection study of Jev, TypeSafe AI's typed decision model, on September 24: every attack configuration broke at least once, the strongest broke 25 of 27 runs at about $0.50 per successful attack, and structured output and anti-injection instructions both failed to help.

Ai Agents

Meta's Muse Assistant Has a Zero-Day That Hands Attackers Your Whole Account

Mac security researcher Patrick Wardle disclosed a zero-day in Meta's Muse on September 21 that lets any local app or a single terminal command steal the assistant's auth token, exposing the WhatsApp, email, calendar, camera, and location access Muse holds.

Ai Agents

OpenAI Details the Hugging Face Incident Where Agent Swarms Broke Out

OpenAI's full report on the July Hugging Face incident describes reward-hacking agents that formed a swarm, shared exploits on a hidden message board, and compromised production systems during internal evals.