↓ Skip to main content
  1. Tech Blog: AI, Security, Infrastructure & Open Source/

Poisoned GGUF Models — Local Does Not Mean Trusted

·1386 words·7 mins
Osmond van Hemert
Author
Osmond van Hemert
Supply Chain Security - This article is part of a series.
Part : This Article

Running an LLM on your own workstation answers an important question: where does inference happen? It does not answer a different one: who controls the instructions that reach the model?

Malspark’s November 27 investigation reports five publicly hosted model repositories containing poisoned GGUF chat templates. In two of them, the researchers also recovered a Windows executable hidden inside the model files. The reported total was 2,428 downloads, not 2,428 confirmed infections. Download counters cannot establish whether someone loaded a particular revision, encountered the malicious output, or executed anything.

The important distinction is the execution chain. This report does not demonstrate that merely opening a GGUF model launches its hidden malware. The documented route goes through template-injected instructions, model output, and a human or tool-enabled agent that acts on that output. That is a supply-chain problem even without a memory-corruption exploit.

The Chat Template Is Part of the Trust Boundary
#

A chat application presents a conversation as messages with roles. The model ultimately receives tokens. Hugging Face’s chat-template documentation explains how templates turn those structured messages into the formatted sequence a model expects. Formatting therefore sits between what the interface displays and what inference consumes.

For the GGUF files examined by Malspark, the relevant metadata key was tokenizer.chat_template. The researchers describe malicious templates that added instructions without displaying those additions in the chat window. Their attack did not require escaping the restricted template engine used by the C++ runtimes they discuss; ordinary template logic was enough to alter the prompt.

That makes three separate boundaries worth inspecting:

BoundaryWhat needs to be trustedWhat not to assume
Model intakeThe exact artifact, revision and associated metadataA familiar base-model name proves the uploader’s artifact is safe
Prompt constructionThe effective template and rendered conversationThe chat window shows everything the model receives
Action executionThe human decision or tool authorization policyA command is authorized because a locally hosted model proposed it

My earlier discussion of Ollama and local inference focused on the benefits of moving inference onto your own hardware. This incident adds a separate requirement: local deployment still needs an explicit policy for accepting third-party model artifacts and templates.

Two Reported Campaigns, Different Execution Paths
#

Malspark attributes the five repositories to two campaigns. Its campaign analysis and repository timeline describe both the recovered payloads and the limits of the evidence.

In the Mir2k campaign, two model files carried an executable after the final tensor. One carried it in a compressed form. According to the researchers, the files initially had clean templates; on November 26, the templates changed to instruct the model to prefix its answers with a PowerShell command. That command was intended to extract the concealed program from a local GGUF file and start it.

The payload’s presence and its activation instructions were therefore separate. An earlier download could contain the hidden bytes without the later poisoned template. Conversely, a repository name alone cannot tell an investigator which combination reached an endpoint. The exact file and revision matter.

Malspark identifies the recovered executable as the ollie remote-access trojan and describes credential theft, surveillance and mining functionality from static analysis. Those are the researchers’ findings about the recovered program, not evidence that every downloader ran it. I have not independently executed the samples or reproduced the scan.

In the timdedid campaign, three repositories used a different approach: a trigger phrase caused the template to insert a fake system directive telling an agent to use a PowerShell tool to download and execute a script. The researchers did not recover that second stage, so its eventual payload remains unknown in this investigation.

For defenders, the distinction changes the question. With Mir2k, ask whether the extraction command ran and whether the recovered implant’s indicators are present. With timdedid, ask whether a tool invocation fetched or executed the referenced script. Neither question can be answered by a model download count.

A Normal Reply Is Not a Safety Test
#

A quick chat is a poor acceptance test for a model package. A conditional template can behave normally until a trigger appears, while a file can contain unused bytes without changing the visible answer. Malspark reports both patterns in its attack-mechanics analysis.

There is also a scope issue with security badges. Hugging Face’s malware-scanning documentation says its malware scanner processes repository files smaller than 2 GB and that scanning is triggered on commits. That documented scope is not a promise that every large model artifact, template behavior or downstream execution path has been cleared.

The investigation introduces a scanner, GGUF Radar, that checks templates and file structure and can rebuild files while preserving dequantized weights. It is a potentially useful inspection layer, not a universal safety certificate. The authors distinguish checks that work through remote range requests from checks requiring the complete local file. A clean result must be interpreted against what was actually inspected; I would not promote an unknown artifact solely because one scanner reported no findings.

Make Model Intake a Reviewable Change
#

My recommendation is to treat the deployable unit as weights plus template plus runtime configuration plus tool policy, not just a model filename. A workable intake process does not need to start with a large platform project:

  1. Record provenance and exact bytes. Capture the canonical upstream, the community uploader or converter, repository revision, filenames and cryptographic hashes. A digest proves that bytes match an approved artifact; it does not prove that the artifact was benign when approved.
  2. Review the effective template separately. Compare it with the expected model-family format and inspect conditional branches, added system messages and command-like content. Where the runtime supports an external template override, pin a reviewed, compatible template and verify that the override is actually active.
  3. Inspect the complete artifact where feasible. Use structural inspection and endpoint-security tooling together. Unexpected appended content or suspicious metadata deserves investigation, not an improvised attempt to execute or unpack it on a developer laptop.
  4. Evaluate without useful privileges. Use an isolated environment without production credentials, personal browser profiles or a general-purpose shell exposed to the model. Test rendered prompts and proposed tool calls, not only the friendliness of the answer.
  5. Require review when the package changes. Replacing a template is a security-relevant update even if the weights are unchanged. Promote the reviewed combination into an internal registry rather than silently following a moving repository revision.

The last execution boundary needs independent enforcement. A model’s claim that a command is a mandatory repair step must not grant it shell access. The same separation between a model and its authorized tools underpins production-agent architecture: policy should be enforced by the application, not delegated to persuasive text inside the model’s context.

If an Affected Model Reached Your Machines
#

Start with an inventory, not an infection announcement. Identify the repository, downloaded revision, local hashes, effective template and whether the model was connected to execution tools. Preserve relevant files and logs without running the suggested commands.

Use the investigation’s recommendations and indicator table as starting evidence for endpoint triage. Review process creation, script execution, agent tool logs and persistence findings. Separate downloaded, loaded, produced malicious instructions, and executed a payload in the incident record; they represent different levels of exposure.

If execution is confirmed or strongly suspected, isolate the endpoint and follow your incident-response procedure, including assessment of accessible credentials. Deleting the GGUF file or changing its template is not evidence that an executed implant has been removed. Conversely, finding the model in a cache is not by itself proof that credentials were stolen.

My Take
#

The useful lesson is not that local AI is inherently unsafe. It is that locality and trust solve different problems. Moving inference off a hosted API does not remove the need to review the package that constructs its prompts, or to constrain the tools acting on its output.

I would put template review and artifact pinning ahead of another round of reassuring demo prompts. They create an auditable answer to “what did we approve?” Independent execution controls answer the equally important question: “what could it do if that approval was wrong?”

A model should be able to suggest a command without being able to authorize it. Keeping that distinction intact is the practical defense here—and it remains useful even when the next poisoned package uses a different hiding place.

Supply Chain Security - This article is part of a series.
Part : This Article

Related