127.0.0.1 Is a Place, Not a Person
Track 1 moved every app's network traffic onto loopback: an app asks its own Mac's Delta on 127.0.0.1, and only Delta dials the LAN. It is tempting to finish the thought with "and therefore anything on loopback is trusted". That sentence is wrong on every Mac with more than one account, and the family has one where it matters most.
Pippa's home Mac has two accounts. Delta runs in her pippa account and serves that account's home. Dad's account exists there only to administer the machine. Both accounts' processes can open a TCP connection to 127.0.0.1; loopback does not care which user a process belongs to. If "came from loopback" meant "is this Mac", then any process in any account (or any tool that a stray script launched) could read the home Delta serves, as that Mac, with full fleet standing.
So loopback is a place. To be treated as "this Mac", a caller there has to prove something only the account that runs Delta can prove.
The Proof Is a File Permission
The proof is the local token: 32 random bytes (secrets.token_urlsafe(32)) in <state root>/local.token, created with mode 0600. Among ordinary accounts, macOS lets only one read that file: the one Delta runs as. (Root reads any file, so an administrator who chooses sudo can read it too; the token keeps ordinary accounts and stray processes apart, not an administrator who deliberately becomes root.) An app in that account reads it and sends it as X-Delta-Local-Token, beside X-Delta-App naming itself. A process in another account cannot open the file, so it cannot show the token, so it is refused with 401 and a sentence that says what is missing.
The kit's client, kit_delta, does this for every app: it reads the token from Delta's state folder (again at most once a minute, so a rewritten token is picked up) and adds both headers to every request. No app keeps its own copy, and the token never appears in a URL, a log line or an environment variable.
| Listener | Who reaches it | What it demands |
|---|---|---|
engine, 127.0.0.1:5200 | loopback only; any other source is closed unanswered | the local token on every route except health and version |
gateway, :5201, from loopback | a process on this Mac that dialled the gateway directly | the local token, or it should ask the engine |
| gateway, from the tailnet | another Mac | nothing more: the roster names it (lesson 1) |
| gateway, Thunderbolt or LAN | another Mac | a ticket (lessons 2 and 3) |
The Hole the Review Found
The engine asked for the token from the first day. The gateway did not. In the first version, a connection that reached the gateway from loopback was classified as a tailnet connection carrying this Mac's own label, with no token asked. The engine's front door was locked; the side door into the same house stood open. Any account on the Mac could skip the engine, call the gateway on its port, and read the home share as the Mac itself.
The 1110-7 review found it, and the fix is one more connection kind. Loopback callers at the gateway are now loopback, not tailnet, and _authenticate holds them to the engine's rule: show the token, or be told to ask the engine. A test pins it: the same request to the gateway answers 401 without the header and 200 with it.
The same review fixed two smaller things in the same few lines. The token comparison became hmac.compare_digest, which takes the same time whether the first byte or the last byte differs, instead of !=. And token creation became crash-safe. The first version created the file with O_EXCL and then wrote the token into it. A stop between those two steps left an empty file, every later start read the empty string, and an empty token matches nothing: every app on the Mac refused, permanently, by a file that looked present. Now an empty file counts as missing, and the token is written whole under a temporary name, then moved into place with os.replace, which is atomic.
What the App Name Is Worth
X-Delta-App is honest bookkeeping, not proof. Share policies list the apps that may use them (apps), and Delta holds a request to that list. But the header is whatever the calling process says, on a Mac whose token it holds. It separates well-behaved apps from each other; it does not stop a process in Delta's own account from naming a different app. The architecture says so in plain words: a writer that must tell two apps on one Mac apart needs more than that header. Knowing exactly what a credential proves, and writing down what it does not, is as much a part of the design as the credential itself.