Elith日本語版
Menu

AI Model Supply Chain Security: A Case of GGUF Chat Templates Used for Attacks, and What to Check Before Bringing a Model In

We sort out, from primary sources, the five GGUF models on Hugging Face that Malspark reported on November 27, 2026: instructions added through the chat template, an executable appended at the end of the file, the two accounts' timeline, the status as of November 30, and four checks before bringing a model in.

Published
{minutes} min read
7 min read
Abstract 3D illustration of a stack of white plates floating inside a translucent rounded panel, with a small gray block attached to the right edge of the stack, a thin light-blue line running from the top plate to a small white block outside on the right, and a thin orange line entering the stack from the left

A model file for a locally run LLM holds more than weights. It also carries a chat template that formats the conversation, among other things. On November 27, 2026, Malspark, a malware analysis tool project, reported that it had found five GGUF models published on Hugging Face that used this template to add attack instructions (Malspark's report). The counts and analysis results in this article come from Malspark's report. What the editorial team confirmed from Hugging Face's public information is described in the section "Current status." We lay out this case as an example of AI model supply chain security: a model file carries instructions as well as data.

What happened: two accounts and two methods

According to Malspark, on November 26 the project scanned all 3,273,389 public model repositories on Hugging Face. Of these, 226,310 were GGUF repositories, and it analyzed 572,184 chat templates without executing them. After manual review, five repositories from two accounts remained. The five had 1,502 downloads in total at the time of the scan on November 26, and 2,428 as of November 27 (Malspark's report, "1. Summary" and "3. Scan Results Across 3.27 Million Repositories"). The report notes that this counts downloads, not people, so the number of affected users is equal to or lower than that. The report's title says "2400+ Victims," but what its body gives is this download count.

Adding instructions through the template

GGUF metadata has a key named tokenizer.chat_template, which holds the template that turns a conversation into the text passed to the model. According to Malspark, the models it found used the template's ordinary features to add text to the conversation that never appears in the chat window. They do not execute operating system commands directly from the template. The report points out that this method is not limited to GGUF, because models in the Safetensors and PyTorch formats carry the same kind of template in a separate file (ibid., "2.1 The Chat Template").

Placing an executable after the weights

Under the GGUF specification, a file is laid out in this order: the header (which includes the metadata key-value pairs), the tensor information, padding, and the tensor data (GGUF specification). According to Malspark, runtimes such as llama.cpp and LM Studio read only the ranges the header points to and ignore everything else. The attacker appended an executable after the last tensor (Malspark's report, "2. Attack Mechanics" and "2.2 Bytes After the Last Tensor").

The report says this appending is not possible with Safetensors. The Safetensors specification requires that the data area be entirely referenced by tensors and that it contain no holes (Safetensors README). As noted above, however, mixing instructions into a template works regardless of the format.

Diagram of the layout of a GGUF file and the Mir2k timeline, headed: Two parts of a GGUF file were abused, the template and the tail. The subtitle says it shows the method of the two Mir2k models among the malicious models Malspark found on Hugging Face (per Malspark's analysis). The upper part shows the file layout from left to right: header, metadata, tensor info table, padding, weights, and bytes appended after the weights. Two places are highlighted: tokenizer.chat_template inside the metadata, and the appended bytes at the tail. The first, the template, adds instructions the user never sees to the text the model reads. The second, the tail, is where an executable is appended; runtimes do not read this part. The lower part is the timeline. November 22: the first model was published with an executable at the tail (the account had 14 repositories, 12 of them empty). November 24: the second model was published with the same executable, compressed, at the tail. November 26: the templates of both models were rewritten, and rewritten again the same day. November 27: total downloads of the five repositories (two accounts) were 2,428. As checked on November 30: access was disabled on all five (shown by Hugging Face). There are three notes. 2,428 counts downloads, not people, and the report gives no number of infected machines. The template makes the model print one PowerShell line in its replies, and the executable does not start unless the user runs that line. Counts, methods and timeline are from Malspark's report, and the disabled status on November 30 was checked through the Hugging Face API and model pages
Figure 1: The two parts of a GGUF file that were abused (the template and the tail) and the Mir2k timeline (prepared by Elith from Malspark's report, the GGUF specification, and Hugging Face's public information)

What the two accounts did

For the first account, Mir2k, Malspark gives the following order of events from the repository history. On November 22, the first model was published with an executable already appended at its end. On November 24, the second model was published with the same executable in compressed form. In both, the template was still the original one at that point. On the morning of November 26, the templates of both models were rewritten to tell the model to begin every reply with one PowerShell line. That line reads the end of the model file back out and starts it as an executable. According to the report, the templates were rewritten again nine hours later. The report says files downloaded before November 26 contain the executable but not the trigger. The report also says the account had 14 repositories, 12 of which were empty and named after models expected to be released (ibid., "3.1 Campaign 1: Mir2k, Plant First and Arm Later").

As the result of analyzing this executable without running it, Malspark lists capabilities including remote control, collection of passwords saved in browsers, keylogging, and cryptocurrency mining (ibid., "1. Summary" and "3.1.1 The ollie Implant"). The report does not state how many times it actually ran on users' machines.

The second account, timdedid, published three copies of the same model on November 21 and 22. When the user's latest message contains a specific phrase, the template inserts a fake system directive that tries to make an agent able to call PowerShell download and run an external script. The report says the script that would follow was not recovered, so what it would have installed is unknown (ibid., "3.2 Campaign 2: timdedid, Hijacking Coding Agents").

With either method, simply loading the model file does not run the executable. Either the user has to run the command the template makes the model print, or an agent with tool access has to follow the instruction.

Current status: access to all five is disabled

On November 30, 2026, the editorial team checked the five repositories named in the report through Hugging Face's public API and the model pages. The API returned disabled: true for all five. Each page shows "Access to this model has been disabled" together with a notice that the content infringes the content policy (Hugging Face Content Policy). The creation dates returned by the API are November 22 and 24 for the two Mir2k repositories and November 21 and 22 for the three timdedid repositories, which matches the timeline in the report. The download counts returned by the API totaled 4,221. This, too, counts downloads, not people. That is as far as the editorial team checked; we did not examine the contents of the model files or the executable.

Both modifying templates and hiding malicious code in model files have precedents in research (Pillar Security, EvilModel). Malspark says what its report adds is the method seen in real attacks on Hugging Face, and Mir2k's combination of an executable at the end of the file with a template switched on days later, for which it found no earlier public report (Malspark's report, "2.3 Prior Work").

Malspark has also published gguf-radar (GitHub), an open-source tool that inspects templates and trailing data without executing them, along with detection rules. The editorial team has not tested this tool. For an investigation, please refer to the original report.

What to check before bringing a model in, as AI model supply chain security

Companies that bring external models in-house should check the following points.

  1. Do you inspect the contents of the chat template of each model you bring in? For cases where the model has access to tools, Malspark lists one countermeasure: specifying a reviewed template on the runtime side (--chat-template-file in llama.cpp, or TEMPLATE in an Ollama Modelfile).
  2. Do you check whether any data has been appended after the last tensor?
  3. Do you avoid giving strong privileges, such as shell execution, to agents that use local models? Is anyone running commands suggested by a model without checking them?
  4. Do you record where each model came from, and the date and version you took in? The templates of the two Mir2k models were rewritten after publication, so the contents of the same repository differed depending on when it was downloaded.

The point that an AI ends up following instructions slipped in from outside is shared with prompt injection countermeasures and the supply chain of AI agent skills.

A model file is not just a set of weights; it also carries instructions. Inspecting the parts other than the weights before bringing a model in is the place to start.

Elith builds AI products for enterprises and conducts advanced research on a foundation of AI safety and security. We share trends in AI safety and security and insights from research and practice in Elith AI Signal. We will keep reading reports like this one against primary sources and reporting on them for those bringing AI into their work.

Sources

  1. Malspark, GGUF LLM Models with Hidden Malware on Hugging Face Reached 2400+ Victims (November 27, 2026)
  2. ggml, GGUF specification (docs/gguf.md, commit of November 8, 2026)
  3. safetensors, README (commit of November 20, 2026)
  4. Hugging Face, Content Policy
  5. Pillar Security, LLM Backdoors at the Inference Level: The Threat of Poisoned Templates (July 9, 2025)
  6. arXiv:2107.08590, EvilModel: Hiding Malware Inside of Neural Network Models (submitted July 19, 2021)
  7. gguf-radar (the detection tool the Malspark report points to, GitHub repository)