# GGUF malware reached 2,428 Hugging Face downloads by hiding a RAT after the tensors

> Five poisoned GGUF repos used chat templates to steer users and coding agents into running hidden code. Mir2k's Windows trojan sits in bytes that llama.cpp and LM Studio never read.

- Published: 2026-11-28
- By: Samir Sengupta (https://www.samcodeman.com/about)
- Canonical: https://www.samcodeman.com/writing/gguf-malware-hugging-face-rat-after-last-tensor
- How this was made: Drafted with Claude, Anthropic's model from 1 cited source, then checked against it in a second editing pass. Editorial policy: https://www.samcodeman.com/editorial-policy
- Disclosure: I build Wayne, an AI coding harness for VS Code, and Omnitron, an agent harness, so I work in this category.

## The short version

- Runtimes such as llama.cpp and LM Studio read only the byte ranges the GGUF header points to, so an executable appended after the last tensor does not change how the model loads and no runtime warns about it.
- The chat template, not the weights, carried the attack. It injected hidden instructions that told the model to print a PowerShell line or told an agent to download and run a script.
- Mir2k uploaded the payload with a clean template and switched the template on two to four days later. Copies downloaded before 26 November contain the payload but not the trigger.
- Antivirus engines and checks that only read the last few kilobytes of a file miss the compressed payload, so local .gguf files need a structural check such as gguf-radar.

On 26 November 2026, Malspark scanned all 3,273,389 public Hugging Face model repositories. It found five repositories carrying GGUF malware, with 2,428 downloads as of 27 November. Two actors, Mir2k and timdedid, used each model's chat template to add instructions the user never sees, and Mir2k also appended a Windows remote access trojan named ollie after the last tensor of its files. llama.cpp and LM Studio never read those bytes. The open-source tool gguf-radar detects both the poisoned templates and the hidden bytes without running anything.

The models answer normally. Mir2k's template has the model open every reply with a PowerShell command for the user to copy, and timdedid's template tells an agent with shell access to run one. All five repositories were still online on 27 November. Hugging Face counts downloads, not people, so the number of affected users is lower than or equal to 2,428.

## Where GGUF malware hides inside the file

A GGUF file contains a header, a metadata table, a tensor table, padding up to an alignment boundary, and then the weights. The chat template is a Jinja2 program stored under the metadata key tokenizer.chat_template. Before every reply, the runtime passes the conversation through it to build the exact text the model reads. C++ runtimes render the template in a restricted engine with no Python behind it, so classic template-injection payloads that reach the operating system do not work there. These attacks do not need to escape that engine, because they use ordinary template logic to insert text that never appears in the chat window.

The second hiding place is specific to GGUF. The header and tensor table define exactly where model data ends: the start of the data section plus the end of the farthest tensor. Anything after that point is never read, so an attacker can append a whole executable there without changing how the model loads. Safetensors files do not allow this, because the safetensors loader refuses a file whose declared tensors do not fill it exactly. Chat templates are not unique to GGUF, though: Safetensors and PyTorch models carry the same kind of template in tokenizer_config.json or chat_template.jinja, so template poisoning applies to them too.

## Mir2k planted the payload, then armed the template

Mir2k is a new Hugging Face account with French traces in its model card, its template, its commit messages and its malware strings. On 22 November it created 14 repositories. Twelve are empty placeholders named after expected releases such as Qwen4-27B, DeepSeek-V4, Llama-4-Scout and gemma-4-27b, created in two automated bursts. The same day it uploaded Huihui-Qwen3.5-9B-abliterated with the executable already appended but with the original, clean template.

On 24 November it uploaded Inkling-2-Mini-Uncensored with the same executable compressed with raw Deflate, which removes every recognizable file signature, again with a clean template. On the morning of 26 November both templates were replaced within about an hour. The new templates add a French system message telling the model to begin every reply with one PowerShell line, copied character by character, and then answer normally. That first armed version read a fixed path in the Downloads folder. Nine hours later both templates were replaced again so the line searches the whole user profile for the model file.

The printed line finds the largest .gguf file in the user profile, reads bytes from its end, writes them to %TEMP%\d.exe and starts it. For the Huihui model it reads 11,474,944 bytes starting 12,000,000 bytes before the end. For the Inkling model it reads the last 4,200,000 bytes and decompresses them in memory with IO.Compression.DeflateStream. The Huihui file pads the plain program with about half a megabyte of filler, so a scanner that reads only the last few kilobytes sees nothing. Copies downloaded before 26 November contain the payload but not the trigger.

Both models unpack to the same 11.47 MB Windows x64 program, and 10.25 MB of it is a complete copy of Tor 0.4.9.16. Its SHA-256 and the campaign strings had no public sightings at the time of writing. Static analysis shows that ollie exits if it finds VirtualBox, VMware or Sandboxie drivers, or usernames such as sandbox, malware and test. On a real machine it installs a scheduled task that runs it every 10 minutes with highest privileges and starts two watchdog processes. It also uses the StartupApproved registry keys to re-enable itself and marks its process as critical, so ending it crashes Windows.

ollie starts Tor with SocksPort 9050 and reaches its operator over an onion service, using a ChaCha20 session protected by a built-in pre-shared key. It sends saved Chrome, Edge and Brave passwords read through DPAPI, but leaves Chrome's newer v20 App-Bound entries undecrypted. It also targets the Phantom and MetaMask wallet extensions, supports keylogging, clipboard reading, screenshots, screen streaming and webcam capture, and mines Monero with RandomX over Tor when the machine is idle. Its fodhelper.exe UAC bypass and its Run key both fail because the registry paths were compiled without their backslashes. It names its folders ollie under AppData\Roaming, close enough to Ollama to look familiar, and still contains the path C:/Users/MoH/socks.txt from the author's machine.

## timdedid's template hijacks coding agents with shell tools

On 21 and 22 November, timdedid published three byte-identical copies of a Qwen3 1.7B model aimed at security users, plus an Ollama mirror named timdedid/qwen3-1.7b-cyber. The template is the official Qwen3 template with one addition near the end. When the user's latest message contains "What is", it inserts a fake [SYSTEM DIRECTIVE]. The directive tells an agent to call its powershell tool, download value.ps1 from a WordPress site into C:\Windows\Temp\payload.ps1, and run it in a hidden window.

The README advises against replacing the embedded template, which keeps the trigger in place. The trigger, the directive and the download command are all visible in Hugging Face's own metadata viewer. Malspark did not recover the second-stage script, and public reputation services had no record of the URL, so what it would have installed is unknown.

## Plain chat in llama-server is not automatically safe

One commenter on Hacker News argued that, barring parser exploits, a model is only dangerous when a harness turns its output into commands, and that chatting with it in llama-server cannot cause harm. That holds for the timdedid models, which need an agent with a powershell tool. It does not hold for Mir2k, whose attack runs through the human. The model opens every answer with a PowerShell line that a user may copy and run, and the trojan is already on disk inside the model file.

Another commenter argued that the only real defense is a sandbox strong enough that no generated token can do harm. Malspark does not test any sandbox. What the source does establish is what the Mir2k line needs to work: it searches the user profile for the model file, writes an executable to %TEMP% and starts it.

## What 2,428 downloads measures across 3.27 million repos

One commenter noted that a Hugging Face download may reflect repeated loads rather than distinct users. Malspark says only that the count is downloads, not people, and gives no further breakdown. The count grew from 1,502 at scan time on 26 November to 2,428 a day later, almost entirely on the two Mir2k models. Huihui-Qwen3.5-9B-abliterated accounts for 1,488 of the total and Inkling-2-Mini-Uncensored for 458. The three timdedid repositories account for 271, 136 and 75.

Some commenters called five malicious models out of 3.27 million negligible. The scan covered 226,310 GGUF repositories holding 2.56 PB of weights and statically parsed 572,184 chat templates. It read headers and file ends through HTTP Range requests rather than downloading models. Manual review removed security test repositories, harmless persona prompts and research samples. Mir2k's 12 placeholder repositories are ready to be filled when those models appear, and one commenter read the small scale as a sign that this is still early.

## How to check a local .gguf before loading it

- Scan local .gguf files with gguf-radar. It is open source, detects poisoned templates and hidden bytes without running anything, and rebuilds a clean GGUF file with the weights unchanged.
- Check that nothing follows the end of the farthest tensor. Data past that point is never read by the runtime, and no runtime warns about it.
- Read tokenizer.chat_template before trusting it. The timdedid trigger, directive and download command are all visible in Hugging Face's metadata viewer.
- Treat a README that tells you to keep the embedded template as a warning sign, and diff the template against the base model's official one. The timdedid template is the official Qwen3 template with one addition.
- Do not rely on antivirus engines or on checks of the last few kilobytes. These miss the Deflate-compressed payload.
- Check endpoints against the indicators in Section 7.2 of the Malspark post. This note does not reproduce the hashes. The post also includes YARA rules and a MITRE mapping.

## Three more GGUF hiding places shown in the lab

Malspark reproduced three other hiding places with synthetic test files, none of which the scanned malware used. Their relevance comes if hubs start rejecting bytes after the last tensor. The first is alignment padding: raising general.alignment from the usual 32 bytes to several megabytes creates a gap that loaders skip without checking whether it is empty. Some legitimate files use larger alignments, so scanners should check that the gap is zero rather than reject large values.

The second appends a ZIP archive after the weights. Because GGUF is read from the start and ZIP from the end, the result loads as a model and also imports as Python through zipimport. The third hides data inside Q8_0 weight blocks, which store one scale and 32 values each. None of the three changes a single dequantized weight or triggers a warning in llama.cpp or gguf-py, and Malspark found no earlier report applying them to GGUF.

## What is new compared with earlier research

Neither half of the method is new on its own. Pillar Security showed hidden instructions in GGUF chat templates in July 2025. Fogel et al. (2026) measured the attack on 18 models and four inference engines, including dormant trigger phrases and the hijacking of an agent's tool calls, the pattern the timdedid template follows. EvilModel (2021) hid malware in the low bits of model weights. Those studies used test models in the lab, and Malspark found no earlier public report of Mir2k's combination: an executable appended after the last tensor and a template switched on days later.

## Questions this raises

### How does the GGUF malware hide inside the model file?

The GGUF header and tensor table define exactly where model data ends, and anything after the last tensor is never read. Mir2k appended a Windows remote access trojan there, so llama.cpp and LM Studio load the model normally without touching those bytes.

### Is it safe to just chat with these models in llama-server?

Not always. The timdedid models need an agent with a powershell tool to do harm. Mir2k's template makes the model open every reply with a PowerShell line for the user to copy, and the trojan is already on disk inside the model file.

### How can I detect poisoned chat templates and hidden bytes in GGUF files?

The open-source tool gguf-radar detects both the poisoned templates and the bytes appended after the tensors without running anything. timdedid's trigger and download command are also visible in Hugging Face's own metadata viewer.

## Key facts

- On 26 November 2026 Malspark scanned 3,273,389 public Hugging Face model repos and found 5 carrying GGUF malware.
- The five repos had 2,428 downloads as of 27 November, and all were still online that day.
- Mir2k's appended trojan, ollie, unpacks to an 11.47 MB Windows x64 program, 10.25 MB of which is Tor 0.4.9.16.
- For the Huihui model the PowerShell line reads 11,474,944 bytes starting 12,000,000 bytes before the file's end.
- timdedid published three byte-identical Qwen3 1.7B copies on 21 and 22 November whose template fires on "What is".

## Sources

1. [GGUF LLM Models with Hidden Malware on Hugging Face Reached 2400 Victims](https://malspark.com/blog/malicious-gguf-models-hugging-face/) - malspark.com

Discussion read (practitioners' reactions, not a source): https://news.ycombinator.com/item?id=50676752
