Preserve macOS exit replies and isolate the Linux service fixture

Apple PF restores the forwarding tag from the physical NAT state on replies. Steer only packets sourced in an offered mesh and destined outside the offered ranges. Reverse-translated replies can then leave on the utun, including while the local host uses an upstream exit.

Apply the same rule in the authorized sharing helper. An older installed copy can still clear its anchors. Re-enabling sharing upgrades it through the normal authorization dialog and preserves existing subnet grants.

Run the Linux namespace B process with a service environment. Give its parent an explicit login environment in CI to keep exercising this boundary without weakening the agent’s login-session guard.

Reproduced the Linux denial and passed the corrected established-flow test in isolated kernel namespaces. On macOS the workspace suite, Clippy, formatting, exit helper regressions and the PF syntax check passed. The privileged two-utun test requires a disposable Mac and was not run locally.
This commit is contained in:
Aleksandr Bogomiakov committed 2026-11-26 02:20:40 +02:00
1 parent 7dacc4517e
commit 9920d4c10f
7 files changed
+89 -18

No files matched your search

+7 -4
View File
@@ -116,9 +116,10 @@ and configured networks.
- **Offering:** a `pf` anchor `com.apple/tsunagi-exit-<interface>` (the stock
`/etc/pf.conf` already evaluates `com.apple/*`) holds
NAT for traffic tagged on entry from an offered range. A tagged packet that the
kernel would forward back to the utun gets a PF `route-to` through the
physical gateway. The physical NAT state is interface-bound.
NAT for traffic tagged on entry from an offered range. If the kernel chooses
the utun for a member's outbound internet packet, PF steers it through the
physical gateway. Replies keep the tag after reverse NAT and return to the
member over the utun. The physical NAT state is interface-bound.
`pf` is enabled if it was off, and that reference is released when the rules
go. After installing the rules the agent enables IPv4 forwarding and checks
the kernel's answer before advertising the exit. Stopping the offer removes
@@ -133,7 +134,9 @@ and configured networks.
a separate grant. The helper checks the live utun address and mask, selects
the uplink from the kernel, and manages its own PF anchor and enable token.
It accepts only sharing operations. The agent can subsequently reconcile and
remove these rules without prompting. At startup it reclaims orphaned helper
remove these rules without prompting. When an update changes the helper,
enabling sharing again prompts once to replace it and keeps existing subnet
grants. At startup the agent reclaims orphaned helper
anchors for the account by checking the owning process and its start time.
For a system agent with the necessary
rights, the initial enable completes directly.