Skip to content

Harden Serve identity and Codex worker credentials - #342

Merged
lucbocahut merged 1 commit into
mainfrom
harden-serve-identity-codex-auth
Nov 13, 2026
Merged

lucbocahut merged 1 commit into
mainfrom
harden-serve-identity-codex-auth

Conversation

@lucbocahut

Copy link
Copy Markdown
Contributor

Closes #335, closes #336.

Serve identity (#335)

In Tailscale Serve mode the UI previously trusted Tailscale-User-Login from any loopback peer that used the public host name. It now also requires the connecting loopback socket to be owned by root (uid 0), as tailscaled is. The UI reads the owner from the kernel's socket table (/proc/net/tcp, visible to the UI container because it uses host networking). If the owner is unknown or not root, no identity is forwarded and GitHub cookie sign-in applies as before.

Why not a unix socket? Serve's backend is set by a root-only command (sudo tailscale serve … http://127.0.0.1:8787), and the installer's sudoers policy allows only that exact command. Moving to a unix: backend would mean:

  • a root step on every existing host;
  • changing the sudoers policy and the bootstrap's expected Serve configuration;
  • relying on a recent Tailscale release that supports unix backends.

None of that could happen through forge update. Serve cannot add a custom secret header either. The peer-owner check keeps Serve, sudoers and units unchanged, so a normal forge update deploys it with the rebuilt UI. The check fails closed wherever /proc is unavailable.

Codex worker credentials (#336)

  • Every Codex worker now receives the access-only chatgptAuthTokens snapshot, single runs included. The refresh token never enters a worker container.
  • The snapshot path already renews the login under the credential lock, in a bounded container with no repository, so the access token outlives the job deadline plus five minutes. If renewal can't reach that far, the job waits as provider-unavailable instead of failing mid-run.
  • Codex runs can now share an account in parallel. Exclusive leasing still applies to other refreshable logins, such as Claude.
  • codex_parallel_auth is retired, since nothing needs the full-file path any more. Stored runtime settings, immutable launch snapshots and older install intents or bindings that still carry it are accepted, and the field is ignored.
  • Teardown write-back still refuses to save an access-only copy over the managed login.
  • scrub() now also redacts any value labelled as a refresh token (refresh_token/refreshToken, as JSON, escaped JSON or form fields), as defence in depth next to the existing JWT and known-secret redaction.

Tests

  • UI: a forged header from a non-root loopback peer is rejected, Serve's root-owned hop is accepted, and parsing of the socket table is tested against kernel-formatted rows.
  • Python:
    • the default configuration delivers no refresh token in the worker's credential archive or in any engine call;
    • the retired setting is accepted and ignored;
    • scrub() redacts labelled refresh tokens;
    • Codex accounts are shared across workers;
    • exclusive-lease tests now use a refreshable Claude login.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GvCDky7pWJx1VVhmNxftM4

Serve identity (#335): the UI accepts Tailscale-User-Login only when the
loopback connection that carries it is owned by root, as tailscaled is,
read from the kernel socket table. Other local accounts can no longer
present the header. Serve's configuration and the sudoers policy are
unchanged, so the update applies through the normal forge update.

Codex credentials (#336): every Codex worker now receives the
access-only snapshot, renewed by the controller to outlive the job
deadline; the refresh token never enters a worker container. The
codex_parallel_auth setting is retired (still accepted and ignored in
stored settings, launch snapshots and older install intents). scrub()
also redacts values labelled as refresh tokens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GvCDky7pWJx1VVhmNxftM4
@lucbocahut
lucbocahut merged commit 4e6a1ef into main Nov 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant