Key Takeaways

  • Malspark found five malicious GGUF files among 226,310 GGUF repositories (2.56 PB of weights) after scanning 3,273,389 public Hugging Face repos; those five repos logged 2,428 downloads before being disabled.
  • Attackers combined two techniques: poisoned chat templates (hidden reply prefixes that could execute commands) and hidden executables appended after the last tensor in GGUF files, enabling normal model behavior while carrying a trojan.
  • Provenance and static metadata controls stop most attacks: mirror and pin external models, require signed manifests, and run GGUF scanners such as gguf-radar to detect trailing bytes and suspicious metadata before promotion.
  • Runtime least-privilege is mandatory: run untrusted community models in isolated VMs/containers, restrict filesystem and network access, and enforce constrained tool identities and policy-gated execution to prevent silent escalation.

On November 27, 2026, the Malspark project disclosed five malicious GGUF models on Hugging Face, two of them with a Windows trojan appended after the last tensor. [4][5]

The scan covered 3,273,389 public model repositories, including 226,310 GGUF repos that held 2.56 PB of weights. [7]

All five malicious files were later disabled, but their pages had already logged 2,428 download events. [4][6][7]

The models combined two paths: poisoned chat templates that silently injected commands, and hidden executables that local tools could extract from the GGUF tail. [4][5][8]

Mir2k targeted Windows users with an “ollie” RAT, and timdedid targeted coding agents with terminal and remote tools. [4][5][7]

For teams running llama.cpp, Ollama, LM Studio, or custom agent harnesses, this is a concrete model supply chain compromise. [4][8]

💡 Goal: Assume some community models are hostile, and design tooling so a poisoned GGUF cannot quietly take over agents or workstations. [4][12]

1. Incident recap: what the five malicious GGUF models actually did

Key facts:

  • Scan scope:
    • 3,273,389 public Hugging Face repos.
    • 226,310 GGUF repos, 2.56 PB of weights. [4][7]
  • Static analysis of 572,184 chat templates, no model execution, flagged five GGUF repos as malicious. [7]
  • All five later disabled for policy violations. [3][7]

Two connected attack techniques

  1. Chat template poisoning

    • GGUF stores a Jinja2 chat template at tokenizer.chat_template.
    • Attackers modified it so every request received a hidden prefix.
    • In Mir2k models, the prefix was a PowerShell line that appeared above the visible answer.
    • If users copied that line into PowerShell, it unpacked and executed a Windows binary from the same GGUF file. [4][5][8]
  2. Trojan bytes after the last tensor

    • GGUF loaders such as llama.cpp read only byte ranges declared in the header and ignore bytes beyond the last tensor.
    • Attackers placed the “ollie” Windows RAT in that ignored region.
    • The model loaded and responded normally while carrying a full executable on disk. [7][8]

⚠️ Key point: The weights were valid. The exploit used the container format and template, pieces that many teams never inspect. [4][7]

Who was targeted and how

Malspark attributed two repos to Mir2k and three to timdedid. [4][7]

  • Mir2k campaign

    • Huihui-Qwen3.5-9B-abliterated-GGUF
    • Inkling-2-Mini-Uncensored-GGUF
    • Same Windows “ollie” RAT in the tail.
    • Reply prefix poisoning added later via template update. [4][5][6][7]
  • timdedid campaign

    • Three “qwen3-cyber-uncensored” variants.
    • Byte identical weights, different agent focused templates.
    • Templates instructed terminal capable agents to fetch and execute attacker scripts when trigger phrases appeared. [4][7][8]

Downloads, not victims

  • 2,428 download events across the five repos by November 27, 2026. [4][6][7]
  • Breakdown:
    • Huihui-Qwen3.5-9B-abliterated-GGUF: 1,488 downloads.
    • Inkling-2-Mini-Uncensored-GGUF: 458 downloads.
    • Three timdedid models: remainder. [6][7]
  • Hugging Face counts downloads, not devices or confirmed infections. Victim count is at most this number and probably lower. [3][4][7]

Timeline and stealth

  • Mir2k uploaded the Huihui and Inkling models in late November.
  • Initial revisions already carried the embedded trojan, but with clean templates. [5][8]
  • On November 26, Mir2k updated templates to add the PowerShell prefix, making the trojan reachable through normal chat. [5][7]
  • Early testers could see benign behavior, then later pull a revision that behaved differently, under the same filename and branding. [5][8]

