[PR #2776] fix(macos): widen killswitch utun exemption so tunnels on high utunN aren't blocked #2943

Open
opened 2026-10-15 04:06:24 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amnezia-client/pull/2776
Author: @Kris1225-hash
Created: 6/26/2026
Status: 🔄 Open

Base: dev ← Head: fix/macos-killswitch-utun-range


📝 Commits (1)

  • a9b734f fix(macos): widen killswitch utun exemption range to utun0..utun99

📊 Changes

1 file changed (+11 additions, -6 deletions)

View changed files

📝 deploy/data/macos/pf/amn.200.allowVPN.conf (+11 -6)

📄 Description

Problem

The macOS pf killswitch anchor 200.allowVPN (deploy/data/macos/pf/amn.200.allowVPN.conf) exempts a hardcoded list of tunnel interfaces, utun0 … utun30.

macOS assigns the WireGuard/AmneziaWG tunnel the next free utunN unit. On machines that already run several utun-based services (Tailscale, iCloud Private Relay, other VPNs), that number starts high and increments on every reconnect until reboot. When the tunnel lands on a unit > utun30, anchor 100.blockAll (block drop out all) drops the tunnel's own egress.

Symptom: the client shows Connected, the WireGuard handshake completes (handshake packets egress en0, which is allowed), and routes 0/1 + 128.0/1 correctly point at the tunnel — but no user traffic passes and the machine appears offline, with no error surfaced.

Reproduced on: macOS 26/27, Apple Silicon, "VPN by Amnezia" (AmneziaWG). Across reconnects the tunnel landed on utun40–utun57; pfctl -a 'amn/200.allowVPN' -sr showed the exemption stopping at utun30, so 100.blockAll dropped everything routed into the tunnel. Verified end-to-end against a native build: with this change the AmneziaWG tunnel passes traffic normally; without it, it connects but carries nothing.

Fix

Widen the static exemption range from utun0 … utun30 to utun0 … utun99.

Possible follow-up

This keeps the existing static-list approach, just with more headroom. A more robust fix would exempt the actual tunnel interface dynamically — the daemon already knows it (wireguardutilsmacos.cpp → m_ifname), KillSwitch::enableKillSwitch(configStr, vpnAdapterIndex) already plumbs an adapter index, and MacOSFirewall::setAnchorTable already injects dynamic values (the server IP) into a pf table. Exempting m_ifname directly would remove the fixed cap entirely. Left out here to keep the change minimal.

One note for reviewers: MacOSFirewall::setAnchorEnabled only reloads an anchor's .conf when the anchor is currently empty, so a running daemon won't pick up this change until the anchor is flushed / the service reloads.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/amnezia-vpn/amnezia-client/pull/2776 **Author:** [@Kris1225-hash](https://github.com/Kris1225-hash) **Created:** 6/26/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `fix/macos-killswitch-utun-range` --- ### 📝 Commits (1) - [`a9b734f`](https://github.com/amnezia-vpn/amnezia-client/commit/a9b734f5d272e96781e04db8941d0f8c291d3817) fix(macos): widen killswitch utun exemption range to utun0..utun99 ### 📊 Changes **1 file changed** (+11 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `deploy/data/macos/pf/amn.200.allowVPN.conf` (+11 -6) </details> ### 📄 Description ## Problem The macOS pf killswitch anchor `200.allowVPN` (`deploy/data/macos/pf/amn.200.allowVPN.conf`) exempts a hardcoded list of tunnel interfaces, `utun0 … utun30`. macOS assigns the WireGuard/AmneziaWG tunnel the next free `utunN` unit. On machines that already run several utun-based services (Tailscale, iCloud Private Relay, other VPNs), that number starts high and **increments on every reconnect** until reboot. When the tunnel lands on a unit **> utun30**, anchor `100.blockAll` (`block drop out all`) drops the tunnel's own egress. Symptom: the client shows **Connected**, the WireGuard handshake completes (handshake packets egress `en0`, which is allowed), and routes `0/1` + `128.0/1` correctly point at the tunnel — but **no user traffic passes** and the machine appears offline, with no error surfaced. **Reproduced on:** macOS 26/27, Apple Silicon, "VPN by Amnezia" (AmneziaWG). Across reconnects the tunnel landed on `utun40`–`utun57`; `pfctl -a 'amn/200.allowVPN' -sr` showed the exemption stopping at `utun30`, so `100.blockAll` dropped everything routed into the tunnel. Verified end-to-end against a native build: with this change the AmneziaWG tunnel passes traffic normally; without it, it connects but carries nothing. ## Fix Widen the static exemption range from `utun0 … utun30` to `utun0 … utun99`. ## Possible follow-up This keeps the existing static-list approach, just with more headroom. A more robust fix would exempt the **actual** tunnel interface dynamically — the daemon already knows it (`wireguardutilsmacos.cpp` → `m_ifname`), `KillSwitch::enableKillSwitch(configStr, vpnAdapterIndex)` already plumbs an adapter index, and `MacOSFirewall::setAnchorTable` already injects dynamic values (the server IP) into a pf table. Exempting `m_ifname` directly would remove the fixed cap entirely. Left out here to keep the change minimal. One note for reviewers: `MacOSFirewall::setAnchorEnabled` only reloads an anchor's `.conf` when the anchor is currently empty, so a running daemon won't pick up this change until the anchor is flushed / the service reloads. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amnezia-client#2943
No description provided.