7.5high
LLama Factory Remote OS Command Injection Vulnerability
- Severity
- 7.5high CVSS:3.1 by GitHub_M
- Exploit likelihood
- 2.99% (higher than 88% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-hj3w-wrh4-44vpPYSEC-2026-1575
Description
LLama Factory enables fine-tuning of large language models. 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. This vulnerability is fixed in 0.9.1.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| hiyouga LLaMA-Factory | < 0.9.1, before 0.9.1 | CVE List, NVD |
| llama-factory llama-factory | before 0.9.1 | CVE List |
| llamafactory (PyPI) | before 0.9.1 | GitHub Advisory Database, PyPA Advisory Database |
All scores
| GitHub_M | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N |
| GitHub | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N |
| NVD | 9.8critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| PyPA Advisory Database | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N |
Classification
What each source says
CVE List
LLama Factory enables fine-tuning of large language models. 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. This vulnerability is fixed in 0.9.1.
GitHub Advisory Database
Summary
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.
Affected Version
Llama Factory versions <=0.9.0 are affected by this vulnerability.
Impact
Exploitation of this vulnerability allows attackers to:
- Execute arbitrary OS commands on the server.
- Potentially compromise sensitive data or escalate privileges.
- Deploy malware or create persistent backdoors in the system.
This significantly increases the risk of data breaches and operational disruption.
Root Cause
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()
Proof of Concept (PoC)
Steps to Reproduce
-
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.
Remediation Recommendations
Avoid using shell=True in Popen.
- Instead, pass the command and its arguments as a list. This prevents user inputs from being executed as part of a shell command.
cmd = [
"llamafactory-cli",
"train",
*save_cmd(args).split(),
]
self.trainer = Popen(cmd, env=env)
NVD (es)
LLama Factory permite el ajuste fino de modelos de lenguaje de gran tamaño. Se ha identificado una vulnerabilidad crítica de inyección remota de comandos del sistema operativo en el proceso de entrenamiento de LLama Factory. Esta vulnerabilidad surge del manejo inadecuado de la entrada del usuario, lo que permite que actores maliciosos ejecuten comandos arbitrarios del sistema operativo en el sistema host. El problema se debe al uso inseguro de la función `Popen` con `shell=True`, junto con una entrada del usuario no desinfectada. Se requiere una solución inmediata para mitigar el riesgo. Esta vulnerabilidad se solucionó en la versión 0.9.1.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2024-52803 changed 2024-11-21 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-hj3w-wrh4-44vp changed 2026-07-07 | CC-BY-4.0 |
| NVD | CVE-2024-52803 changed 2026-06-17 | Public domain |
| PyPA Advisory Database | PYSEC-2026-1575 changed 2026-07-07 | CC-BY-4.0 |