LLama Factory Remote OS Command Injection Vulnerability
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
bashpython3 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)
Czego dotyczy
Kliknij technologię, aby zobaczyć wszystkie dotyczące jej podatności.
| Platforma | Paczka | Podatne wersje | Poprawka w wersji |
|---|---|---|---|
| Python (PyPI) | llamafactory | < 0.9.1 | 0.9.1 |
Odnośniki
- https://github.com/hiyouga/LLaMA-Factory/security/advisories/GHSA-hj3w-wrh4-44vp
- https://nvd.nist.gov/vuln/detail/CVE-2024-52803
- https://github.com/hiyouga/LLaMA-Factory/commit/b3aa80d54a67da45e9e237e349486fb9c162b2ac
- https://gist.github.com/superboy-zjc/f2d2b93ae511c445ba97e144b70e534d
- https://github.com/hiyouga/LLaMA-Factory
- https://pypi.org/project/llamafactory
- https://github.com/advisories/GHSA-hj3w-wrh4-44vp
- Wektor CVSS
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N- Słabość (CWE)
CWE-78, CWE-79- Platforma
- Python (PyPI)
- Paczka
llamafactory- Ujawniono
- 21.11.2024
- Aktualizacja
- 11.10.2026 13:19
Źródła i licencje
OSV / GitHub Advisory Database - PYSEC-2026-1575 - PyPA Advisory Database; CC BY 4.0
OSV / GitHub Advisory Database - GHSA-hj3w-wrh4-44vp - CC BY 4.0
Historia podatności: llamafactory
Wszystkie opisane podatności tej paczki (Python (PyPI)), od najnowszej. Widać, czy to jednorazowa wpadka, czy paczka, której trzeba pilnować.
- Wszystkich wpisów
- 4
- Pierwsza → ostatnia
- 11.2024 10.2025
- Bez poprawki
- 1
- Wykorzystywana w atakach
- 0
Rozkład istotności
- Wysoka 3
- Średnia 1
Ujawnienia w latach
- 2024: 1
- 2025: 3
- 2026: 0
-
LLama Factory Remote OS Command Injection Vulnerability ten wpis
Dowiedz się, które podatności dotyczą Twojej aplikacji
Po podłączeniu integracji DockRay i włączeniu raportowania oprogramowania DockRay porównuje zgłoszone wersje komponentów ze znanymi podatnościami i powiadamia o potwierdzonych dopasowaniach. Zakres zależy od obsługiwanej technologii i dostępnych biuletynów.