Uncertain impact and missing payloads

  • Reports describe plausible paths to password theft and wallet targeting, but no measured victim count. [1][2][4]
  • For timdedid, the remote second stage payload was not recovered. [4][6][7]

📊 Mini conclusion: Five malicious files among millions is small statistically, but they targeted high demand “uncensored” and “cyber” niches that local LLM users actively seek. Operational risk is real. [7][8]

2. Threat model: model supply chain risk for local LLM stacks

The GGUF case is a classic ML supply chain attack. The attacker uploads a poisoned artifact and waits for someone to pull and run it. [4][5]

Teams that auto download GGUF models into llama.cpp, Ollama, LM Studio, KoboldCpp, or homegrown runners face this risk directly. [4][8]

More broadly, enterprises building conversational AI, AI agents, and agentic AI on top of large language models such as GPT, GPT-4, BERT, and ChatGPT, from providers like OpenAI, led by Sam Altman, and Anthropic, already face threats such as prompt injection, model poisoning, ML supply chain attacks, data exfiltration, and hallucination. DevOps, MLOps, and LLMOps teams manage complex pipelines with Infrastructure as Code, experiment tracking, and continuous monitoring, so this risk belongs in mainstream security strategy.

As Model Context Protocol (MCP) and similar standards let agents coordinate tools across clouds, and as models like o3 or advanced generators reach or exceed GPT-4 level abilities, the blast radius of compromise grows. Hosted routers and orchestration layers that connect LLMs, agents, and downstream tools become part of the security boundary.

From unsafe serialization to poisoned containers

  • JFrog showed that some Hugging Face models using Python pickle could execute arbitrary code during deserialization. [10]
  • In that case, loading the model artifact granted the attacker a shell. [10]
  • The GGUF case extends this pattern:
    • No pickle.
    • Attackers abused GGUF structure and metadata to carry executables and inject malicious instructions that activate under normal use. [4][7][8]

⚠️ Threat class: “Model artifact as executable,” not only “model as text generator.” [4][10]

Specific risk to agentic systems

  • In simple chatbots, malicious templates skew content.
  • In coding assistants or shell agents, model output often flows straight into tools. OWASP calls this unsafe output handling. [9]
  • In the GGUF campaigns, prompt injection was baked into the system prompt via templates, not added by a user query. [7][8][9]
  • For timdedid, trigger phrases like “What is” caused the template to inject a hidden directive to a shell capable agent, instructing it to download and run remote code. [4][8][9]

Cloud and router side exposure

  • Analysis of around 2 million canary prompts sent to inference providers found that some hosts logged or leaked prompts marked for zero data retention. [11]
  • OpenRouter removed three providers and 125 endpoints from zero retention eligibility as a result. [11]
  • This shows that even when you never download weights, you inherit supply chain risk from routing, logging, and vendor practices. [11][12]

Adversaries already experiment with AI

  • Anthropic reports attempts by state sponsored and criminal actors to use LLMs for cyber operations, fraud, and surveillance. [13]
  • As models and tooling become central to workflows, compromising hubs, routers, or templates becomes attractive to such actors. [12][13]

💼 Mini conclusion: Treat model artifacts, templates, hosted channels, and agent tools as potential entry points, especially when outputs can reach shells, build systems, or production data. [9][11][13]

3. Artifact provenance: verifying who you pull from and what you run

Treat GGUF files like binaries or container images, not like static datasets. [10][12]

You would not run a random :latest Docker image from an unknown author in production. Apply the same policy to models. [10][12]

Repository trust policies and mirrors

Malspark found only five poisoned GGUF repos, but all used names like “uncensored,” “abliterated,” or “cyber,” terms that attract users seeking “no guardrails” models. [4][7][8]

Practical defenses:

  • Maintain allowlists of trusted publishers, such as official orgs or vetted community authors. [7][12]
  • Mirror external models into an internal registry; do not pull directly from public hubs in production. [10][12]
  • Pin by checksum and require signed manifests for promoted versions. [10][12]

One midsize SaaS firm discovered engineers copying GGUF URLs from blogs into ollama pull on corporate laptops. Their first fix was an internal model catalog backed by a mirror and scanners, and blocking direct Hub downloads from office networks.

Integrating scanners such as gguf-radar

