# CVE-2025-46567: LLaMA-Factory Allows Arbitrary Code Execution via Unsafe Deserialization in Ilamafy_baichuan2.py

> Attackers can execute arbitrary code by providing malicious .bin files to the LLaMA-Factory library due to unsafe deserialization.

- **Severity:** Medium 6.1 (`CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:L/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 1 May 2025
- **Updated:** 2 May 2025
- **Also known as:** GHSA-f2f7-gj54-6vpv, PYSEC-2026-1574

## What is CVE-2025-46567?

CVE-2025-46567 is a medium-severity unsafe deserialization vulnerability in hiyouga LLaMA-Factory, published on 1 May 2025. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

LLama Factory enables fine-tuning of large language models. Prior to version 1.0.0, a critical vulnerability exists in the `llamafy_baichuan2.py` script of the LLaMA-Factory project. The script performs insecure deserialization using `torch.load()` on user-supplied `.bin` files from an input directory. An attacker can exploit this behavior by crafting a malicious `.bin` file that executes arbitrary commands during deserialization. This issue has been patched in version 1.0.0.

Weakness: CWE-502 (Deserialization of Untrusted Data)

## Which versions are affected by CVE-2025-46567?

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.3 |
| `llamafactory` | PyPI | All versions | 0.9.3 |
| `llamafactory` | PyPI | All versions | 0.9.3 |

Products: Hiyouga Llama-Factory.

## How do I fix CVE-2025-46567?

Upgrade llamafactory to 0.9.3 or later.

## Is CVE-2025-46567 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-46567 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-2024-52803](https://insights.sbomify.com/CVE-2024-52803/): LLama Factory Remote OS Command Injection Vulnerability (high 7.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-46567 and fix it if it is affected.

What it is: CVE-2025-46567 is a medium-severity unsafe deserialization vulnerability in hiyouga LLaMA-Factory, published on 1 May 2025. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-46567 exists.

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

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-2025-46567/ (Markdown: https://insights.sbomify.com/CVE-2025-46567/index.md)
```

## Sources

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

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