# CVE-2024-52803: LLama Factory Remote OS Command Injection Vulnerability

> Attackers can execute arbitrary OS commands on the host system via unsanitized input in the training process of this LLM fine-tuning library.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 21 Nov 2024
- **Updated:** 21 Nov 2024
- **Also known as:** GHSA-hj3w-wrh4-44vp, PYSEC-2026-1575

## What is CVE-2024-52803?

CVE-2024-52803 is a high-severity command injection vulnerability in hiyouga LLaMA-Factory, published on 21 Nov 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official 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.

Weakness: CWE-78 (Improper Neutralization of Special Elements used in an OS Command), CWE-79 (Improper Neutralization of Input During Web Page Generation)

## Which versions are affected by CVE-2024-52803?

3 open source packages ship an affected version, including llamafactory. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `llamafactory` | PyPI | All versions | 0.9.1 |
| `llamafactory` | PyPI | All versions | 0.9.1 |
| `llamafactory` | PyPI | All versions | 0.9.1 |

Products: Hiyouga Llama-Factory.

## How do I fix CVE-2024-52803?

Upgrade llamafactory to 0.9.1 or later.

## Is CVE-2024-52803 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-52803 exists.

## Other vulnerabilities in hiyouga LLaMA-Factory

- [CVE-2026-58116](https://insights.sbomify.com/CVE-2026-58116/): LLaMA-Factory 0.9.5 Remote Code Execution via WebUI Model Path (critical 9.3)
- [CVE-2025-53002](https://insights.sbomify.com/CVE-2025-53002/): LLaMA-Factory Remote Code Execution (RCE) Vulnerability (high 8.3)
- [CVE-2025-61784](https://insights.sbomify.com/CVE-2025-61784/): LLaMA Factory's Chat API has Critical SSRF and LFI Vulnerabilities (high 7.6)
- [CVE-2025-46567](https://insights.sbomify.com/CVE-2025-46567/): LLaMA-Factory Allows Arbitrary Code Execution via Unsafe Deserialization in Ilamafy_baichuan2.py (medium 6.1)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-52803 and fix it if it is affected.

What it is: CVE-2024-52803 is a high-severity command injection vulnerability in hiyouga LLaMA-Factory, published on 21 Nov 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-52803 exists.

Affected packages and fixed versions:
- llamafactory (PyPI): affected all versions; fixed in 0.9.1
- llamafactory (PyPI): affected all versions; fixed in 0.9.1
- llamafactory (PyPI): affected all versions; fixed in 0.9.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-52803/ (Markdown: https://insights.sbomify.com/CVE-2024-52803/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-52803
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-52803
- OSV: https://osv.dev/vulnerability/CVE-2024-52803

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-52803/
Summaries are generated and may contain mistakes; the official description above is the record.
