Jailbreak AI model hides trojan! Teach you to scan, remove viruses, and use local AI safely.

CN
33 minutes ago

WmJuh88UB6HZryTmVEDAOHVKziZBuGrRmhVYJp_J9xk.jpg

KGJxoN2EqwlRXhrgohb0gzjEfrbeEliTEgmAI7sO02E.jpg

More and more users are choosing to install large language models (LLM) on their own computers. Besides being able to use it offline, ensuring privacy, and saving cloud service costs, another reason is to escape the content censorship of AI services and use AI models that have been "jailbroken". On the large AI model sharing platform Hugging Face, it is not difficult to find third-party modified models that claim to be Uncensored or Abliterated. However, downloading these models may also pose security risks, even leading to computers being infected with Trojan programs.

H1hA-xS9-jXjxQKqU5a2tWMY0gqlytDjJjIwZHUif-A.png

Hugging Face Discovers 5 Malicious AI Models

The open-source malware analysis project Malspark published a research report on November 27, revealing that researchers found the following five GGUF models containing malicious content after scanning over 3.27 million public model repositories on Hugging Face.

As of the publication of the research report, the involved models had recorded a total of 2,428 downloads, but the actual number of infected users remains unknown. The aforementioned five model repositories have now been disabled.

How is Malware Hidden in GGUF Models?

GGUF is a commonly used file format for local AI models, widely applied in inference tools like Ollama, LM Studio, and llama.cpp. GGUF files not only store model weights but also include metadata and chat templates, the latter responsible for converting user inputs and system prompts into the format required by the model.

Attackers exploit the feature of GGUF loaders that typically do not process end data except for model weights, hiding Trojan programs at the end of the file and modifying the chat template to implant hidden instructions within the model. Since the model weights are not compromised, even if a Trojan is embedded, the model can still be loaded and answer questions normally, which may not raise user suspicion.

Using AI to Induce Users to Execute Trojans

Researchers found that two models released by the Mir2k account were hiding a Windows Remote Access Trojan (RAT) named ollie, which has functionalities such as stealing browser passwords, cryptocurrency wallet data, recording keyboard inputs, capturing screenshots, and mining. The attackers modified the chat template to make the AI output malicious PowerShell commands when answering questions. Once users mistakenly think this is a normal command and execute it, the Trojan hidden in the GGUF file may be released and activated.

Another account, timdedid, targeted AI Agents with system operation permissions, using hidden prompts to hijack calls from the agent's tools, inducing the AI to download and execute external malicious scripts even without user intervention. This attack method does not rely on exploiting program vulnerabilities in the AI inference engine but uses users' trust in AI responses and the system operation permissions held by the AI Agent.

Guide: Using GGUF Radar to Scan Local AI Models

Researchers have simultaneously launched a free open-source GGUF Radar scanning tool that can check whether malicious programs, suspicious chat templates, and abnormal data are hidden in GGUF files without executing the AI models.

Step 1: Install Python

Visit the official Python website to download and install Python. Windows users should remember to check "Add Python to PATH" during installation.

Download link: https://www.python.org/downloads/

Step 2: Install GGUF Radar

Open Windows PowerShell and enter the following command to install GGUF Radar:

python -m pip install gguf-radar

Official GitHub: https://github.com/Root0ne/gguf-radar

Step 3: Scan GGUF Models

In PowerShell, navigate to the folder where the AI models are stored, for example:

cd "C:\AI\models"

Then enter the following command, replacing model.gguf with the actual file name of the model:

gguf-radar scan ".\model.gguf"

If the model consists of multiple GGUF files, each split file should be scanned individually. If the system cannot find the gguf-radar command, you can use the full path to its .exe executable instead.

Step 4: View Scan Results

As shown in the figure, the author tested a version of the Qwen3.8 Flash Next model that has undergone Abliterated processing, scanning two GGUF split files of approximately 55.06GB and 28.80GB, both of which displayed the green CLEAN label, indicating that the scanning tool did not detect any known malicious or suspicious content.

CLEAN in the scan results means no anomalies were found, SUSPICIOUS indicates the presence of suspicious content, and MALICIOUS means detected malicious content. If ERROR is displayed, it indicates that an error occurred during the scanning process.

It is worth noting that some quantized models may contain unused data bits, and GGUF Radar will also show relevant prompts, but this does not necessarily mean the model contains malicious software.

