Security researchers have uncovered a new wave of open-source supply chain attacks targeting users who run artificial intelligence models locally. Attackers published poisoned model files to Hugging Face and mirrored them on the Ollama registry, tricking desktop users into fetching malware and executing compromised chat templates.

The campaign specifically exploits GGUF format files, a popular standard used by local runtimes such as llama.cpp, LM Studio, and Ollama. By abusing unused binary space within model containers and manipulating chat templates, threat actors managed to reach thousands of local PC deployments before initial platform takedowns began.

Malicious Hugging Face Malicious AI Models Ollama Threat Landscape

A recent scan of more than 3.2 million public repositories on Hugging Face identified multiple malicious GGUF repositories created by accounts operating campaigns such as Mir2k and timdedid. The affected repositories had accumulated over 2,400 downloads before being disabled. However, security analysts noted that copies of these files quickly surfaced on the public registry for Ollama, where they remained accessible to local desktop users.

Running large language models locally has exploded in popularity as users seek privacy and offline availability. Runtimes like Ollama simplify this process by letting developers pull model weights directly into desktop environments, including Windows 11 systems. The discovery highlights how attackers are weaponizing open-weight platforms to breach environments that traditional network boundary tools often consider trusted.

Malicious GGUF Models Surface on Hugging Face and Ollama

The technical structure of the GGUF file format plays a central role in how these malicious files operate without triggering initial format checks. GGUF files bundle weight matrices with metadata instructions. When local runtimes load a GGUF file, they parse defined header segments to extract tensor arrays while leaving unindexed trailing data intact on disk.

Attackers took advantage of this design by appending a full Windows Remote Access Trojan (RAT) payload directly after the final tensor block inside the model container. Because local tools like llama.cpp only read the specific memory locations defined by the tensor header index, the appended binary code does not interfere with the text generation performance of the underlying neural network.

Exploiting Chat Templates to Execute Remote Scripts

To deliver the hidden binary payload from the disk to execution memory, threat actors altered the chat template embedded within the GGUF metadata. Chat templates use the Jinja2 engine to format raw text exchanges into structured dialogue tokens.

In the observed attacks, the malicious templates were programmed to prepend malicious command strings to model output responses. When a user asked the AI model for help with system configuration or command line syntax, the output would display a pre-formulated PowerShell script disguised as standard instructions. If executed by the user, the script extracted the appended executable from the local GGUF file path directly onto the host PC.

How Poisoned AI Models Target Local PC Environments

The reliance on user interaction or automated AI agents makes this threat vector particularly subtle. Many developer setups use local models alongside shell integration tools or task execution software. When a model altered by a malicious chat template issues system instructions, automated agents or unsuspecting developers may run those commands directly in a local terminal.

System administrators who maintain desktop deployments should note that local model files can bypass basic security assumptions if the underlying host hardware is unmonitored. While Microsoft continues to optimize core OS components and reduce background memory usage in Windows 11, endpoint security tools still rely heavily on behavioral file scanning to catch post-execution scripts.

Risks to Local LLM Runtimes and Desktop Security

The key security risks identified in local LLM deployments include:

  • Arbitrary File Appending: Malicious binaries can hide within GGUF metadata or post-tensor file space without altering normal model execution.
  • Inference-Time Prompt Poisoning: Chat templates can force models to generate deceptive PowerShell or Bash commands designed to compromise the host PC.
  • Cross-Platform Mirroring: Takedowns on one platform, such as Hugging Face, do not automatically purge mirrored model instances hosted on alternative registries like Ollama.
  • Agent Exploitation: Automated coding assistants or autonomous task runners reading model output may execute system-level commands without human confirmation.

Platform Response and Security Recommendations for Users

Following disclosures from security researchers, Hugging Face disabled the reported repositories linked to the malicious accounts. Platform security teams continue to refine scanning tools to detect anomalous trailing data and suspicious Jinja syntax inside uploaded model artifacts.

However, security experts emphasize that static scans alone cannot catch every variation of poisoned metadata. Organizations running local AI workflows are advised to audit all GGUF dependencies, pin model release hashes, and restrict terminal permissions for AI agent frameworks.

Users running local models via Ollama or custom local runtimes should inspect model provenance before execution. Running local inference engines within isolated containers or virtual machines remains the most effective defense against unverified model binaries. As open-source AI adoption grows, verifying the safety of open-weight files is now as critical as securing traditional software dependencies.