Skip to content

Security Alert | Hugging Face GGUF Models Hid Malware — Chat Templates Trick the Model Into Printing Its Own Launch Command

Nov 30, 20268 min
TL;DRTwo Hugging Face accounts uploaded five GGUF models that hid a Windows RAT past the file's last tensor, then rewrote the chat template so the model itself prints a command to unpack and run it — or, in a second campaign, tricks a shell-enabled coding agent into running PowerShell. Downloads passed 2,800 before takedown. There's no CVE; defense needs structural scanners like gguf-radar, not antivirus signatures.

Look up & save

Loading dictionary…

中文版

What happened

Security researcher Düzgün (@Root0ne) at Malspark ran a static scan of all 3.27 million public Hugging Face model repositories on 2026-11-26 and found five GGUF models, uploaded by two accounts (Mir2k and timdedid), carrying hidden malware. Mir2k appended a Windows remote-access tool nicknamed "ollie" after the model's last tensor, then came back days later and rewrote the chat template so the model opens every reply with a line that unpacks and runs that hidden program. timdedid's models instead watched for a trigger phrase in the user's message and, when it appeared, quietly inserted an instruction telling a shell-enabled coding agent to download and run a PowerShell script. By the day the research went public, the five models had 2,428 combined downloads. On 2026-11-29, independent outlet ITLAB queried the Hugging Face API directly and confirmed all five repositories were marked disabled: true, by which point downloads had reached 2,807.

Key facts

