Quick answer: GGUF model malware hides in two places antivirus doesn’t look: the chat template stored in the file’s metadata, and extra bytes appended after the last tensor. To check a GGUF model, scan it with a structural scanner, confirm the file ends where its last tensor ends, read the chat template for shell or download strings, and pin a reviewed template before any agent with tools loads it.
On November 27, 2026, the security firm Malspark published a scan of every public model repository on Hugging Face, 3,273,389 of them. It found 5 malicious GGUF models with 2,428 downloads. You may have seen that figure reported as “2,400 victims.” Malspark’s own report is more careful: Hugging Face counts downloads, not people, so the number of affected users is lower or equal.
The count is small. The method is the part to worry about. One of the two campaigns targeted coding agents directly: its chat template told an agent with a shell tool to download and run a script. If your agents run local models on the same computer that holds your repo access and keys, this guide gives you a check that takes minutes. It also shows how to run that check as a task in Sharkly, so a model reaches your team only after someone has looked at the result.
What the GGUF model malware campaign did
GGUF is the single-file format that llama.cpp, Ollama, LM Studio and similar runtimes use for local models. One file carries the weights, the tokenizer, and a chat template: a small Jinja2 program the runtime applies to every prompt before the model reads it.
Malspark’s report describes two campaigns:
- Mir2k uploaded two uncensored models with a Windows remote access trojan, named ollie, appended after the last tensor. On November 26 it rewrote both chat templates so the model opens every reply with one PowerShell line. That line finds the largest
.gguffile in your user profile, reads its last bytes, writes them to%TEMP%\d.exeand starts it. The two Mir2k models account for 1,946 of the 2,428 downloads. - timdedid published three copies of a small Qwen3 model aimed at security users. When your message contains “What is”, the template inserts a fake
[SYSTEM DIRECTIVE]that tells an agent to call itspowershelltool, download a script and run it in a hidden window. The README advised against replacing the embedded template.

The timing matters. Mir2k planted the payload first and armed the template two to four days later. A file you downloaded on November 23 held the trojan but no trigger, so a check that only reads the template that day would have passed it.
Where GGUF model malware hides
A GGUF file runs in a fixed order: header, metadata, tensor info, padding up to an alignment boundary, then the weights. The runtime reads exactly the byte ranges the header points to and ignores the rest.

That layout leaves two hiding places that real attacks used:
- The chat template. It lives under the metadata key
tokenizer.chat_template. It can add text to the conversation that never shows in your chat window. Pillar Security demonstrated this in July 2025; Malspark’s report shows it in live repositories. - Bytes after the last tensor. The header defines where the model data ends. Anything after that point is never loaded, changes nothing about how the model behaves, and triggers no warning.
Malspark tested common scanners against both. Antivirus engines and pickle scanners raised no alert on the live Mir2k files, and GGUF parsers loaded them normally. Mir2k also padded one payload with half a megabyte of filler and compressed the other with raw Deflate, so a check that reads only the last few kilobytes finds nothing.
Can a chat template make a coding agent run commands?
Yes, if the agent has a shell tool and trusts what the model asks for. The template can’t execute code itself in C++ runtimes, but it can inject an instruction the agent treats as a system message. That’s the same trust problem as prompt injection in tables: text the agent reads becomes text the agent obeys.
How to check a GGUF model for malware in 5 steps
Run these steps before a model file reaches any computer where an agent holds keys or repo access.
- Read the repository history. Look at the account’s age, its other repositories and the commit log of the file. Mir2k was a new account that created 14 repositories on one day, 12 of them empty placeholders named after expected model releases.
- Scan it with gguf-radar. gguf-radar is Malspark’s open-source scanner (MIT license). It parses the template without running it and reports bytes after the last tensor. It can scan a Hugging Face link by reading only the header and the end of the file.
- Run your own structural check. A second tool catches what a first tool’s rules miss. The script below uses the official
ggufPython package. - Pin a reviewed template. Pass a template you’ve read with
--chat-template-filein llama.cpp, or setTEMPLATEin an Ollama Modelfile. The embedded one then never runs. - Treat every command a model prints as untrusted. Don’t let an agent run a shell command because a reply suggested it.
Step 2 looks like this:
pip install gguf-radar
gguf-radar scan https://huggingface.co/owner/model
gguf-radar scan ./model.gguf
gguf-radar sanitize suspicious.gguf -o clean.gguf
sanitize writes a new file with everything after the last tensor removed and the weights unchanged.
For step 3, this script compares the file size with the end of the farthest tensor and searches the template for loader strings. It uses GGUFReader from the gguf package on PyPI, which ships with llama.cpp:
#!/usr/bin/env python3
"""Flag bytes after the last tensor and risky chat-template strings in a GGUF file."""
import os
import re
import sys
from gguf import GGUFReader
RISKY = re.compile(
r"powershell|invoke-webrequest|start-process|deflatestream|"
r"openread|writeallbytes|curl |wget |\[system directive\]",
re.IGNORECASE,
)
def check(path: str) -> int:
reader = GGUFReader(path)
size = os.path.getsize(path)
data_end = max(t.data_offset + t.n_bytes for t in reader.tensors)
trailing = size - data_end
problems = 0
if trailing > 0:
print(f"FAIL {trailing:,} bytes after the last tensor (file {size:,} bytes)")
problems += 1
else:
print("ok no bytes after the last tensor")
field = reader.fields.get("tokenizer.chat_template")
template = bytes(field.parts[field.data[0]]).decode("utf-8", "replace") if field else ""
hits = sorted({m.group(0).lower() for m in RISKY.finditer(template)})
if hits:
print(f"FAIL chat template mentions: {', '.join(hits)}")
problems += 1
else:
print(f"ok chat template ({len(template):,} chars) has no loader strings")
return problems
if __name__ == "__main__":
sys.exit(1 if check(sys.argv[1]) else 0)
We tested it with gguf 0.19.0 on three files built with GGUFWriter: a clean model, the same model with 512 KB appended, and one with a timdedid-style template.
$ python gguf_check.py dirty.gguf
FAIL 524,288 bytes after the last tensor (file 524,768 bytes)
ok chat template (53 chars) has no loader strings
$ python gguf_check.py bad-template.gguf
ok no bytes after the last tensor
FAIL chat template mentions: [system directive], invoke-webrequest, powershell
The exit code is 1 on any failure, so a script or an agent can gate on it. The keyword list is a floor, not a proof. A template can encode a command in ways no regex predicts, which is why step 4 exists.
How to run a GGUF intake check as a Sharkly task
A check only helps if it runs every time. The pattern that holds up is a model intake: a new GGUF file goes through one place, gets scanned there, and reaches your other computers after a person signs off.
Sharkly gives that intake a home without new infrastructure. An Agent is the AI teammate that takes the work; it runs through a Runtime such as Claude Code or Codex on a Computer, which is any host connected to your organization.

