GitHub Advisoryadvisory · PyPI

GHSA-hj3w-wrh4-44vp LLama Factory Remote OS Command Injection Vulnerability

HIGH Published 2024-11-21 Modified 2025-08-27 Official page ↗
Aliases
CVE-2024-52803
Ecosystem
PyPI
Packages
llamafactory
Severity
High
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
Weaknesses
CWE-78, CWE-79
Reviewed
2024-11-21

Affected packages

• PyPI llamafactory: < 0.9.1 → fixed in 0.9.1

Description

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 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 ```bash 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. ```python cmd = [ "llamafactory-cli", "train", *save_cmd(args).split(), ] self.trainer = Popen(cmd, env=env) ```

Related

Alias · CVE (1)

  • CVE-2024-52803 LLama Factory enables fine-tuning of large language models. vulnerability

Weakness · CWE (2)

  • CWE-78 Improper Neutralization of Special Elements used in an OS Command weakness
  • CWE-79 Improper Neutralization of Input During Web Page Generation weakness

References