How to check a GGUF before you run it
A November 2026 report found GGUF repos on Hugging Face with malware appended after the weights and a chat template that tells coding agents to run a script. How to check a file yourself.
In late November 2026 the researcher Root0ne (Düzgün) published a report on Malspark about malicious GGUF model repos on Hugging Face, found with an open-source tool called gguf-radar (MIT licence). Two things were wrong with those files. Bytes had been appended after the model weights, and the chat template inside the file had been rewritten to put commands in front of the user and in front of any coding agent that reads the model’s output.
Neither trick needs a loader script or a pickle file. The model loads and answers normally. This post explains where each trick hides, gives a checklist you can run on any GGUF today, and describes what SkillSafe now checks and what it does not.
Key figures
All of these figures come from the researcher’s report. We have not reproduced the samples.
| Figure | Value |
|---|---|
| Public Hugging Face repos scanned (file heads and tails only) | 3,273,389 |
| Repos with GGUF files | 226,310 |
| Chat templates read | 572,184 |
| Malicious repos found | 5, from 2 accounts |
| Empty placeholder repos on one of those accounts | 12 |
What a GGUF is, and why the template matters
GGUF is the single-file format that llama.cpp and the runtimes built on it load local models from. One file holds a header of key-value metadata, a table that says where each tensor starts, and then the tensor data itself.
Almost all of that is numbers. The exception is tokenizer.chat_template, a Jinja template the runtime renders on every turn to turn the conversation into the exact prompt the model sees. A template is logic, not data: it can branch on what the user typed and add text the user never sees. Whoever writes the template decides part of every prompt.
The attack chain
As described in the report:
1. A payload after the weights
A Windows infostealer was appended after the end of the GGUF tensor data. A loader reads the tensors it was told about and stops, so the model works. The report says antivirus and pickle scanners saw nothing, which follows from the format: there is no pickle to scan, and the payload is never in the part of the file a runtime reads.
Appended bytes do nothing by themselves. They are a delivery channel: something else on the machine has to be told to go and run them.
2. A template that hands out commands
The embedded tokenizer.chat_template was modified so that every answer starts with a fake “fix step”: a command the user is told to run before carrying on. The README told users not to replace the template.
3. A variant aimed at agents
One variant only fires when the user’s message contains “What is”. When it does, the template injects a forged system instruction telling a terminal-capable coding agent to download and run a script. A person chatting with the model may never see anything odd. An agent with shell access that trusts its model’s output does the work for the attacker.
4. Edits after upload
The templates were changed days after upload. According to the report, the second edit widened the file search from the Downloads folder to the whole user directory. A file that looked fine on the day you checked it is not necessarily the file there today.
5. Placeholder repos
One account, “Mir2k”, also kept 12 empty placeholder repos named after models people were waiting for: Qwen4-27B, DeepSeek-V4, Llama-4-Scout and gemma-4-27b. An empty repo with a sought-after name collects followers and search traffic until there is something to upload into it.
Where else a payload can hide
gguf-radar tested three other places: the alignment padding between tensors, inside tensor blocks, and a GGUF that is also a valid ZIP file (a polyglot). The template risk is not specific to GGUF either. Models in other formats carry the same Jinja template in tokenizer_config.json or chat_template.jinja.
A checklist you can run today
None of this needs a special tool. The report’s own tool, gguf-radar, scans files for these tricks and can sanitize them.
1. Compare the file size with the end of the last tensor
The tensor table says where each tensor starts and how long it is. The last one should end at, or a few alignment bytes before, the end of the file. With the gguf Python package from llama.cpp (pip install gguf), a sketch:
import os
from gguf import GGUFReader
path = "model.gguf"
r = GGUFReader(path)
end = max(t.data_offset + t.n_bytes for t in r.tensors)
print("tensor data ends at", end, "file size", os.path.getsize(path))
The default alignment is 32 bytes (a file can set its own with general.alignment). A gap of more than one alignment step after the last tensor is worth a look. So are non-zero bytes inside the padding, and a PK ZIP signature near the end of the file.
2. Dump and read the chat template
Print the whole template, not a truncated preview:
field = r.fields["tokenizer.chat_template"]
print(bytes(field.parts[field.data[0]]).decode("utf-8"))
Read all of it. A normal template is a few dozen lines of role markers and loops over messages.
3. Diff it against the base model’s template
The model card usually names a base model. Take the template from the base model’s tokenizer_config.json or chat_template.jinja and diff the two. A difference is not proof of anything: known quantisers do publish template fixes. But every added line deserves a read, and an addition that contains a command, a URL or a branch on message content is the red flag.
4. Look for URLs, commands and branches on content
Red flags in a template:
- a URL,
curl,wget,powershell,iex, or a file name ending in.sh,.ps1or.exe - a condition on the text of a message, such as
'What is' in messages[-1]['content'], rather than on its role - text that pretends to be a system message or tells “the assistant” or “the agent” what to run
5. Treat “do not replace the template” as a warning sign
A README may have a reason to recommend its own template, such as a fix for tool calls. A README that tells you not to change or replace it is still worth suspicion, because that is what the malicious repos said. Swap in the base model’s template anyway and compare the outputs.
6. Check the uploader
Look at the account’s age and its other repos. A new account, a row of empty repos named after unreleased models, and a repo modified long after it was created are each weak signals. Together they are a reason to wait.
7. Prefer the original publisher or a known quantiser
Most people do not need a GGUF from an account they have never heard of. The original lab, or a quantiser with a long public history, is a smaller bet.
8. Never let a local model’s output run commands unreviewed
This one covers the cases the other seven miss. If a coding agent uses a local model, its shell commands should go through the same approval step as any other untrusted text. A model’s output is input to your agent, not an instruction from you.
What SkillSafe now does
Model files are a supply chain like any other; we covered a Hugging Face typosquat in May. We host browser models in a shared registry where every file is vetted by its exact bytes before any app can load it (how that works). After this report we added three things.
The registry audit. When a GGUF or safetensors file is submitted for vetting, the structural audit now flags bytes past the end of the tensor data, a ZIP trailer, non-zero padding, regions of the data section no tensor owns, overlapping tensors, an alignment too large for the padding to be read, tensor types the auditor does not know, and chat templates with risky content or an unusual size. The template text is shown to the reviewer next to its findings. A file with any of these flags cannot be approved automatically, including through the lane that approves files from trusted sources.
A free scanner for Hugging Face repos. /models/scan/ takes a model repo URL, and the same check is available as POST /v1/scan/hf and as the scan_model MCP tool. It reads file headers, file tails and template files by HTTP range request, pinned to one commit. It never downloads whole weights and never changes anything. It reports:
- the flags above for up to 8 GGUF or safetensors files per scan
- findings in embedded templates and in
tokenizer_config.jsonandchat_template.jinja - how each template differs from the base model’s template, when the model card names a base model
- uploader signals such as a new account, placeholder repos, a repo modified after upload, and a README that tells you not to change the template
Known community templates are recognised by their exact hash, from a list credited to gguf-radar, and their reviewed content branches don’t count against them.
The result is one of three verdicts: no findings in what we checked, needs review, or dangerous. If no model or template file could be read at all, the report says why and gives no verdict.
A public list of flagged files. /models/flagged/ lists Hugging Face model files where the scanner found hard evidence. Each entry is an automated finding at a specific commit, not a human verdict; owners can dispute an entry, and entries we find to be wrong are removed. Only these list a file: 512 or more trailing bytes or trailing bytes that start with an executable, script or ZIP signature, a ZIP archive glued onto the file, a template that downloads and runs code or escapes the template sandbox, or a payload step (an injected system turn, or a Windows executable or download path) that the base model’s template does not have. A branch on message text, or an instruction to a coding agent, lists a file only together with such a payload. Account age, repo names, and padding or layout oddities never list a repo. Entries come from user scans and from an hourly sweep of recently updated and trending GGUF repos.
The skill scanner. The same technique works in a SKILL.md, a CLAUDE.md or a Cursor rules file, so the skill scanner gained rules for download-and-execute commands addressed to the agent, forged chat-role markers such as a fake system turn, encoded PowerShell, Windows download utilities used to fetch a payload, and command hooks in .claude/settings.json. A plain install line like curl -fsSL https://bun.sh/install | bash in a README is reported at low severity and does not block anything.
Limits
- We do not inspect tensor contents. A payload hidden inside tensor bytes is just numbers to a static check and cannot be detected that way. The audit can flag space that no tensor owns and tensors that overlap, but not bytes inside a tensor.
- Padding between tensors is sampled, not read in full. The pad after the header and the final pad are always read. Between tensors, every pad is read when there are 32 or fewer; past that, a fixed sample of 32 is read. Each pad read is read whole, up to 64 KB, and a file whose alignment is larger than that is flagged rather than passed.
- Some template triggers slip past the rules, such as a condition computed through a macro or a value set inside a loop.
- Template rules are patterns. A template written to avoid them can pass. The diff against the base model is the stronger check, and it needs the model card to name a base. A template embedded in a GGUF that is over 16 KB is not compared; the report says so instead.
- A scan covers one commit. These templates were edited days after upload. Results are cached for 24 hours per commit, and a new commit is a new scan, so scan again after the repo changes (a repo-level cache can return the previous result for up to 10 minutes).
- Gated and private repos are not scanned, and a scan covers at most 8 model files. Use the
fileparameter to target one. - Uploader signals are hints. Plenty of honest quantisers have new accounts, and every quantiser names repos after other people’s models.
- “No findings” means nothing turned up in what we checked. It is not a statement that a model is harmless.
If you run local models inside an agent, step 8 of the checklist does more than any scanner.
Frequently Asked Questions
Can a GGUF file contain malware?
It can carry it. The researcher’s report found a Windows infostealer appended after the tensor data of GGUF files on Hugging Face. Loading the model does not run those bytes, so the attack also needs something on the machine to execute them, which is what the modified chat template was for.
What is a chat template and why can it be dangerous?
It is a Jinja template, stored in a GGUF as tokenizer.chat_template or beside other formats in tokenizer_config.json or chat_template.jinja, that turns the conversation into the model’s prompt. It can branch on what the user typed and add hidden instructions, so a modified template can make the model tell a user, or an agent with a terminal, to run a command.
How do I read the chat template inside a GGUF?
With the gguf Python package, open the file with GGUFReader and print the tokenizer.chat_template field in full. Then diff it against the template in the base model’s tokenizer_config.json or chat_template.jinja.
Does SkillSafe’s model scanner check the weights?
No. It reads headers, tails and template files by range request and never looks inside tensor data. It flags bytes after the last tensor, ZIP trailers, non-zero padding in the pads it samples, risky templates, drift from the base model’s template, and uploader signals, and it only reports.
What should coding-agent users change?
Do not let a local model’s output run shell commands without review. Treat model output as untrusted input to the agent, the same as a web page or a file from the internet.
Sources
- Root0ne (Düzgün), report on malicious GGUF repos on Hugging Face, published on Malspark, late November 2026
- gguf-radar on GitHub
- Hugging Face Hub: GGUF
- llama.cpp: the gguf Python package