upatch.dev

CVE-2026-85180

Ollama 0.30.0 through 0.33.2 SSRF via Cross-Host Tensor Blob Redirect

Refuses outbound connections from Ollama processes to cloud metadata, link-local, RFC 1918 private, CGNAT and multicast addresses to mitigate CVE-2026-85180.

High 8.7Vetted

EPSS 0.5%: the estimated chance this CVE is exploited in the next 30 days, as of 25 Nov 2026.

At a glance

CVE-2026-85180 is a high (CVSS 8.7) vulnerability in Ollama, published 3 September 2026. A vetted upatch, cve-2026-85180-ssrf-block, blocks it on running Linux machines with shirudo until Ollama is upgraded.

Severity
High 8.7 CVSS 4.0
Chance of exploitation
0.5% in the next 30 days (EPSS, 25 Nov 2026)
Known exploited
No, not on CISA’s KEV list
Weakness
CWE-918
Affected software
Ollama
Upatch status
Vetted, merged into the registry
How to apply
Build, sign and roll out with shirudo

Overview

CVE-2026-85180 is a server-side request forgery (SSRF) vulnerability in Ollama 0.30.0 through 0.33.2, published on 3 September 2026. When PullModel in server/images.go pulls a model manifest containing a tensor layer (application/vnd.ollama.image.tensor), it delegates blob downloads to pullWithTransfer, which invokes transfer.Download in x/transfer/download.go. In downloader.resolve, HTTP 301, 302 and 307 redirects whose Location header points to a different host are returned and followed without checking whether the target resolves to a private, link-local or cloud metadata address. An unauthenticated caller who reaches POST /api/pull can point Ollama at a registry that serves a tensor-layer manifest and redirects blob requests to internal hosts or cloud metadata services such as 169.254.169.254. Upstream commit 7cea5717959d9c424ff8fb906271d31943141505 (fixing issue #17041) wraps the transfer HTTP client in redirectGuard and rejects cross-host redirects to private, loopback, link-local, multicast and unspecified addresses via validateRedirectHost and blockedRedirectAddr.

Official description

Ollama fails to validate redirect destinations when pulling tensor-layer models, allowing unauthenticated attackers to redirect blob downloads to arbitrary hosts. An attacker can control a registry, serve a malicious tensor-layer manifest, and cause the server to issue GET requests to internal hosts including cloud metadata endpoints.

Affected versions

This is an application vulnerability in Ollama 0.30.0 through 0.33.2. The upatch runs on any Linux kernel supported by shirudo with BPF LSM and BTF enabled.

Sources

More references from NVD (4)

Mitigation

The BPF LSM program cve_2026_85180_ssrf_block attaches to lsm/socket_connect and returns -EPERM when a process whose command name or executable is ollama attempts to connect an AF_INET or AF_INET6 socket to any of the following internal or non-routable ranges:

  • IPv4: 0.0.0.0/8 (unspecified), 10.0.0.0/8, 100.64.0.0/10 (CGNAT, including 100.100.100.200), 169.254.0.0/16 (link-local and cloud metadata 169.254.169.254), 172.16.0.0/12, 192.168.0.0/16, 224.0.0.0/4 (multicast) and 240.0.0.0/4.
  • IPv6: ::/128 (unspecified), fc00::/7 (unique-local, including fd00:ec2::254), fe80::/10 (link-local), ff00::/8 (multicast), and IPv4-mapped (::ffff:0:0/96) or IPv4-compatible (::/96) embeddings of the blocked IPv4 ranges.

The program inspects the socket family and destination address first, and checks whether the current task is ollama only when the destination falls in a blocked range. Refused connection attempts are counted in the refused per-CPU array map.

Side effects

  • Any ollama process on the machine is refused outbound AF_INET and AF_INET6 connections to RFC 1918 private, link-local, cloud metadata, CGNAT, multicast and unspecified addresses.
  • Loopback connections (127.0.0.0/8 and ::1/128) are permitted so the ollama CLI, local runner subprocesses and loopback test registries continue to communicate with the local ollama serve daemon on 127.0.0.1:11434.
  • Non-ollama processes on the host (including sshd, system services, curl and python3) are unaffected.

Preemption model and cost

The program keeps no shared state beyond a single per-CPU counter updated with __sync_fetch_and_add, so it is safe under every kernel preemption model, including PREEMPT_LAZY, PREEMPT_DYNAMIC with preemptible RCU, and PREEMPT_RT. Connections to public or loopback addresses and non-IP sockets return after reading the address family and destination IP without querying task state or maps.

The policy

142 lines of BPF C, attached at lsm/socket_connect.

// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause

#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_core_read.h>
#include <bpf/bpf_endian.h>

#define EPERM 1
#define AF_INET 2
#define AF_INET6 10

char _license[] SEC("license") = "Dual BSD/GPL";

struct {
	__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
	__uint(max_entries, 1);
	__type(key, __u32);
	__type(value, __u64);
} refused SEC(".maps");

static __always_inline void count_refused(void)
{
	__u32 key = 0;
	__u64 *value = bpf_map_lookup_elem(&refused, &key);

	if (value)
		__sync_fetch_and_add(value, 1);
}

static __always_inline int earlier_verdict(int ret)
{
	return ret >= -4095 && ret < 0 ? ret : -EPERM;
}

static __always_inline bool name_is_ollama(const struct dentry *dentry)
{
	const unsigned char *name = BPF_CORE_READ(dentry, d_name.name);
	char buf[8] = {};

	if (!dentry || BPF_CORE_READ(dentry, d_name.len) != 6)
		return false;
	if (bpf_probe_read_kernel_str(buf, sizeof(buf), name) < 0)
		return false;
	return buf[0] == 'o' && buf[1] == 'l' && buf[2] == 'l' &&
	       buf[3] == 'a' && buf[4] == 'm' && buf[5] == 'a' &&
	       buf[6] == '\0';
}

static __always_inline bool current_is_ollama(void)
{
	char comm[16] = {};
	struct task_struct *task;
	const struct dentry *exe;

	if (bpf_get_current_comm(&comm, sizeof(comm)) == 0 &&
	    comm[0] == 'o' && comm[1] == 'l' && comm[2] == 'l' &&
	    comm[3] == 'a' && comm[4] == 'm' && comm[5] == 'a' &&
	    comm[6] == '\0')
		return true;
	task = bpf_get_current_task_btf();
	exe = BPF_CORE_READ(task, mm, exe_file, f_path.dentry);
	return name_is_ollama(exe);
}

static __always_inline bool ipv4_is_blocked(__u32 ip)
{
	if ((ip & 0xff000000U) == 0x00000000U)
		return true;
	if ((ip & 0xff000000U) == 0x0a000000U)
		return true;
	if ((ip & 0xffc00000U) == 0x64400000U)
		return true;
	if ((ip & 0xffff0000U) == 0xa9fe0000U)
		return true;
	if ((ip & 0xfff00000U) == 0xac100000U)
		return true;
	if ((ip & 0xffff0000U) == 0xc0a80000U)
		return true;
	if ((ip & 0xe0000000U) == 0xe0000000U)
		return true;
	return false;
}

static __always_inline bool ipv6_is_blocked(const struct in6_addr *addr6)
{
	__u32 w0 = bpf_ntohl(BPF_CORE_READ(addr6, in6_u.u6_addr32[0]));
	__u32 w1 = bpf_ntohl(BPF_CORE_READ(addr6, in6_u.u6_addr32[1]));
	__u32 w2 = bpf_ntohl(BPF_CORE_READ(addr6, in6_u.u6_addr32[2]));
	__u32 w3 = bpf_ntohl(BPF_CORE_READ(addr6, in6_u.u6_addr32[3]));

	if (w0 == 0 && w1 == 0 && w2 == 0)
		return w3 == 0 || ipv4_is_blocked(w3);
	if (w0 == 0 && w1 == 0 && w2 == 0x0000ffffU)
		return ipv4_is_blocked(w3);
	if ((w0 & 0xfe000000U) == 0xfc000000U)
		return true;
	if ((w0 & 0xffc00000U) == 0xfe800000U)
		return true;
	if ((w0 & 0xff000000U) == 0xff000000U)
		return true;
	return false;
}

SEC("lsm/socket_connect")
int BPF_PROG(cve_2026_85180_ssrf_block, struct socket *sock,
	     struct sockaddr *address, int addrlen, int ret)
{
	__u16 family;

	if (ret)
		return earlier_verdict(ret);
	if (!address || addrlen < (int)sizeof(family))
		return 0;
	family = BPF_CORE_READ(address, sa_family);
	if (family == AF_INET) {
		const struct sockaddr_in *sin;
		__u32 ip;

		if (addrlen < (int)sizeof(*sin))
			return 0;
		sin = (const struct sockaddr_in *)address;
		ip = bpf_ntohl(BPF_CORE_READ(sin, sin_addr.s_addr));
		if (!ipv4_is_blocked(ip) || !current_is_ollama())
			return 0;
		count_refused();
		return -EPERM;
	}
	if (family == AF_INET6) {
		const struct sockaddr_in6 *sin6;

		if (addrlen < (int)sizeof(*sin6))
			return 0;
		sin6 = (const struct sockaddr_in6 *)address;
		if (!ipv6_is_blocked(&sin6->sin6_addr) || !current_is_ollama())
			return 0;
		count_refused();
		return -EPERM;
	}
	return 0;
}

Process

How this upatch was written, checked and reviewed, from the registry’s history.

  1. 3 Sept 2026CVECVE published
  2. 25 Nov 2026CommitCommitted directlyAdd CVE-2026-85180romanlab

No human review is recorded on GitHub for this upatch yet.

Evidence

On a vulnerable Ollama 0.30.0 server, the loaded upatch refused the cross-host tensor blob redirect to a link-local address at lsm/socket_connect, while the before and after runs reached the link-local listener.

Tested
25 Nov 2026
Target
Ollama 0.30.0 (ollama serve) listening on 127.0.0.1:11434
Kernel
7.4-shirudo-ci-20261123
Architecture
x86_64
Results
StateTensor blob redirect to link-local address
Before loadingreached
Upatch loadedblocked
After unloadingreached
tools-test.log Output of tools/test --setup showing the probe reached before loading, blocked while loaded, and reached again after unloading.
tools/test --setup, 2026-11-25T16:15:41Z
Target: shirudo test VM, Linux 7.4-shirudo-ci-20261123, x86_64, swtpm
cve-2026-85180
  setup   done         OLLAMA_URL=http://127.0.0.1:11434 PROBE_BIND_IP=169.254.169.250
  before  reached      Ollama followed cross-host tensor blob redirect to http://169.254.169.250:38439/upatch-probe-1312bd552d5188af
  loaded  blocked      Ollama outbound connection to link-local target was refused
  after   reached      Ollama followed cross-host tensor blob redirect to http://169.254.169.250:38867/upatch-probe-b8362c2364d8cb5b
  PASS: reached before, blocked while loaded, reached again after

Use it

Build the upatch from source, sign it with your own shirudo key, and publish it to your own OCI registry. Machines that follow your upatch tree load it within about a minute.

Build and sign
git clone https://github.com/copper-helm/upatch-registry
cd upatch-registry
tools/build <shirudo-checkout> <keys-dir> 1.0.0 upatches/cve-2026-85180
Publish and roll out
shirudo bpm push build/packages/cve-2026-85180-1.0.0.bee oci://<registry>/<namespace>/cve-2026-85180 --keys-dir <keys-dir>
shirudo bpm tree append build/packages/cve-2026-85180-1.0.0.bee oci://<registry>/<namespace>/<tree> --tree-id <tree-id> --keys-dir <keys-dir>