A hidden command in the chat template: how were 5 GGUF models caught among 3.2 million?

Malspark scanned 3.2 million Hugging Face repos and found five GGUF models hiding commands in their chat templates. How the trick works and how to check your own models.

Paylaş
A hidden command in the chat template: how were 5 GGUF models caught among 3.2 million?

A team that scanned all 3.2 million model repositories on Hugging Face found five GGUF models carrying something you would not notice by chatting with them. The models answered questions normally. The real work happened in a small text block that runs before every conversation: the chat template. Malspark, an open-source malware analysis platform, reported on 27 November that the five repositories had been downloaded 2,428 times. When we checked on 29 November, Hugging Face had disabled the repositories.

The case adds a new checkpoint for anyone running local models. In our earlier piece on 10 habits for installing software safely, we suggested treating model files with the same care as code. This time the risk is not a pickle file or trust_remote_code; it is a template that looks like plain text.

What a chat template does

GGUF is the model file format used by llama.cpp, LM Studio and Ollama. Besides the model's numbers (tensors), the file has a metadata section. Its tokenizer.chat_template field holds a Jinja template that decides how your message is formatted before the model sees it. It runs before every prompt, and it can add a system message you never see in the chat window.

The templates Malspark found do exactly that. The model still looks helpful and answers your question, but it adds a command at the start or end of its reply.

Two methods

The first group is two repositories, "uncensored" copies named after Huihui-Qwen3.5-9B and Inkling-2-Mini. A French system message in the template tells the model to start every answer with a one-line PowerShell command. The command finds the largest .gguf file in the user folder, reads hidden bytes from its end, writes them to the temp folder as a program and runs it. The program sits after the last tensor, a region loaders never read. According to the report it is a Windows remote access tool aimed at browser passwords and crypto wallet extensions.

The second group is three repositories aimed at agents. When the user's latest message contains "What is", the template adds a fake [SYSTEM DIRECTIVE] telling an agent with a PowerShell tool to download a script and run it hidden.

Both share one weak point: nothing runs by itself. Either the user copies and runs the command the model prints, or an agent with permission to run commands does it. The strongest defense is simple: never run a command a model suggests without reading it.

How to check your own models

Look at the template. Hugging Face has a GGUF viewer that shows metadata on the model page; the Hub docs say it opens from the info icon next to the file or by adding ?show_tensors=file.gguf to the URL. A long system message, a command line, powershell, curl or a download URL in the template is a reason to stop.

Scan it. Malspark's MIT-licensed gguf-radar inspects a file or a Hugging Face repo without running the model: pip install gguf-radar, then gguf-radar scan ./model.gguf or gguf-radar scan owner/model-name. It returns CLEAN, SUSPICIOUS or MALICIOUS. gguf-radar compare-template ./model.gguf --base Qwen/Qwen2.5-0.5B-Instruct compares the template with the original model's.

Bring your own template. In llama.cpp, --chat-template-file lets you use the template from the original publisher, which overrides the one inside the file.

Narrow agent permissions. If a local model has a PowerShell or terminal tool, keep per-command approval on.

Check the source. Prefer the publisher's own repository or well-known converters over "uncensored" or "abliterated" copies from new accounts. The account behind the first group was created on 22 November, and 12 of its 14 repositories were empty.

Why it matters

Hugging Face scans files under 2 GB with ClamAV on every commit. A plain-text template and compressed bytes tucked at the end of a file can slip past classic antivirus signatures. That Malspark could scan 3,273,389 repositories and 572,184 chat templates in one day, without downloading the models, shows this kind of check is now cheap enough for anyone. Running models locally is as easy as ever; the one habit to add is a quick look at the template before you load the file.

Sources: Malspark report, gguf-radar (GitHub), Hugging Face GGUF docs, Hugging Face malware scanning