/

CVE-2026-59707

Severity:

HIGH RISK

(8.6)

Server-Side Request Forgery (CWE-918) in LocalAI API

CVE-2026-59707

Deferred

Vulnerability type

Category:

Server-Side Request Forgery (SSRF)

CWE:

CWE-918

Impact:

Internal network access and information disclosure via SSRF

Severity:

HIGH RISK

(8.6)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

An unauthenticated server-side request forgery vulnerability in LocalAI's POST /models/apply endpoint allows attackers to coerce the server into issuing HTTP requests to arbitrary internal URLs.

By supplying crafted gallery URL fields, an attacker can target private or loopback network ranges and obtain partial response details via propagated error messages, becoming risky wherever the API is exposed without strict network egress controls.

Affected context

This vulnerability occurs in LocalAI deployments that expose the POST /models/apply endpoint over HTTP without strong network egress restrictions.

It is relevant when the endpoint accepts gallery URL inputs that are subsequently used to build outbound HTTP requests, and when the server can reach internal services, metadata endpoints, or loopback interfaces.

Environments with permissive outbound connectivity or rich internal HTTP-based services are more susceptible to impactful exploitation.

Exploit preconditions

  • Attack surface: The HTTP POST /models/apply endpoint of a LocalAI server.
  • Required access: Network access to the LocalAI API; no authentication is required for the vulnerable call.
  • Trigger point: Submission of a crafted request containing gallery URL fields pointing to internal, private, or loopback addresses.
  • Why exploitation is possible: The endpoint forwards user-controlled URLs directly into gallery.GetGalleryConfigFromURLWithContext without sanitization or validation, allowing attacker-chosen destinations and resulting in error messages that can leak partial response content.

Why this happens

The underlying bug class is server-side request forgery: user-provided URLs are treated as trusted destinations for server-initiated HTTP requests.

The POST /models/apply endpoint passes unsanitized gallery URL fields into the gallery fetching routine, effectively outsourcing destination choice to the client.

This maps to CWE-918: Server-Side Request Forgery (SSRF), where an application lets an attacker leverage its network position and HTTP client to access resources that might not be directly reachable from the attacker's environment, and exposes aspects of responses through error handling or logging.

Potential impact

  • Attackers may coerce the server to send HTTP GET requests to internal services, including those bound to private or loopback interfaces.
  • Attackers could discover internal hostnames, IP ranges, and service behavior through timing and error messages.
  • Partial response content or configuration details can be leaked via propagated error messages and failure logs.
  • Internal HTTP endpoints that respond with sensitive metadata or credentials could be probed and partially exposed.

General mitigation guidance

Mitigation typically centers on constraining how the server uses user-provided URLs and limiting its ability to reach sensitive network destinations.

Defensive patterns include:

  • Validating and whitelisting allowable URL hosts, schemes, and paths, rejecting or normalizing anything outside a controlled set of domains.
  • Blocking requests to private, loopback, link-local, or metadata service address ranges at the application level before dispatch.
  • Implementing strict network egress controls so application servers cannot freely access internal administration endpoints, metadata services, or other sensitive resources.
  • Treating error messages as potential data exfiltration channels and ensuring they do not surface raw response bodies or low-level network details to clients.

How teams detect issues like this

Detection approaches often focus on identifying patterns where user-controlled input drives outbound HTTP requests.

Useful strategies include:

  • Static analysis rules and code scanning queries that flag uses of user-supplied URLs in HTTP client calls or helper functions like gallery.GetGalleryConfigFromURLWithContext without prior validation.
  • Code review checklists that highlight network calls originating from API endpoints, requiring explicit validation, allowlisting, and egress policy checks.
  • Runtime monitoring that detects unusual outbound traffic from application servers to internal ranges or metadata services, coupled with alerts on repeated failures and suspicious error message patterns.
  • Policy enforcement via automated tooling that prevents deployment of services lacking URL validation or that allow unrestricted server-to-server HTTP access from publicly reachable endpoints.

Sources

SourceLink
github.comgithub.com/mudler/LocalAI
github.comgithub.com/mudler/LocalAI/commit/f9b968e19d7cbc556d59dceb2e0e450b828a3fda
github.comgithub.com/mudler/LocalAI/issues/10665
vulncheck.comvulncheck.com/advisories/localai-server-side-request-forgery-via-post-models-apply

Frequently asked

questions

It is broadly exploitable wherever the POST /models/apply endpoint is reachable over the network and not protected by authentication or strict firewall rules. Any external user who can send requests to the API can attempt SSRF attacks.

The attacker only needs network access to the LocalAI HTTP endpoint exposing /models/apply. No valid credentials are required for the vulnerable call, making it accessible from anonymous clients.

The safest pattern is to avoid using raw user-supplied URLs as destinations for server HTTP requests. Instead, enforce strict allowlists for gallery hosts, validate schemes and paths, block private and loopback ranges, and reduce the server's ability to reach sensitive internal services through network policy.

Prevention relies on consistently treating all URLs from clients as untrusted input, applying rigorous validation and allowlisting before use, enforcing network egress restrictions, and incorporating SSRF-specific checks into code review and automated security testing processes.

Find out what's already
exploitable in your codebase.