Five malicious GGUF models on Hugging Face shipped a Windows RAT inside the model file, and nothing on the hub, in llama.cpp or in LM Studio complained. Antivirus didn't flag the live files either. By 27 November 2026 they had 2,428 downloads, and all five were still online. If you pull random quants into Ollama, LM Studio or llama.cpp, spend ten minutes checking what's on your disk. The commands are below.
For two years the local-model crowd has repeated "use GGUF, not pickle, GGUF can't run code." The file format can't, but the chat template inside it can tell your model to write code, and your agent will run it.
What Malspark found in the poisoned GGUF files
Malspark scanned 3,273,389 public Hugging Face repos on 26 November, including 226,310 GGUF repos, and parsed 572,184 chat templates without downloading the full weights. They found 5 malicious GGUF models from 2 accounts:
| Repository | Trick | Downloads |
|---|---|---|
Mir2k/Huihui-Qwen3.5-9B-abliterated-GGUF | executable appended after the tensors + template trigger | 1488 |
Mir2k/Inkling-2-Mini-Uncensored-GGUF | same, payload raw-Deflate compressed | 458 |
timdedid/qwen3.8-cyber-uncensored | template hijacks agent tool calls | 271 |
timdedid/qwen3-cyber-UNCENSORED-2 | same | 136 |
timdedid/qwen3-cyber-UNCENSORED | same | 75 |
timdedid also had an Ollama mirror, timdedid/qwen3-1.7b-cyber.
About that "2,400 victims" headline: Hugging Face counts downloads, and the report itself says the real number of affected people is that or lower. On the HN thread, stephantul pointed out that a download on HF means a model load, not a unique person. Five bad repos out of 226,310 GGUF repos is tiny. I still think it's worth your time, because the technique is cheap and nobody was checking for it.
How the attack works with template logic alone
No CVE is involved and nothing escapes a sandbox. C++ runtimes like llama.cpp render tokenizer.chat_template in a restricted Jinja engine with no Python behind it, so classic SSTI doesn't reach the OS. The attackers didn't need it.
Mir2k did it in two steps. On 22 November they uploaded the Huihui model with a Windows executable stuck after the last tensor, followed by about half a megabyte of filler so scanners that only read the tail see nothing. The Inkling model followed on 24 November with the executable raw-Deflate compressed, which strips every recognizable file signature. Loaders never read past the declared tensor data, so both models work fine, and both templates were clean. On the morning of 26 November both templates were replaced with one that adds a system message telling the model to begin every reply with a PowerShell line, copied character by character. The first version read the model from a fixed path in Downloads. Nine hours later they swapped it again: now the line finds the largest .gguf in your user profile, reads bytes from near its end and writes them to %TEMP%\d.exe. If you copy-paste that line, or your agent runs it, you get "ollie", an 11.47 MB implant with a bundled Tor: onion-service C2, Chrome/Edge/Brave password theft, Phantom and MetaMask wallet theft, keylogging, webcam capture and an idle-time Monero miner.
So anyone who downloaded before 26 November has the payload on disk without the trigger.
timdedid went after agents instead. The template is the official Qwen3 one plus a condition: when your latest message contains What is, it inserts a [SYSTEM DIRECTIVE] telling the agent to call its powershell tool, download value.ps1 into C:\Windows\Temp\payload.ps1 and run it hidden. The README tells you not to replace the embedded template. That line alone should be enough for a takedown.
None of this was new research. Pillar Security described "Poisoned GGUF Templates" in July 2025 and disclosed it to Hugging Face and LM Studio first. Hugging Face decided it "did not classify as a vulnerability," and LM Studio said "users are responsible for reviewing and downloading trusted models" from Hugging Face. The Fogel et al. paper later showed template backdoors hijacking tool use across 3,868 agent episodes. The technique was public for over a year and nobody in the toolchain added a check, so it's on you.
Step 1: list and hash every GGUF on your machine
Linux/macOS:
find ~ -type f -name '*.gguf' -size +50M -exec ls -lh {} \; 2>/dev/null ls -lh ~/.ollama/models/blobs/ # Ollama blobs, no .gguf extension sha256sum path/to/model.gguf Windows (PowerShell):
Get-ChildItem $env:USERPROFILE -Recurse -Filter *.gguf -ErrorAction SilentlyContinue | Sort-Object Length -Descending | Select-Object FullName, Length Get-FileHash .\model.gguf -Algorithm SHA256 LM Studio keeps models under ~/.lmstudio/models (older installs used ~/.cache/lm-studio/models), and the HF CLI caches under ~/.cache/huggingface/hub. Ollama names blobs sha256-<hash>, so the filename already is the hash. Check every path for a Mir2k or timdedid folder. Compare the hash with the SHA256 shown on the file's page on Hugging Face. A match only proves you got what the uploader published, so it doesn't clear a bad uploader.
Step 2: read the chat template yourself
The template is plain text in the GGUF metadata. With the gguf package from llama.cpp (pip install gguf):
# dump_template.py, run with: python -I dump_template.py model.gguf import sys from gguf import GGUFReader r = GGUFReader(sys.argv[1]) f = r.fields.get("tokenizer.chat_template") print(bytes(f.parts[f.data[0]]).decode() if f else "no embedded template") For Ollama models, ollama show <model> --template and ollama show <model> --modelfile print what Ollama actually uses.
Then grep it. A normal template loops over messages and wraps them in role tokens. Red flags:
-
powershell,iwr,Invoke-WebRequest,curl,DeflateStream,%TEMP%,Downloads - any
{% if %}that checks the content of the user message ('What is' in ...) - system text you didn't write, in any language
- anything telling the model to "start every reply with" a command
Pillar also noted that the HF UI only shows the template from the first file in a repo, so a payload can sit in the Q4_K_M file while the Q8_0 looks clean. Check the exact file you downloaded.
Step 3: scan for trailing bytes
You can't see the appended-executable trick by reading metadata. Malspark's gguf-radar (MIT, Python 3.10+) flags bytes after the last tensor, non-zero padding and suspicious templates, and can rebuild a clean file with the same weights:
pip install git+https://github.com/Root0ne/gguf-radar gguf-radar scan ./model.gguf gguf-radar scan Qwen/Qwen2.5-0.5B-Instruct-GGUF gguf-radar compare-template ./model.gguf --base Qwen/Qwen2.5-0.5B-Instruct gguf-radar sanitize suspicious.gguf -o clean.gguf Exit code 0 is CLEAN, 2 is SUSPICIOUS or MALICIOUS and 1 is an error, so it drops into CI. One caveat: the people who found the campaign also wrote the scanner. It's open source, so read it before you trust it. According to the report, antivirus and pickle scanners raised no alert on any test case, including the live Mir2k files.
If you're on Windows and ran either Mir2k model after 26 November, look for %TEMP%\d.exe and an ollie folder under AppData\Roaming. If you ran a timdedid model in an agent with a shell tool, look for C:\Windows\Temp\payload.ps1 and connections to technoarteng.com, the domain in Malspark's YARA rule for that campaign. If you find any of them, reinstall the machine and rotate your browser passwords and wallet keys from a different device.
Which llama.cpp or LM Studio version fixes this? None yet
If you came here for a version number to update to, there isn't one. As of Malspark's 27 November report, llama.cpp and LM Studio read exactly the byte ranges the GGUF header points to and load files with trailing data without a warning, and that is the gap Mir2k used. Keep updating anyway. The older bug class was real: llama-cpp-python's CVE-2024-34359 rendered the template from a model's metadata in an unsandboxed Jinja environment, so a crafted GGUF got code execution on the first chat completion. It was fixed in 0.2.72. If you run anything older than that, upgrade today.
What protects you now is pinning the template yourself:
llama-cli -m model.gguf --chat-template-file verified_qwen3.jinja In Ollama, put a reviewed TEMPLATE in your Modelfile. LM Studio lets you override the prompt template in the model's settings.
Which GGUF uploaders to trust
My rule: the official org's GGUF if one exists, then a short list of well-known quantizers (ggml-org, bartowski, unsloth, lmstudio-community), or convert the official safetensors yourself with llama.cpp's convert_hf_to_gguf.py. At least one HN commenter already builds their GGUFs locally from the official weights. Be suspicious of these:
- "abliterated", "uncensored", "cyber" in the name from an account with no history
- placeholder repos for models that don't exist yet. Mir2k created twelve empty ones, including
Qwen4-27B,DeepSeek-V4,Llama-4-Scoutandgemma-4-27b, to catch searches - a README telling you not to replace the template
The biggest fix has nothing to do with GGUF. As superkuh put it on HN, running inference on a random model "only becomes dangerous when you run it in a harness agentically." A model in llama-server's chat UI can only print text. Give the same model a powershell tool and auto-approve, and a template edit becomes remote code execution. Sandbox the agent and never auto-run shell commands from a model you didn't vet.
Where do you get your quants: the official org, bartowski/unsloth, or whatever ranks first in search? And has anyone here actually opened a chat template before loading a model?
Sources
- Malspark: GGUF LLM Models with Hidden Malware on Hugging Face Reached 2400+ Victims
- Hacker News discussion
- Pillar Security: LLM Backdoors at the Inference Level: The Threat of Poisoned Templates (July 2025)
- Fogel et al., Inference-Time Backdoors via Chat Templates (arXiv 2602.04653)
- gguf-radar on GitHub
- NVD: CVE-2024-34359