Step 5: Generate a Clean Version of the GGUF Model

If suspicious data is found within the model file, GGUF Radar also provides a sanitize function to re-establish a clean version of the GGUF model, removing extraneous data from the end of the file and clearing unused bits from the quantized weights, all while maintaining the actual values of the model weights.

In PowerShell, enter the following command:

gguf-radar sanitize ".\model.gguf" -o ".\model-clean.gguf"

Once completed, the tool will generate a new file named model-clean.gguf and retain the original model. Users should ensure they have enough hard drive space to store the new file.

However, this function will by default retain the original Chat Template, so even if the Trojan hidden in the file is cleared, there may still be malicious prompts present.

Step 6: Compare If the Chat Template Has Been Modified

Even if the scan results show CLEAN, users can use the compare-template function to compare the chat templates within third-party models with the original version to check if any additional instructions have been added.

Taking Qwen2.5-0.5B-Instruct as an example:

gguf-radar compare-template ".\model.gguf" --base Qwen/Qwen2.5-0.5B-Instruct

Users need to replace the name after --base with the corresponding Hugging Face official model repository. The tool will retrieve the original chat template and compare it with the local GGUF model.

The comparison results are divided into four types:

IDENTICAL: The chat templates are identical.

OLDER: Consistent with an earlier version of the original chat template.

DIFFERENT: There are differences in the chat templates that require further inspection.

ERROR: Unable to complete the comparison.

If there are differences in the chat templates, the tool will list the added and deleted content for users to check for suspicious instructions. However, some third-party model authors may also modify chat templates to fix bugs or improve tool calling functions, so differences do not necessarily indicate that the model contains malicious content.

Step 7: Remove or Replace Suspicious Chat Template

If it is found that the chat template contains malicious instructions, the --strip-template parameter can be added when generating the clean version of the model to remove the built-in chat template.

gguf-radar sanitize ".\model.gguf" -o ".\model-clean.gguf" --strip-template

However, removing the chat template may affect the model's dialogue format and tool calling functionality. Therefore, a more ideal method is to obtain a trusted chat_template.jinja file from the original model and then use the following command to replace the existing template:

gguf-radar sanitize ".\model.gguf" -o ".\model-clean.gguf" --replace-template ".\chat_template.jinja"

Afterward, scan the newly generated model again:

gguf-radar scan ".\model-clean.gguf"

It is worth noting that the sanitize function is not an all-powerful detox tool, and it cannot guarantee that the model weights themselves have not been poisoned or backdoored. If the model has been confirmed to contain malicious software, the safest course of action is still to stop using it and re-download it from a reliable source.

Will Using Ollama, LM Studio, llama.cpp Get Infected?

In this incident, simply loading the involved GGUF models through Ollama, LM Studio, or llama.cpp will not directly activate the Trojan hidden in the file. The real risk lies in users executing the malicious commands provided by the AI or allowing the AI Agent to automatically execute system commands.

Even using AI models in offline environments does not mean there are absolutely no security risks, as some malware may already be hidden in the local model files, requiring no downloads from the internet.

How to Choose a Reliable Local AI Model?

It is recommended that users prioritize versions released by the model developer's official repository, or those offered by third-party quantization model authors with a long track record and good community reputation. If wanting to use a model that removes censorship mechanisms, users should also pay attention to the publisher's account history, model source, modification methods, and community discussions, avoiding judging security based solely on the model name and download count.

After downloading the model, it is best to use GGUF Radar to perform a scan first and keep the inference tools updated. When using AI Agents, restrict their file access and system command execution permissions to avoid letting AI execute programs without verification.

While GGUF Radar can assist in detecting malicious content, normal scan results do not mean the model is 100% secure. Downloading models from reliable sources remains the first line of defense for ensuring computer security.

This article is reprinted from PCM, with copyright owned by the original author and original media.

免责声明:本文章仅代表作者个人观点,不代表本平台的立场和观点。本文章仅供信息分享,不构成对任何人的任何投资建议。用户与作者之间的任何争议,与本平台无关。如网页中刊载的文章或图片涉及侵权,请提供相关的权利证明和身份证明发送邮件到[email protected],本平台相关工作人员将会进行核查。

Share To
APP

X

Telegram

Facebook

Reddit

CopyLink