# CVE-2026-77866: SSRF protection bypass in safeurl via IPv6 addresses and unresolvable hosts

The Markdown version of <https://upatch.dev/cve/CVE-2026-77866>. Last updated 25 Nov 2026.

## At a glance

CVE-2026-77866 is rated Critical 9.0 (CVSS 4.0, CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:L/VA:N/SC:H/SI:L/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X). It affects safeurl (Slab) and was published on 15 Sept 2026. It is not in CISA's Known Exploited Vulnerabilities catalog. Its EPSS score is 0.5%: the estimated chance it is exploited in the next 30 days, as of 25 Nov 2026. The upatch `cve-2026-77866-safeurl-block` mitigates it, and is vetted (merged into the registry).

A upatch is a signed BPF program that shirudo loads into a running Linux kernel to block the code path this CVE's exploit takes. It holds the line until the fix ships; it does not replace patching.

## The vulnerability

CVE-2026-77866 (EEF-CVE-2026-77866), published on 15 September 2026, is a Server-Side Request Forgery (SSRF) protection bypass in the Elixir library `safeurl`. When `SafeURL.validate/2` and `SafeURL.allowed?/2` validate a URL against the default `@reserved_ranges` CIDR list or a configured `:blocklist`, `ip_in_ranges?/2` in `lib/safeurl/safeurl.ex` matches only 4-tuple IPv4 addresses (`{_, _, _, _}`) and returns `false` for every other value. An internal or loopback destination that is rejected in its IPv4 form (such as `127.0.0.1` or `169.254.169.254`) is accepted when written as an IPv6 address (such as `[::1]` or `[::ffff:127.0.0.1]`), IPv6 entries in `:blocklist` never match, and a host that resolves to no IPv4 address (`nil`) is accepted regardless of where it points.

### Official description

Server-Side Request Forgery (SSRF) vulnerability in Slab safeurl allows an attacker who controls a validated URL to reach internal network destinations the library is configured to block.

Only IPv4 addresses are matched against the reserved ranges and the blocklist. Every other address is treated as matching nothing, so a destination that is rejected in its IPv4 form is accepted when written as an IPv6 address, IPv6 entries in the blocklist never match, and a host that resolves to no IPv4 address is accepted regardless of where it points. Deployments that rely on the allowlist instead are unaffected, because there an unmatched address is rejected.

This issue affects safeurl: from 0.1.0 onward.

## What the upatch does

