Devbox identity and private targets (#486 A): design
Visitor identity headers on every devbox link via a provider-neutral adapter (Tailscale whois), socket targets private to owner and service, and an optional edge-enforced --allow list.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+217
−0
docs/superpowers/specs/2026-11-01-devbox-identity-design.md+217 −0
CI passed — run details
Intent
Attributed to this commit: 28.5 g CO₂e (3,542,485 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-devbox-identity, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/docs/superpowers/specs/2026-11-01-devbox-identity-design.md b/docs/superpowers/specs/2026-11-01-devbox-identity-design.md| new file mode 100644 |
| index 000000000..e129b37a1 |
| --- /dev/null |
| +++ b/docs/superpowers/specs/2026-11-01-devbox-identity-design.md |
| @@ -0,0 +1,217 @@ |
| +# Devbox identity and private targets (#486, part A) |
| + |
| +Status: design, 2026-11-01. Discussion: amadan #486. Builds on devbox mode |
| +(docs/superpowers/specs/2026-10-30-devbox-mode-design.md, merged 2c66e563; |
| +macOS 90c4d3a). Part B of #486, internal deployed apps on fleet boxes, is a |
| +separate design. |
| + |
| +## 1. Why |
| + |
| +The first internal tool is the copy-review daemon (paulca/agent-skills #1). |
| +It runs on a devbox behind a devbox link, because it reads each agent's local |
| +files. It wants only its owner to be able to open reviews. Today it can't |
| +know who is looking: a devbox link passes no visitor identity, and its |
| +upstream is a loopback port that any account on the machine can reach |
| +directly, so even a passed identity could be forged by connecting around |
| +the edge. Its spec asks devbox for exactly two things: visitor identity, and |
| +a Unix-socket target only the devbox service and the owner can open. |
| + |
| +The private network already knows every visitor. On a tailnet, Tailscale |
| +knows each peer's login. The edge only has to ask, pass the answer on, and be |
| +the only way in. |
| + |
| +## 2. What it is |
| + |
| +1. **Visitor identity on every devbox link.** For each request, the edge |
| + asks the private network who the visitor is and passes it to the upstream |
| + in headers the edge controls. |
| +2. **Socket targets.** `carlos devbox share --socket <path>` points a live |
| + link at a Unix socket owned by the caller. Only the caller and the devbox |
| + service can open it, so the edge is the only way in and the identity |
| + headers can be trusted. |
| +3. **An optional allow list, enforced by the edge.** For example, |
| + `carlos devbox share ... --allow paulca@github`. A visitor whose login is |
| + not on the list gets a refusal page. With no list, a link stays open to |
| + the whole tailnet, as today. This works for folder links too. |
| + |
| +## 3. Goals, non-goals, anti-goals |
| + |
| +Goals: |
| + |
| +- A tool behind a devbox link can rely on knowing who is looking, without its |
| + own sign-in. |
| +- A link can be made private to named people with one flag, with no code in |
| + the tool. |
| +- The copy-review daemon's two open questions are answered as its spec |
| + describes: identity header plus socket target. |
| + |
| +Non-goals: |
| + |
| +- Our own access control, VPN or user directory. Tailscale's ACLs stay the |
| + network gate. The allow list only narrows who, among those the network |
| + already lets in, sees a link. |
| +- Part B: internal deployed apps on fleet boxes, and app sign-in from |
| + identity (automatic sign-in or account linking). |
| +- macOS socket targets and identity in the first cut. The macOS devbox keeps |
| + today's behaviour until a follow-up (its ACL and Tailscale LocalAPI paths |
| + differ). |
| + |
| +Anti-goals: |
| + |
| +- **Forgeable identity.** A visitor-supplied identity header must never |
| + reach an upstream. The edge strips the header names on every request, |
| + whatever the link. |
| +- **Failing open.** If the identity lookup fails, the request carries no |
| + identity. A link with an allow list then refuses it. It is never let |
| + through as "probably fine". |
| +- **The core depending on Tailscale.** Identity comes through an adapter. |
| + Tailscale is the one implementation. |
| +- A socket target that lets one account point a link at another account's |
| + socket. |
| + |
| +## 4. Decided |
| + |
| +Paul, 2026-11-01: |
| + |
| +- Part A first, because it unblocks copy review; part B is its own design. |
| +- Identity headers on every link, always. |
| +- The allow list is optional. With no list, a link stays open to the |
| + tailnet, so sharing with a colleague keeps working. |
| +- Automatic sign-in for apps is welcome later, not required ("either would |
| + be fine"). |
| + |
| +## 5. Shape |
| + |
| +### 5.1 The identity adapter |
| + |
| +An interface in the edge package (the name is the builder's): |
| + |
| + type VisitorIdentity interface { |
| + // Who returns the visitor at remote, or ok=false if unknown. |
| + Who(ctx context.Context, remote netip.AddrPort) (Visitor, bool, error) |
| + } |
| + type Visitor struct { Login, Name, Node string } |
| + |
| +The Tailscale implementation calls tailscaled's LocalAPI `whois` for the |
| +remote address, over its Unix socket (`/var/run/tailscale/tailscaled.sock`, |
| +mode 0666 on the first devbox). It uses plain HTTP over the socket: no new |
| +module dependency (my call). |
| + |
| +- **Login** is the user's login name (`paulca@github`). |
| +- **Name** is the display name. |
| +- **Node** is the machine name. |
| +- A **tagged device** has no user login, so `Who` returns ok=false and the |
| + request is anonymous. |
| + |
| +**Caching:** an answer is cached per remote address for 60 seconds, and a |
| +failure for 5 seconds (my call). Tailnet addresses are stable per device, |
| +and this keeps LocalAPI off the request path. |
| + |
| +The builder must check on the first devbox that the devbox service user (not |
| +root, not the Tailscale operator) is allowed to call `whois`. If it isn't, |
| +the fallback is the builder's call, and must not need root or sudo for |
| +day-to-day running. |
| + |
| +### 5.2 The headers |
| + |
| +On every request through a devbox link, the edge: |
| + |
| +1. deletes every request header named `Carlos-Visitor-Login`, |
| + `Carlos-Visitor-Name` or `Carlos-Visitor-Node`, in any case, before |
| + anything else; |
| +2. if `Who` returns a visitor, sets those three headers. Values are |
| + restricted to printable ASCII; anything else is dropped, not escaped (my |
| + call). |
| + |
| +This applies to live links (port and socket) and to folder links (where the |
| +headers just aren't used). It applies to WebSocket upgrades too. |
| + |
| +### 5.3 Socket targets |
| + |
| +`carlos devbox share --socket <path> [name]` (Linux): |
| + |
| +- **Where the socket lives:** under a directory the devbox service provides, |
| + `/run/carlos-devbox/sockets/`, created by the service at start with mode |
| + 1733 (`wx` for others, sticky, and not listable). Callers create their |
| + socket file there. The CLI refuses any other path (my call). A user's home |
| + directory isn't traversable by the service user, and this spot is the same |
| + on every devbox. |
| +- **Who can open it:** before registering, the CLI, running as the caller, |
| + makes the socket private (mode 0600). It then grants the devbox service's |
| + user read and write through a POSIX ACL entry, set in Go through the |
| + `system.posix_acl_access` extended attribute with no external `setfacl`. |
| + The tool doesn't have to do anything. |
| +- **The registrar's checks:** the path is directly inside the sockets |
| + directory and is a socket, not a symlink; its owner uid is the caller's |
| + uid; and the devbox service can connect to it. The checks use the file it |
| + opens, not the path (the builder picks the race-free way). |
| +- **The route:** the registry route uses the existing `Socket` upstream |
| + field (`internal/registry`), so the edge needs no new proxy path. |
| +- **The list:** `list` shows the socket path as the target and "answering" |
| + by a connect test, as for ports. |
| +- **If the tool recreates its socket** (a restart), the ACL is gone and |
| + links stop answering. The CLI help and the skill say to share again after |
| + a restart. A future option could make the service re-apply the grant (not |
| + in this cut). |
| + |
| +### 5.4 The allow list |
| + |
| +`--allow <login>[,<login>…]` on `share`, for any link kind: |
| + |
| +- It's stored with the link's owner record (the registrar's links file), not |
| + in the registry. The devbox edge and the registrar run in one process |
| + (`carlos devbox serve`), so the edge reads it in memory through a lookup |
| + the registrar hands it (my call, which avoids a registry schema change). |
| +- **Matching:** exact and case-insensitive on Login. Glob patterns and |
| + domains (`*@company`) are out of the first cut. |
| +- **Refusal:** the edge answers 403 with a short page saying the link is |
| + private (that text goes through copy review). It must not echo the allow |
| + list or the owner. |
| +- **Updates:** re-sharing a link with a different `--allow`, or none, |
| + replaces the list. Only the owner can do this, as for any change to a |
| + link. |
| +- **`list`:** shows a link as "private" or "tailnet", without the names (my |
| + call). Owners see their own lists with a flag (builder's call). |
| + |
| +## 6. Boundaries |
| + |
| +- **Provider-neutral:** identity is an adapter. The core edge knows |
| + `VisitorIdentity`, not Tailscale. With no adapter configured, every |
| + request is anonymous: allow-listed links refuse and others work as today. |
| +- **Request budget:** no S3 or other object-store requests. LocalAPI calls |
| + are local, at most one per new visitor address per minute. |
| +- **Census:** the devbox service is unprivileged. The CLI's ACL write runs |
| + as the calling user on their own socket. |
| +- **Copy:** the `--socket` and `--allow` help, the refusals (bad socket |
| + path, not your socket, unreachable), the private-link page and the |
| + runbook and skill updates all go through copy review. |
| + |
| +## 7. Outside this repo |
| + |
| +- The `carlos:devbox` skill gains `--socket` and `--allow`. |
| +- The copy-review daemon's spec, section 2, can switch from secret URLs to |
| + identity: it checks `Carlos-Visitor-Login` and uses `--socket` and |
| + `--allow paulca@github`. |
| + |
| +## 8. Left to the builder |
| + |
| +- Names for the interface, the cache and the header constants. |
| +- How the race-free socket checks are done. |
| +- The fallback if the service user can't call `whois` (subject to "no root |
| + for day-to-day running"). |
| +- How owners see their own allow lists in `list`. |
| + |
| +## 9. Done when |
| + |
| +On the first devbox: |
| + |
| +1. A live link shows the visitor's `Carlos-Visitor-Login` to the upstream, |
| + and a visitor-sent header of the same name never arrives. |
| +2. A link shared with `--socket` answers through the edge. Another account on |
| + the box can't connect to that socket, and the CLI refuses a socket owned |
| + by someone else. |
| +3. A link shared with `--allow paulca@github` serves Paul and refuses another |
| + tailnet login with the private-link page. A folder link with `--allow` |
| + behaves the same. |
| +4. With tailscaled stopped, an allow-listed link refuses and an open link |
| + still serves. |