The Malspark author released gguf-radar, which:

  • Parses GGUF headers and metadata.
  • Detects extra bytes beyond the last tensor.
  • Can reconstruct a clean GGUF that drops trailing payloads while preserving weights. [4][5]

Integrate such tools into CI:

  1. Fetch or mirror the GGUF.
  2. Run gguf-radar or equivalent.
  3. Fail if:
    • there is data past the final tensor, or
    • metadata contains suspicious keys or oversized blobs. [4][5][7]

Every artifact in the loading chain

Earlier malicious cases involved tokenizers and adapter checkpoints using pickle. [10]

Apply provenance controls to:

  • Primary model weights.
  • Tokenizers.
  • LoRA or QLoRA adapters.
  • Custom loaders and inference plugins.
  • Post processing code that runs in process with the model. [10][12]

⚡ Mini conclusion: Govern models like container images. Mirror, sign, and scan them. Make direct Hub pulls into local runners an internal anti pattern. [10][12]

4. Metadata and template review: static defenses against poisoned GGUF

Even with provenance controls, metadata can carry attacks. Malspark statically parsed 572,184 chat templates to find prompt injection patterns without running models. [7][8]

This is cheap and catches reply prefixes and trigger based injections. [7][8]

How the reply prefix worked

  • In Mir2k files, the chat template forced the conversation to begin with a PowerShell command, then the normal answer. [5][8]
  • The hidden command unpacked and ran the “ollie” binary from the GGUF tail. [4][5]

A template auditor can search for:

  • Unconditional shell or PowerShell commands at the start of assistant replies.
  • URLs combined with Invoke-WebRequest, curl, or wget.
  • Instructions to “copy and paste this into your terminal.” [5][8][9]

Regular expressions and Jinja2 AST checks can detect most cases. [8][9]

Agent tool hijacking via templates

  • timdedid templates targeted coding agents with terminal tools.
  • When user input contained phrases like “What is,” the template injected an invisible [SYSTEM DIRECTIVE] to the agent. [4][8]
  • That directive told the agent to invoke a shell tool with attacker commands. [4][8][9]

Therefore, you must audit:

  • Tool wiring metadata.
  • Function calling schemas.
  • System prompts in agent definitions. [9][12]

Input sanitization concepts from web security now apply to templates and tool specs. Normalize encodings, watch for homoglyphs, and block obvious attempts to embed shell instructions in metadata.

Building a template auditing pipeline

A robust GGUF import pipeline should:

  1. Parse GGUF headers and extract tokenizer.chat_template and related fields. [4][7]
  2. Lint templates for:
    • Instructions to execute code.
    • References to shells, registries, or admin consoles.
    • Trigger based hidden system directives. [8][9]
  3. Block promotion if linting fails, unless a human reviewer explicitly approves. [9][12]

OWASP lists prompt injection and insecure output handling as top LLM risks. Static scanning of templates is a form of input validation for models. [9][12]

📊 Mini conclusion: Treat chat templates as code paths that run on every request. If you would not auto merge a third party shell script, do not auto promote an unreviewed template. [7][8][9]

5. Least privilege inference: sandboxing local models and agents

Even with strong provenance and template scanning, some malicious artifacts will pass. Runtime isolation and least privilege are the final barrier. [9][12]

The GGUF case illustrates what happens when a local runner or agent has full workstation access. [4][5][8]

Sandbox the runtime

Analysts report that the “ollie” RAT targeted:

  • Saved browser passwords.
  • Browser based cryptocurrency wallets such as Phantom and MetaMask. [6]

To reduce impact:

  • Run community GGUF models in containers, OS sandboxes, or dedicated VMs. [6][9]
  • Block direct access to browser profiles, password stores, home directories, and wallet files. [6][9]
  • Restrict outbound network access to what the application actually needs. [9][12]

One fintech team had run uncensored models on the same laptops used for personal banking. After the incident, they moved local runners into isolated desktop VMs without shared clipboard or disk mounts.

Least privilege tool wiring

For agent stacks:

  • Give each tool a constrained identity, not a shared wide scope token. [9][12]
  • Examples:
    • Shell tools restricted to a dedicated directory, with read only access elsewhere.
    • Database tools limited to reads or a staging schema.
    • CI tools that open pull requests but cannot merge or deploy without human approval. [9][12][13]
  • Route model suggested commands through a policy engine that treats them as untrusted. This aligns with OWASP guidance on validating LLM outputs before execution. [9]