Two BPF LSM programs on `lsm/socket_connect` and `lsm/socket_sendmsg` inspect the destination `struct sockaddr` when its family is `AF_INET6`. If the IPv6 address is in a reserved or private range (`::/128`, `::1/128`, `fc00::/7`, `fe80::/10`, `fec0::/10`, `ff00::/8`, or `::ffff:0:0/96` and `64:ff9b::/96` embedding any of `safeurl`'s reserved IPv4 ranges) and the calling process is a BEAM runtime task (`beam*`, `erlexec` or `elixir`), the hook increments the `refused` per-CPU counter and returns `-EPERM`.

The policy: [`cve-2026-77866-safeurl-block.bpf.c`](https://github.com/copper-helm/upatch-registry/tree/main/upatches/cve-2026-77866), 175 lines of BPF C attached at `lsm/socket_connect` and `lsm/socket_sendmsg`, licensed GPL-2.0 OR BSD-2-Clause.

## Side effects

- Erlang and Elixir processes on the machine cannot connect or send packets over IPv6 to loopback (`::1`), link-local (`fe80::/10`), unique-local (`fc00::/7`), multicast (`ff00::/8`), or IPv4-mapped reserved addresses (`::ffff:127.0.0.0/104`, `::ffff:10.0.0.0/104`, `::ffff:169.254.0.0/112`, `::ffff:172.16.0.0/108`, `::ffff:192.168.0.0/112`).
- IPv4 connections (including `127.0.0.1` for local Erlang distribution or application ports), public IPv6 connections, and all connections by non-BEAM processes are unaffected.

## Preemption model and cost

The programs keep no state beyond the `refused` per-CPU array counter, updated with an atomic fetch-and-add, so they are safe under every preemption model, including `PREEMPT_LAZY`, `PREEMPT_DYNAMIC` and `PREEMPT_RT`. Every non-IPv6 socket operation exits after reading the two-byte `sa_family` field, and public IPv6 destinations return before checking the task's command or executable name.

## Affected versions

This is an application vulnerability in the `safeurl` Hex package:

| Package         | Affected                    | Fixed in       |
| --------------- | --------------------------- | -------------- |
| `safeurl` (Hex) | 0.1.0 to 1.0.0 (`>= 0.1.0`) | none published |

The BPF LSM programs run on any Linux kernel that supports `BPF_LSM_MAC` with `socket_connect` and `socket_sendmsg`.

## How it was tested

On an Elixir 1.18.3 service running safeurl 1.0.0 with default reserved-range blocking, the loaded upatch refused the outbound IPv6 loopback SSRF connection with EPERM while safeurl continued to reject IPv4 loopback.

- **Tested:** 25 Nov 2026
- **Target:** Slab safeurl 1.0.0 on Elixir 1.18.3 / Erlang/OTP, block_reserved=true, loopback HTTP service on 127.0.0.1:18080
- **Kernel:** 7.4-shirudo-ci-20261123
- **Architecture:** x86_64
- **Distribution:** Ubuntu 26.04

### Results

| State           | IPv6 loopback SSRF blocked | IPv4 loopback rejected by safeurl (HTTP 403) |
| --------------- | -------------------------- | -------------------------------------------- |
| Before loading  | no (HTTP 200)              | yes                                          |
| Upatch loaded   | yes (EPERM, HTTP 502)      | yes                                          |
| After unloading | no (HTTP 200)              | yes                                          |

## How to apply

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:

```sh
git clone https://github.com/copper-helm/upatch-registry
cd upatch-registry
tools/build <shirudo-checkout> <keys-dir> 1.0.0 upatches/cve-2026-77866
```

Publish and roll out:

```sh
shirudo bpm push build/packages/cve-2026-77866-1.0.0.bee oci://<registry>/<namespace>/cve-2026-77866 --keys-dir <keys-dir>
shirudo bpm tree append build/packages/cve-2026-77866-1.0.0.bee oci://<registry>/<namespace>/<tree> --tree-id <tree-id> --keys-dir <keys-dir>
```

## Review

- Contributors: romanlab.
- Reviewers: none recorded yet.

## Sources and links

- [CVE-2026-77866 advisory (Erlang Ecosystem Foundation CNA)](https://cna.erlef.org/cves/CVE-2026-77866.html)
- [OSV record EEF-CVE-2026-77866](https://osv.dev/vulnerability/EEF-CVE-2026-77866)
- [Introducing commit feabbd0a13f83028ab24b71710526e9da9841f70 in slab/safeurl-elixir](https://github.com/slab/safeurl-elixir/commit/feabbd0a13f83028ab24b71710526e9da9841f70)
- [Hex package safeurl](https://hex.pm/packages/safeurl)

### Links

- [CVE-2026-77866 on upatch.dev](https://upatch.dev/cve/CVE-2026-77866) (this page, as HTML)
- [NVD](https://nvd.nist.gov/vuln/detail/CVE-2026-77866)
- [CVE.org](https://www.cve.org/CVERecord?id=CVE-2026-77866)
- [CWE-636](https://cwe.mitre.org/data/definitions/636.html)
- [CWE-918](https://cwe.mitre.org/data/definitions/918.html)
- Upatch source: [upatches/cve-2026-77866](https://github.com/copper-helm/upatch-registry/tree/main/upatches/cve-2026-77866)

### More references from NVD (3)

- [cna.erlef.org](https://cna.erlef.org/cves/CVE-2026-77866.html)
- [github.com](https://github.com/slab/safeurl-elixir/commit/feabbd0a13f83028ab24b71710526e9da9841f70)
- [osv.dev](https://osv.dev/vulnerability/EEF-CVE-2026-77866)