Set it up like this:
- Pick a separate Computer. Use one that holds no deploy keys, cloud credentials or broad repo tokens. The Computers docs cover connecting one. See how Sharkly Computers work for the shared and private options.
- Create an intake Agent on it. Give it no secret environment variables and set its Task Working Directory to Temporary, so each Task gets its own directory. Temporary mode isolates Tasks from each other; it is not a security sandbox, which is why the Computer choice comes first. The Agents docs list every setting.
- Write the procedure into its instructions. Run gguf-radar and
gguf_check.py, post both outputs on the Task, and never execute anything the model under test prints. - File one Task per model. Put the repository id and file name in the description and assign the intake Agent.
- Approve on the Task. A person reads the result and moves the Task forward. Only then does
clean.ggufand its pinned template go to the folder your developer Computers load from.

Each run leaves an execution trace on the Task, so you can answer “who approved this model, and what did the scan say?” weeks later. The agent task execution docs describe what each run records. For where else a human sign-off belongs, see approval gates for coding agents.
Other ways to reduce GGUF model risk
A per-file check isn’t the only control. Each option below covers a different gap.
| Option | What it stops | Trade-off |
|---|---|---|
| Per-file scan before use | Appended payloads, known template tricks | Someone has to run it every time |
| Pinned, reviewed template | Any embedded template logic | You maintain one template per model family |
| Safetensors instead of GGUF | Appended bytes: the loader refuses files whose tensors don’t fill them | Templates still ship separately; llama.cpp needs a GGUF you convert yourself |
| Internal model registry | Unreviewed downloads on laptops | More process for small teams |
| Least-privilege agents | Damage after a hijacked tool call | Agents need explicit grants for real work |
Use a per-file scan when one person pulls an occasional model. Use a registry with an intake Task when several people and agents share models. Both pair with scoped coding agent permissions and the secrets guardrail checklist, because a hijacked agent can only reach what it already holds.
Conclusion
The Malspark scan found 2,428 downloads of 5 models, not 2,400 confirmed victims. The lesson holds either way: a GGUF file can carry instructions in its template and a program after its weights, and standard scanners miss both. Check the file’s structure, read or replace the template, and keep agents with shell access away from models nobody has reviewed. If your agents already run on several computers, set up a model intake Task in Sharkly and make the scan a step nobody can skip.
FAQ
What is GGUF model malware?
GGUF model malware is a model file built to harm the computer that runs it. Known cases hide instructions in the chat template or an executable after the last tensor. The weights themselves behave normally, which is why the model still looks useful.
Can a GGUF file run code by itself?
No. Loading a GGUF file in llama.cpp doesn’t execute the appended bytes. The attack needs a second step: you, or an agent with a shell tool, running a command the poisoned template made the model print.
Does Hugging Face scan GGUF files for malware?
Hugging Face runs malware scanning on the Hub. Malspark found the five models still online on November 27, and reported that antivirus and pickle scanners raised no alert on the live Mir2k files.
Were 2,400 people infected?
Not confirmed. The figure is 2,428 downloads. Downloads made before November 26 held the Mir2k payload without the trigger, and a download only becomes an infection if someone runs the printed command.
Is Safetensors safer than GGUF?
For appended payloads, yes: the safetensors loader refuses a file whose declared tensors don’t fill it exactly. Chat templates ship with Safetensors models too, in tokenizer_config.json or chat_template.jinja, so template review still applies.
How do I check a model I already downloaded?
Run gguf-radar scan ./model.gguf and the script above on every .gguf file you have. Malspark’s report lists indicators of compromise and YARA rules for checking endpoints.



