{"id":"CVE-2025-53002","aliases":["CVE-2025-53002","GHSA-xj56-p8mm-qmxj","PYSEC-2026-1576"],"related":[],"kind":"vulnerability","state":"published","title":"LLaMA-Factory Remote Code Execution (RCE) Vulnerability","summary":"LLaMA-Factory is a tuning library for large language models. A remote code execution vulnerability was discovered in LLaMA-Factory versions up to and including 0.9.3 during the LLaMA-Factory training process. This vulnerability arises because the `vhead_file` is loaded without proper safeguards, allowing malicious attackers to execute arbitrary malicious code on the host system simply by passing a malicious `Checkpoint path` parameter through the `WebUI` interface. The attack is stealthy, as the victim remains unaware of the exploitation. The root cause is that the `vhead_file` argument is loaded without the secure parameter `weights_only=True`. Version 0.9.4 contains a fix for the issue.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"LLaMA-Factory is a tuning library for large language models. A remote code execution vulnerability was discovered in LLaMA-Factory versions up to and including 0.9.3 during the LLaMA-Factory training process. This vulnerability arises because the `vhead_file` is loaded without proper safeguards, allowing malicious attackers to execute arbitrary malicious code on the host system simply by passing a malicious `Checkpoint path` parameter through the `WebUI` interface. The attack is stealthy, as the victim remains unaware of the exploitation. The root cause is that the `vhead_file` argument is loaded without the secure parameter `weights_only=True`. Version 0.9.4 contains a fix for the issue.","source":"cvelist"},{"lang":"en","text":"### Summary\nA critical remote code execution vulnerability was discovered during the Llama Factory training process. This vulnerability arises because the `vhead_file` is loaded without proper safeguards, allowing malicious attackers to execute arbitrary malicious code on the host system simply by passing a malicious `Checkpoint path` parameter through the `WebUI` interface. The attack is stealthy, as the victim remains unaware of the exploitation. The root cause is that the `vhead_file` argument is loaded without the secure parameter `weights_only=True`.\n\nNote: In torch versions <2.6, the default setting is `weights_only=False`, and Llama Factory's `setup.py` only requires `torch>=2.0.0`.\n\n### Affected Version\n\nLlama Factory versions <=0.9.3 are affected by this vulnerability.\n\n### Details\n\n1. In LLaMA Factory's WebUI, when a user sets the `Checkpoint path`, it modifies the `adapter_name_or_path` parameter passed to the training process.\ncode in src/llamafactory/webui/runner.py\n<img width=\"1040\" alt=\"image-1\" src=\"https://github.com/user-attachments/assets/c8bc79e4-ce7d-43c9-b0fd-e37c235e6585\" />\n\n2. The `adapter_name_or_path` passed to the training process is then used in `src/llamafactory/model/model_utils/valuehead.py` to fetch the corresponding `value_head.bin` file from Hugging Face. This file is subsequently loaded via `torch.load()` without the security parameter `weights_only=True` being set, resulting in remote code execution.\ncode in src/llamafactory/model/model_utils/valuehead.py\n<img width=\"1181\" alt=\"image-2\" src=\"https://github.com/user-attachments/assets/6edbe694-0c60-4a54-bfb3-5e1042c9230d\" />\n\n### PoC\n\n#### Steps to Reproduce\n\n1. Deploy llama factory.\n2. Remote attack through the WebUI interface\n    1. Configure `Model name` and `Model path`  correctly. For demonstration purposes, we'll use a small model `llamafactory/tiny-random-Llama-3` to accelerate model loading.\n    2. Set `Finetuning method` to `LoRA` and `Train Stage` to `Reward Modeling`. The vulnerability is specifically triggered during the Reward Modeling training stage.\n    3. Input a malicious Hugging Face path in `Checkpoint path` – here we use `paulinsider/llamafactory-hack`. This repository(https://huggingface.co/paulinsider/llamafactory-hack/tree/main ) contains a malicious `value_head.bin` file. The generation method for this file is as follows (it can execute arbitrary attack commands; for demonstration, we configured it to create a `HACKED!` folder).\n    4. Click `Start` to begin training. After a brief wait, a `HACKED!` folder will be created on the server. Note that arbitrary malicious code could be executed through this method.\n\n**The video demonstration of the vulnerability exploitation is available at the** [Google Drive Link](https://drive.google.com/file/d/1AddKm2mllsXfuvL4Tvbn_WJdjEOYXx4y/view?usp=sharing) \n\n### Impact\nExploitation of this vulnerability allows remote attackers to:\n - Execute arbitrary malicious code / OS commands on the server.\n - Potentially compromise sensitive data or escalate privileges.\n - Deploy malware or create persistent backdoors in the system.\nThis significantly increases the risk of data breaches and operational disruption.","format":"markdown","source":"ghsa"},{"lang":"es","text":"LLaMA-Factory es una librería de optimización para modelos de lenguaje grandes. Se descubrió una vulnerabilidad de ejecución remota de código en versiones de LLaMA-Factory hasta la 0.9.3 (incluida) durante su entrenamiento. Esta vulnerabilidad surge porque el `vhead_file` se carga sin las protecciones adecuadas, lo que permite a atacantes maliciosos ejecutar código malicioso arbitrario en el sistema host simplemente pasando el parámetro `Checkpoint path` malicioso a través de la interfaz `WebUI`. El ataque es sigiloso, ya que la víctima desconoce la explotación. La causa principal es que el argumento `vhead_file` se carga sin el parámetro seguro `weights_only=True`. La versión 0.9.4 contiene una solución para este problema.","source":"nvd"}],"published":"2025-06-26T14:40:52.764Z","modified":"2026-07-07T17:57:19.707Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:H","score":8.3,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:H","score":8.3,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:H","score":8.3,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:H","score":8.3,"rating":"HIGH"}],"cwes":["CWE-94","CWE-502"],"affected":[{"ranges":[{"version":"< 0.9.4","status":"affected"}],"vendor":"hiyouga","product":"LLaMA-Factory","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"0.9.3"}],"ecosystem":"PyPI","package":"llamafactory","purl":"pkg:pypi/llamafactory","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"0.9.4"}],"vendor":"hiyouga","product":"llama-factory","cpe":"cpe:2.3:a:hiyouga:llama-factory:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"0.9.3"}],"ecosystem":"PyPI","package":"llamafactory","purl":"pkg:pypi/llamafactory","source":"pysec"}],"references":[{"url":"https://github.com/hiyouga/LLaMA-Factory/security/advisories/GHSA-xj56-p8mm-qmxj","tags":["exploit","third-party-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/hiyouga/LLaMA-Factory/commit/bb7bf51554d4ba8432333c35a5e3b52705955ede","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://drive.google.com/file/d/1AddKm2mllsXfuvL4Tvbn_WJdjEOYXx4y/view?usp=sharing","tags":["exploit","x-refsource-misc"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-53002","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/hiyouga/LLaMA-Factory","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/llamafactory","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-xj56-p8mm-qmxj","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2025-06-26T15:05:57.527Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-53002","url":"https://www.cve.org/CVERecord?id=CVE-2025-53002","licence":"CVE Terms of Use","modified":"2025-06-26T15:12:51.382Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-xj56-p8mm-qmxj","url":"https://github.com/advisories/GHSA-xj56-p8mm-qmxj","licence":"CC-BY-4.0","modified":"2026-07-07T17:57:19.707Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-53002","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-53002","licence":"Public domain","modified":"2026-06-17T09:37:27.313Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-1576","url":"https://osv.dev/vulnerability/PYSEC-2026-1576","licence":"CC-BY-4.0","modified":"2026-07-07T17:46:54.104Z"}],"updatedAt":"2026-11-25T22:58:59.653Z","epss":{"score":0.01364,"percentile":0.72605,"date":"2026-12-01T12:00:22.000Z"}}