Guarding secrets in hosted inference

Since some “zero retention” prompts were logged or exposed, teams have been advised to:

  • Rotate all secrets that appeared in those prompts.
  • Reevaluate which tools route through third party hosts. [11]

For both local and hosted LLMs:

  • Never expose production secrets directly to models without additional checks.
  • Use DLP style guards to prevent accidental inclusion of keys or credentials in prompts. [11][12]

Many controls can extend from existing data science, MLOps, and DevOps practice. The same experiment tracking, continuous monitoring, and Infrastructure as Code that govern classic ML now need to cover LLMOps and agentic systems that mix weights, templates, and tools.

⚠️ Mini conclusion: Assume some models and agents will be malicious. Design pipelines so that a single compromised GGUF cannot escalate from a download to a workstation breach or silent data exfiltration.

Conclusion

The malicious GGUF incident shows that:

  • Attackers already weaponize model formats and templates. [4][5][7]
  • Popular community hubs are part of your software supply chain. [4][7][8]
  • Local runners and agent frameworks can turn template level prompt injection into real code execution. [4][8][9]

A practical defense stack combines:

  • Provenance controls: allowlists, mirroring, signatures, and artifact scanners such as gguf-radar. [4][5][10][12]
  • Metadata and template review: static linting of chat templates, system prompts, and tool wiring. [7][8][9][12]
  • Least privilege inference: sandboxed runtimes, minimal tool permissions, and strict handling of secrets and outputs. [6][9][11][12][13]

Treat models as executable artifacts, not just text generators, and extend familiar supply chain and runtime security patterns to LLMs. That approach will not eliminate all risk, but it will turn future malicious GGUF files into contained incidents instead of full scale compromises.

Frequently Asked Questions

How did the malicious GGUF models in the Malspark incident actually deliver malware?
The attack used two coordinated vectors: a poisoned chat template that injected hidden shell commands into assistant replies and a trojan binary placed in bytes after the last tensor in the GGUF container so common loaders ignored it. Static template poisoning provided an execution path (e.g., a PowerShell unpacker embedded in the assistant reply) while the appended bytes held a full Windows RAT; users or automated agents that copied or executed the injected command—or agent tool wiring that forwarded model output directly to a shell—could unpack and run the payload even though the model weights themselves were valid.
What provenance and static checks should teams enforce before using community GGUF models?
Treat models like container images: only promote artifacts from allowlisted publishers or an internal mirror, pin by checksum, require signed manifests, and block direct public-hub pulls in production environments. Integrate static tools (for example, gguf-radar) into CI to parse GGUF headers, fail builds if there are bytes beyond the last tensor or suspicious metadata blobs, lint tokenizer.chat_template and tool wiring for shell commands or hidden system directives, and require human review for any template or metadata flagged by automated checks.
What runtime defenses prevent a compromised GGUF from becoming a workstation breach?
Assume some models will be malicious and enforce least-privilege inference: run untrusted GGUFs inside dedicated VMs, OS sandboxes, or containers with no access to browser profiles, password stores, or home directories; restrict outbound network access and disallow shared clipboards or host mounts for untrusted runners. Additionally, implement constrained tool identities (narrow scopes, directory-limited shells, read-only DB access), route model-suggested actions through a policy engine that treats outputs as untrusted before execution, and rotate any secrets that may have been exposed to third-party inference endpoints.

Sources & References (13)

Key Entities

💡
scan scope: 3,273,389 public model repositories
Concept
💡
chat template poisoning
Concept
💡
PowerShell prefix
Concept
💡
GGUF
WikipediaConcept
💡
download events (2,428)
Concept
💡
trojan bytes after the last tensor
Concept
💡
226,310 GGUF repos / 2.56 PB of weights
Concept
🏢
Hugging Face
WikipediaOrg
🏢
Malspark project
Org
📌
ollie
other
👤
Mir2k
Person
👤
timdedid
Person
📦
qwen3-cyber-uncensored (variants)
Produit
📦
Huihui-Qwen3.5-9B-abliterated-GGUF
Produit
📦
llama.cpp
WikipediaProduit

Generated by CoreProse in 3m 37s

13 sources verified & cross-referenced 2,306 words 0 false citations

Share this article

Generated in 3m 37s

What topic do you want to cover?

Get the same quality with verified sources on any subject.