- Decision
- ADR-184
- Date
- 2026-10-20
- Status
- AcceptedAccepted (owner agreed to the two-component split 2026-10-20). An amendment of ADR-178, which stays
Proposed, itself amended by ADR-186 (a separate route helper, the DNS mechanism for masked destinations, the control sockets frominit); the daemon core and a userdebug probe app are built and host-tested (milestones 1 and 2 of the plan, none of it on an image); the SELinux domain, theinitservice, the exit app and the control socket model are not built or reviewed; D-K and D-L of the design are open. - Part
- Network exit
- Mentions
- ADR-178, ADR-181, ADR-186
- Mentioned by
- ADR-186, ADR-199
1Decision
Amend ADR-178, and with it the masked-destinations class of ADR-181: the exit service is two components, as set out in section 2a of 2026-10-18-network-exit-design.md. (1) The exit daemon is a native Rust program in its own SELinux domain, started by init with the one capability CAP_NET_ADMIN.
It creates the tun interface, runs the Tor client and the packet layer (the library crate onion-tunnel of Onionmasq with Arti, pinned by Cargo.lock), looks up the owner uid of every new flow with sock_diag, and holds no framework permission. (2) The exit app is a platform-signed app that holds NETWORK_FACTORY and CONTROL_OEM_PAID_NETWORK_PREFERENCE.
It registers the network for the interface the daemon reports, sets the OemNetworkPreferences, posts the notifications and hosts the Settings rows. It holds no capability and not NETWORK_STACK. The daemon's own uid stays outside every preference, so its sockets use the normal network and the daemon sets no socket mark. A flow that the daemon cannot attribute to a uid is refused, not given a shared key.
The service does not run in system_server, is not a VpnService and is not one app. The daemon is built with panic = abort and restarted by init, and the memory quota of Arti is set explicitly. The SELinux domain grants the tun device with TUNSETIFF and TUNGETIFF, the sock_diag netlink socket, the sockets that Arti needs and the control channel, and no routing-table write, no netfilter and no other Binder service.
The control channel carries typed messages only and is authenticated by SELinux domain and uid.
2Why and evidence
Permissions and the tun [verified-in-source: ConnectivityService.java in packages/modules/Connectivity, AndroidManifest.xml in frameworks/base, system/sepolicy/private, all on the build server, 2026-10-20]: registering a network or an offer needs NETWORK_FACTORY, setOemNetworkPreference needs CONTROL_OEM_PAID_NETWORK_PREFERENCE, and the owner-uid call needs NETWORK_STACK, all at signature level.
Only system_server, netd, bluetooth, clatd and crosvm may create a tun; an app may only use a descriptor that the framework hands it. The sock_diag rules belong to system_server, network_stack and netd. An app process has no CAP_NET_ADMIN [assumption: general Android behaviour, not read for this image].
The split puts kernel reach (tun, sock_diag, CAP_NET_ADMIN) in a small memory-safe daemon and framework authority (network registration, the preference) in a Java app without capability, so that no component holds both.
The Onionmasq library [verified-in-source: crates/onion-tunnel at commit 849a8d14d165] takes a tun descriptor and has no Android dependency; its TunnelScaffolding trait lets the daemon choose the isolation key; oniux runs it on a plain Linux tun [web].
The upstream Linux scaffolding sets SO_MARK 0xc185 on Arti's sockets (linux.rs:49) and finds the owner by scanning /proc/net/tcp and /proc/net/udp for every new flow (linux.rs:91-128); Android reads the low 16 bits of a socket mark as a network id [assumption: not tested with a uid other than 0; the bootstrap on lynx ran as uid 0, which has its own routing rules], so the daemon does not use that scaffolding as it is: it sets no mark and uses sock_diag.
The owner of a plain DNS query is the app: the DNS sockets of Reddit and Instagram showed the app uid in /proc/net/udp and, for Reddit, in ss (sock_diag) [measured]; DNS-over-TLS is tagged AID_DNS in the source and is not measured.
Cost [measured: NET-006, lynx 2026101802]: about 50 MB resident after bootstrap, 62 to 69 MB at the peak of a start or a consensus refresh, about 0.2 MB for each further isolation key (53.0 MB with twenty), 53.6 MB after an hour with eight keys and no leak seen in that hour; the default quota of Arti is 5.46 GiB, so a cap is needed.
The tree builds it [measured]: AOSP rustc 1.93.1 (the default), a throwaway sysroot, panic = abort because the Android standard library of the tree has no unwind strategy, and two cfg gates widened to Android (2 files, 16 lines).
Rejected: one platform app with the Rust code as a library (an app cannot create the tun and has no capability); the service inside system_server (a crash or a bug in Arti or the packet layer would take the system down, and its heap is shared); a VpnService (it uses the VPN slot, ADR-178); giving the app NETWORK_STACK to look up uids over Binder (a wider permission than the daemon's own sock_diag use, and a Binder call for every new flow); a daemon that also registers the network (the registration API is Java).
3Consequences
Two components and a control channel instead of one. A new SELinux domain and an init service with CAP_NET_ADMIN are a privileged path that gets the higher bar of AGENTS.md: the rows added to capability-boundaries.md and threat-model.md with this entry are Proposed, and a whole-branch review and a neverallow review come before any image.
The daemon brings a dependency tree of 552 packages [measured: exit-daemon/Cargo.lock; upstream Onionmasq's lock has 613] that includes aws-lc-sys (C and assembly, a second copy of BoringSSL-derived code), so the project's preference for memory-safe code does not hold for the whole tree (D-L). A panic ends the daemon, init restarts it, and apps set to Tor have no network meanwhile, as ADR-178 says for a down exit.
The daemon's own traffic to the Tor network is Direct, so a network operator sees that the device uses Tor; the consent of ADR-181 section 5 stays. About 11 percent of 944 requests failed in the one-hour run for a reason not yet found [measured: NET-006], which touches the requirement of no regression.
Whether netd configures the interface from the link properties that the app registers, or the daemon must bring the link up and set its address, is untested [assumption] (NET-001b). Soong needs smoltcp and the Arti crates added to the tree (none is in external/rust/android-crates-io), or a locked and vendored Cargo build; the plan chooses. The two upstream cfg changes are kept as a documented patch in the package of the daemon.
4Review when
init cannot start the daemon with only CAP_NET_ADMIN, or its domain cannot get TUNSETIFF or sock_diag without weakening a neverallow; a daemon with a uid other than 0 cannot bootstrap or reach the Tor network (a socket mark or a network rule is in the way); NET-001b fails on an image; the resident set on stallion exceeds the budget the owner sets (D-K) or a run of many hours shows growth (NET-006); the owner refuses the C crypto code (D-L); the failed requests of NET-006 turn out to come from the daemon; netd needs more from the daemon than this entry allows.
Read from docs/governance/decision-log.md, entry ADR-184.