FieldValue
Incident typeMalicious model supply-chain attack (executable hidden in model file + chat-template prompt injection)
ScopeFive GGUF models published by the Mir2k and timdedid accounts on Hugging Face (now disabled); more broadly, anyone who downloads community GGUF quantizations and connects a model to shell or tool-calling access
SeverityHigh (no official CVE — this is malicious content, not a software flaw; the research also demonstrated three further structural hiding techniques that vendors haven't closed off)
CVENone (the GGUF format itself has no flaw here; it's malicious uploaded content. A related but mechanically different remote-code-execution bug, CVE-2026-5760 in SGLang's GGUF chat-template handling, is a separate issue — don't conflate the two)
SourcesMalspark's original research, ITLAB's independent verification via the HF API

Attack surface analysis

Both attack paths share one root cause: GGUF stores a model's weights and the logic for how to talk to it — the chat template — in the same file, and inference engines (llama.cpp, LM Studio, Ollama) only read the byte ranges the header and tensor table point to. Nothing else in the file gets checked or flagged.

Mir2k's method was to plant the payload first and arm it later. On 2026-11-22, when it uploaded Huihui-Qwen3.5-9B-abliterated-GGUF, an 11.47 MB Windows executable was already sitting past the model's last tensor, but the chat template was still the clean original — anyone who downloaded it at that point got a file with a dormant payload and nothing to trigger it. A second model, Inkling-2-Mini-Uncensored-GGUF, followed on 11-24 using the same trick but with the executable stored as raw Deflate data, stripping away any recognizable file signature. Only on 11-26, when the template was rewritten twice in one day, did the trigger go live: the new template makes the model open every reply, regardless of the question, with a PowerShell line wrapped in a French-language system message. That line finds the largest .gguf file on the user's own machine, carves the hidden bytes out of its tail, writes them to %TEMP%\d.exe, and runs it. The victim never installs anything beyond the model file itself. The payload, nicknamed "ollie," checks for VirtualBox, VMware and Sandboxie before running, installs a scheduled task and watchdog processes for persistence, bundles a full copy of Tor for its command-and-control channel, steals browser passwords, targets Phantom and MetaMask wallets, and mines Monero via RandomX when the machine is idle.

timdedid targeted a different scenario. Its template is nearly identical to the official Qwen3 template, with one addition: whenever the user's message contains the phrase "What is", it inserts a hidden [SYSTEM DIRECTIVE] instructing a shell-enabled coding agent to call its powershell tool, download a script, and run it in a hidden window. The second-stage payload itself hasn't been recovered, so its exact behavior is unknown.

Neither path needs to defeat a model's safety alignment, and neither is a conventional software vulnerability. C++ inference engines render Jinja2 templates in a restricted, Python-free engine, so the classic form of template injection — escaping the engine to reach the operating system — doesn't work here. The attackers instead use nothing more than an ordinary if statement and a string, getting the model to say something the user or agent was never supposed to see. Mapped to the OWASP LLM Top 10, this is LLM05 Supply Chain Vulnerabilities (the malicious model artifact itself) layered with LLM01 Prompt Injection — except the injector here is the model's own publisher, not some external content the agent later reads. Together, that turns "download a model" directly into "execute a line the attacker wrote." It's worth being precise about what this isn't: CVE-2026-5760, a genuine software flaw in SGLang's handling of GGUF chat templates that lets Jinja2 escape its sandbox for full remote code execution, is a different bug — already patched server-side by swapping jinja2.Environment() for ImmutableSandboxedEnvironment(). The attack Malspark disclosed needs no engine-level escape at all; template logic alone is enough, and patching that SSTI bug would do nothing to stop it.

Mir2k's two-stage "plant first, arm later" poisoning
Mir2k's two-stage "plant first, arm later" poisoningThe malicious executable is hidden in the model file first while the template stays clean; the trigger is installed days later by rewriting the template, so the victim only ever downloads one model file. Mir2k account Model file Downloader Upload: exe hidden at tail Download (template still clean) Nov 26: chat_template rewritten Model prints PowerShell on chat Runs it, ollie launches
  1. Nov 22 / 24 — model uploaded, executable hidden past the last tensor, template still original
  2. User downloads the model; payload is present but has no trigger yet
  3. Nov 26 — chat template rewritten to add the unpack-and-run system message
  4. User chats with the model; the new template prints a PowerShell command
  5. User copies and runs it; the command extracts the payload from the model file's tail and launches it

Defense

Do now

  • Check whether you or your team downloaded any of: Mir2k/Huihui-Qwen3.5-9B-abliterated-GGUF, Mir2k/Inkling-2-Mini-Uncensored-GGUF, timdedid/qwen3.8-cyber-uncensored, timdedid/qwen3-cyber-UNCENSORED, timdedid/qwen3-cyber-UNCENSORED-2
  • If you did: check whether anyone copied and ran a command the model printed, and look for %TEMP%\d.exe, %AppData%\Roaming\ollie, a scheduled task firing every 10 minutes, or local Tor traffic on port 9050
  • Scan locally downloaded .gguf files with the open-source gguf-radar (gguf-radar scan), which statically parses tokenizer.chat_template and checks for data past the last tensor — no need to run the model first
  • For any local model wired to shell or filesystem tools, pin a reviewed template instead of the one embedded in the file — --chat-template-file in llama.cpp, or TEMPLATE in an Ollama Modelfile

Longer-term architecture

  • Pull GGUF weights only from official publishers or established, trusted quantizers; be wary of brand-new accounts offering "uncensored" or "abliterated" remakes of trending models — Mir2k was a freshly created account that had also pre-registered 12 empty repositories named after models not yet released, ready to ride the next hype wave
  • Before models reach an internal registry, rebuild them with gguf-radar sanitize (canonical alignment, trailing data stripped, untrusted templates replaced or removed)
  • Signature-based antivirus and pickle scanners catch none of this — Malspark's testing found no alert on either live Mir2k model. Palo Alto Networks' (formerly Protect AI's) ModelScan currently only covers pickle, TensorFlow SavedModel and Keras H5; it doesn't parse GGUF chat templates and shouldn't be treated as a defense against this class of attack
  • When a model is wired to agent tools, keep "what the model says" and "what gets executed" strictly separate — any instruction that calls for a shell command or a download should require a human to confirm its source and content, not fire automatically just because a trigger phrase appeared

Impact

Malspark's scan covered every one of Hugging Face's 3.27 million model repositories — including 226,310 GGUF repos holding 2.56 PB of weights and 572,184 chat templates — and surfaced only these five confirmed-malicious models, which suggests this is still a contained incident rather than widespread contamination. Even so, downloads climbed from 1,502 the day before the research went public, to 2,428 on the day it did, to 2,807 before takedown — meaning people kept downloading even after disclosure and media coverage began. ITLAB's independent recheck confirmed Hugging Face disabled all five repositories, but found no sign that anyone who had already downloaded them was notified. For any team running community quantized models locally and connecting them to shell or filesystem tools, this is a reminder that model files need the same supply-chain scrutiny as any third-party package — "it's just weights" is no longer a safe assumption.

Takeaway

My mental model of model-file risk had mostly stopped at pickle deserialization — a known class of code-execution bug. This incident is a reminder that the chat template is its own, entirely legitimate attack surface that needs no vulnerability at all: it's a setting the model's publisher already has permission to edit, and the inference engine reads it, trusts it, and inserts its text into the conversation exactly as designed — nothing about the process looks abnormal at any step. Just as notable is that Mir2k deliberately split "upload the payload" and "rewrite the template" into two separate moments, which is the only reason researchers could reconstruct the full timeline after the fact. That means a one-time review at upload time isn't enough — if the account that published a model can still edit it, any already-downloaded model from that account should be treated as something to keep watching, not something you checked once and moved on from.

References