CVE-2024-52803High· 7.5▾ TwilightLLama Factory Remote OS Command Injection Vulnerability
▾ Twilight zone — High severity, or a signal on a lesser flaw
impact 41.3 · likelihood 0.5 · exploitation 0
Need a working PoC? Pro members can cast a request and our team develops one — it lands right here.
Exploit-prediction probability, daily snapshots since Jul 8.
Disclosure to exploitation, from the record and what we observed since indexing it.
Disclosed via OSV
Last analysed / modified upstream
2.3%
2.3% → 2.3%
A critical remote OS command injection vulnerability has been identified in the Llama Factory training process. This vulnerability arises from improper handling of user input, allowing malicious actors to execute arbitrary OS commands on the host system. The issue is caused by insecure usage of the Popen function with shell=True, coupled with unsanitized user input. Immediate remediation is required to mitigate the risk.
Llama Factory versions <=0.9.0 are affected by this vulnerability.
Exploitation of this vulnerability allows attackers to:
This significantly increases the risk of data breaches and operational disruption.
The vulnerability originates from the training process where the output_dir value, obtained from the user input, is injected into the popen function without any sanitization. Furthermore, popen is invoked in a unsafe way by enabling the interact shell (shell=True), leading to remote OS command injection vulnerability.
Vulnerable snippet:
# https://github.com/hiyouga/LLaMA-Factory/blob/bd639a137e6f46e1a0005cc91572f5f1ec894f74/src/llamafactory/webui/runner.py#L304-L323
def _launch(self, data: Dict["Component", Any], do_train: bool) -> Generator[Dict["Component", Any], None, None]:
...
args = self._parse_train_args(data) if do_train else self._parse_eval_args(data)
...
self.trainer = Popen(f"llamafactory-cli train {save_cmd(args)}", env=env, shell=True)
yield from self.monitor()
Deploy llama factory
Execute the exploitation script from: https://gist.github.com/superboy-zjc/f2d2b93ae511c445ba97e144b70e534d
python3 llama-factory-rce.py --url http://127.0.0.1:7861 --cmd "curl XXX" --trace

Bad actors are able to execute any OS command as they want.
Avoid using shell=True in Popen.
cmd = [
"llamafactory-cli",
"train",
*save_cmd(args).split(),
]
self.trainer = Popen(cmd, env=env)
llamafactory < 0.9.1Upgrade to a patched release:
llamafactory 0.9.1Connected by shared product, vendor, weakness, or advisory.
CVE-2025-53002High· 8.3LLaMA-Factory allows Code Injection through improper vhead_file safeguards
CVE-2025-46567Medium· 6.1LLaMA-Factory Allows Arbitrary Code Execution via Unsafe Deserialization in Ilamafy_baichuan2.py
CVE-2025-61784High· 7.6LLaMA Factory's Chat API Contains Critical SSRF and LFI Vulnerabilities