Summary
Ollama does not sufficiently validate redirect destinations when downloading tensor-layer model blobs, allowing an attacker-controlled registry to redirect requests to arbitrary hosts.
An unauthenticated attacker may use this behavior to make the Ollama server send requests to internal services, including cloud metadata endpoints, when a vulnerable model is pulled.
Affected context
The vulnerability occurs in Ollama deployments that pull tensor-layer models from registries and follow download redirects without enforcing an appropriate destination policy. The risk is higher when the Ollama server can reach internal network services, cloud instance metadata endpoints, or other sensitive administrative interfaces that are not directly accessible to the attacker.
Exploit preconditions
- Attack surface: Tensor-layer model download and redirect handling
- Required access: No direct authentication to Ollama may be required; the attacker needs to control or influence a model registry or manifest consumed by the server
- Trigger point: Pulling a model whose tensor-layer manifest causes a blob request to be redirected
- Why exploitation is possible: Redirect destinations are not sufficiently validated against trusted hosts, schemes, or network ranges, allowing server-side requests to attacker-selected or internal destinations
Why this happens
The underlying bug is insufficient validation of user-influenced redirect destinations during server-side resource retrieval. A download client that automatically follows redirects without applying an explicit allowlist, scheme restriction, and internal-address policy can be coerced into making requests outside the intended registry boundary.
This behavior maps to CWE-918: Server-Side Request Forgery, where an attacker influences a server into sending network requests to unintended locations.
Potential impact
- The server may make requests to internal network services
- Cloud metadata credentials or configuration may be exposed
- Internal service endpoints may be enumerated
- Administrative interfaces may receive unauthorized requests
- Network segmentation assumptions may be weakened
- Retrieved responses could potentially influence downstream processing
General mitigation guidance
Mitigation generally focuses on treating registry manifests and redirect responses as untrusted input.
Common defensive patterns include:
- Restricting downloads to explicitly trusted registry hosts
- Allowing only expected URL schemes and redirect destinations
- Revalidating every redirect rather than trusting the initial URL
- Blocking loopback, link-local, private, reserved, and cloud-metadata address ranges
- Resolving hostnames safely and accounting for DNS rebinding
- Disabling automatic redirects when they are not required
- Separating model-download services from sensitive internal networks
- Running the service with minimal network permissions and cloud identity privileges
- Applying outbound proxy or egress policies that deny access to metadata and administrative endpoints
How teams detect issues like this
Organizations can look for SSRF risks through:
- Static analysis of HTTP clients that follow redirects without destination validation
- Code review checks for registry, manifest, and URL fields treated as trusted
- Tests covering redirects to loopback, private, link-local, and metadata addresses
- Network monitoring for unexpected outbound requests from Ollama processes
- Egress policies and proxy logs that identify access to internal or cloud metadata services
- Automated security review tools that flag unvalidated server-side URL fetching

