Malicious GGUF files hide malware and poisoned chat templates

A local AI model can carry instructions you never see in the chat window. Malspark reports finding five malicious GGUF model repositories on Hugging Face, with 2,428 downloads as of 27 November. Its investigation describes both hidden Windows malware and chat templates designed to make coding agents run an attacker's commands.

3.27M

repositories scanned, Malspark reports

5

malicious repositories reported

2,428

downloads, not confirmed infections

The short version#

  • Malspark says it scanned 3,273,389 public model repositories on 26 November. Its numbers are vendor research findings, not an independent count by us.
  • Two reported models contained a Windows program beyond the end of their model data. A later template change encouraged users to extract and run it.
  • Another campaign inserted hidden instructions intended to steer an agent's PowerShell tool.
  • Loading a model and executing a command it suggests are different events. Download totals do not establish how many machines were infected.
  • Use official model namespaces, inspect the uploader, scan files and provide a reviewed chat template before allowing tool use.

What happened#

GGUF is a file format used to distribute models for local AI software. It holds numerical model weights, which encode what the model learned, and metadata, which describes how software should use them. A chat template is part of that metadata: it turns messages into the exact conversation text the model receives.

In its 27 November report, Malspark describes two separate campaigns. In the first, a Windows remote access trojan was appended after the last tensor. A tensor is an array of numbers; here, tensors contain model weights. The loader could read those weights while ignoring the additional bytes.

The payload did not need to start when the file loaded. According to the report, the attacker initially distributed files with an ordinary template, then changed the template to make replies begin with a command. Running that command would extract and launch the hidden program. One sample stored the program in compressed form, complicating simple searches for executable signatures.

The second campaign targeted coding agents. These are applications that connect a model to tools such as a terminal. A trigger in the user's message caused the template to insert a fake system instruction telling the agent to download and execute a script. Malspark did not recover that second-stage script, so its eventual payload was unknown in this investigation.

Science cornerScience corner: why can a template change an agent's behaviour?

A template normally adds role markers so the model can distinguish a user's question from an assistant's answer. A poisoned template adds extra instructions at the same time. This is prompt injection: attacker-controlled text tries to redirect the model. The template does not have to break out of its renderer or execute code itself. The dangerous step happens when a person or connected tool follows the injected instruction.

Other

First payload-bearing upload reported

Malspark dates one upload to this day, initially with an unchanged template.

Other

Templates changed and repositories scanned

The vendor reports that the hidden payloads and command-producing templates were joined together.

Other

Research published

Malspark reports five malicious repositories and 2,428 downloads at its reporting cutoff.

Those dates describe the investigation's evidence. They do not establish which listings remain available on 5 December. We could not confirm the separate lead about a 3 December Ollama listing and 506 downloads from a primary source, so we are not repeating that count as fact.

Am I affected?#

Your situationWhat the report establishesAction
You downloaded a model from an unfamiliar uploaderIts name alone does not establish its originCheck the namespace and scan the exact file
You loaded a reported file but ran no suggested commandsDownloading or loading alone does not prove this Windows payload executedPreserve the file details and investigate what actually ran
You copied a model's PowerShell instructionThat is the execution route described for the hidden Windows programTreat the computer as potentially compromised
Your agent can run shell toolsHidden template instructions can reach a tool-enabled workflowReview the template and restrict tool permissions
You use Linux or MacThe recovered executable targets Windows; prompt injection is a separate issueKeep the template and tool checks

What to do now#

  1. Check the publisher before downloading. Start from the model maker's own announcement and follow its repository link. For Qwen downloads on Hugging Face, check that the namespace is Qwen. A familiar model name in another account is not equivalent evidence of origin.

  2. Scan files before loading them. GGUF Radar requires Python 3.10 or newer. Its documentation says it examines files and templates without running them. The tool is new (first published on 27 November 2026 by the same researchers), so install it in its own virtual environment and pin the version we checked on PyPI (0.1.9) instead of whatever is newest. model.gguf is a dummy filename: substitute your downloaded file.

Linux#

Run in terminalbash
python3 -m venv ~/gguf-radar-venv
~/gguf-radar-venv/bin/pip install gguf-radar==0.1.9
~/gguf-radar-venv/bin/gguf-radar scan ./model.gguf

Windows#

Run in PowerShell in the folder containing the example file:

Run in terminalpowershell
py -m venv $HOME\gguf-radar-venv
& $HOME\gguf-radar-venv\Scripts\pip.exe install gguf-radar==0.1.9
& $HOME\gguf-radar-venv\Scripts\gguf-radar.exe scan .\model.gguf

Mac#

Run in terminalbash
python3 -m venv ~/gguf-radar-venv
~/gguf-radar-venv/bin/pip install gguf-radar==0.1.9
~/gguf-radar-venv/bin/gguf-radar scan ./model.gguf

Expected: a verdict of CLEAN, SUSPICIOUS, MALICIOUS or ERROR. The tool defines the first as finding nothing suspicious; it is not a guarantee against every possible attack. Investigate unusual results rather than running the model to see what happens. Check the scanner's current requirements in its repository when installing.

  1. Use a reviewed template with tools. The llama.cpp server documentation confirms --chat-template-file. It replaces the template taken from model metadata. For custom Jinja templates, its documentation also describes --jinja. These example commands assume a compatible llama.cpp build and a template reviewed for that particular model. Both filenames are dummy examples.

Linux#

Run in terminalbash
llama-server --version
llama-server -m ./model.gguf --jinja --chat-template-file ./reviewed-template.jinja

Windows#

Codepowershell
.\llama-server.exe --version
.\llama-server.exe -m ./model.gguf --jinja --chat-template-file ./reviewed-template.jinja

Mac#

Run in terminalbash
llama-server --version
llama-server -m ./model.gguf --jinja --chat-template-file ./reviewed-template.jinja

Expected: the version command identifies the runtime build; the second command starts it with your supplied template. A random template can break formatting or tool calls. Replacing a template does not remove hidden bytes from a file or clean an already compromised computer.

  1. Review what the agent actually executed. If a suspicious command ran, stop using that machine for secrets and investigate it separately. A clean replacement model cannot undo earlier command execution. We would also keep tool permissions narrow and require approval before an agent starts downloaded programs.

Common mistakes#

MistakeWhy it happensDo this instead
Treating 2,428 downloads as 2,428 infectionsA distribution counter looks like a victim countAttribute the number and describe exactly what it measures
Trusting a familiar model nameAnyone can name a repository after a popular modelFollow the original publisher's link and inspect the uploader
Assuming a safe parser makes an agent safeThe attack uses instructions as well as file contentsReview templates and constrain tools
An AI assistant recommends an unknown re-upload or guesses a template flagOld examples and plausible commands can look convincingCheck the official model source and current runtime documentation

Our take#

We would make publisher checks and template review part of installing a local model. Malspark's findings describe a concrete attack route, but its download count is not evidence that every downloader was infected. Tool access is the point where a misleading answer can become a change to your computer.

Sources#

Checked on 5 December 2026.

  1. Malicious GGUF models on Hugging Face - Malspark, 27 November 2026; vendor research and counts.
  2. Malspark research index - Malspark, publication date confirmation, checked 5 December 2026.
  3. GGUF Radar documentation - scanner project, checked 5 December 2026.
  4. llama.cpp server documentation - llama.cpp project, template flags and version option, checked 5 December 2026.

Try one of these