Repository navigation
Conversation
A session obtained through one relay was reused after switching to another whenever the new relay advertised the same issuer and client id, handing the user's ID token to that relay. Sessions now live under one key and name the relay, issuer and client they were obtained for; any other session is dropped on read, and the old provider-keyed entry is removed. Adds RelayPolicy (pinned / allowlisted origins) that the apps read from build config to hide or restrict the self-hosted relay choice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Manual endpoints default to off. Postgres keeps its superuser for setup and the relay connects as a role that owns only the relay database, created by an init script. Database passwords and the URL are secret files from gen-keys.sh, read through POSTGRES_PASSWORD_FILE and DATABASE_URL_FILE. Every container drops all capabilities, runs with no-new-privileges, a read-only root, memory, process and log limits; Postgres runs as its own user on an internal network. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
API requests are capped at 2 MiB and relay channel requests at the relay's 64 MiB limit. Every response gets HSTS; API responses also get nosniff, no framing and no referrer. Carried environments keep the relay's sandbox policy without framing limits, since the apps frame their file previews. Slow request headers time out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Node, Postgres and Caddy images are pinned by digest so a rebuild from unchanged source uses the same inputs. The runtime image also drops npm, which the bundled relay never uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Manual endpoints were validated by hostname only, so a name resolving to a private or link-local address turned the relay into an internal scanner. The Node relay now resolves the name itself, refuses the whole answer when any address is internal or (in public mode) private, and connects to the address it checked. IP literals are checked before connecting. Callers get a generic failure for these endpoints; the reason stays in the relay's logs. Push delivery queues are bounded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The README no longer claims thread data never reaches the relay: it lists what the database holds and that relay channels carry live traffic in clear. Backups are encrypted with age and come with retention and restore steps, plus a migration for deployments that ran the relay as the Postgres superuser. A new operator guide covers the relay host, identity provider settings, device approval, offboarding and known limitations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Any user could type any relay address under T3 Connect service, and a look-alike relay then received the user's ID token. A build can now set T3CODE_RELAY_PINNED=true to use only its own T3CODE_RELAY_URL (the self-hosted choice and its search entry are hidden, a stored choice is ignored), or T3CODE_RELAY_ALLOWLIST to accept only listed origins. Unset keeps today's behavior. Desktop renders the same bundle, so it follows. The OIDC config now carries the relay URL so the session is bound to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The refresh and ID tokens sat in localStorage, readable by any script on the origin and kept on disk for the refresh token's lifetime (90 days for the desktop's public client). Web now keeps the session in this tab's sessionStorage. Memory alone would lose it on every reload, and the redirect sign-in and the relay switch both reload the page; sessionStorage survives those but ends with the tab, is not shared with other tabs and is not kept across browser restarts. The cost: each new tab or browser session signs in again (usually a quick bounce through the identity provider's own session). Desktop keeps the session in the main process, encrypted with Electron safeStorage (oidc-session.bin in the state directory); without a keychain it stays in memory and ends with the app. Token requests also move to the main process: Entra refuses to redeem a code sent from the renderer's t3code:// origin (AADSTS9002326), because only SPA redirect URIs may redeem cross-origin and a custom scheme cannot be one. The main process discovers the issuer itself and only posts authorization-code or refresh-token grants to that issuer's token endpoint. Existing localStorage sessions are deleted on upgrade, so users sign in once more. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Discovery followed redirects, accepted any scheme and any size, so whoever answered it could choose the keys every token is checked against. It now requires https (http only for loopback), refuses redirects, caps the document and refuses a bad issuer at startup. JWKS fetches use the same no-redirect client. Tokens carrying the at+jwt type or an scp claim are access tokens and are refused where an ID token is expected, and azp, when present, must name the relay's client. Entra v2 ID tokens carry neither, so they keep working. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mobile app reads T3CODE_RELAY_PINNED / T3CODE_RELAY_ALLOWLIST from its Expo config like web and desktop: a pinned build hides the T3 Connect service row and ignores a stored relay; an allowlist limits which relay can be chosen. The OIDC session is bound to the relay URL. Sign-out used to clear the session first, so the cleanup that unregisters the phone from the relay found no token and the relay kept pushing agent activity (thread titles) to a signed-out phone. Sign-out now unregisters the device while the token is still valid (bounded to 5 s), then clears the session; switching relays signs out first for the same reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The stored CLI credential was stamped with the identity provider only, so a changed T3CODE_RELAY_URL (a stray dotenv, a malicious env var) received the existing ID and refresh tokens without a new sign-in. The stamp now also names the relay URL; a credential for any other relay is not used and the CLI asks to sign in again. Existing credentials carry no relay, so every CLI host signs in once more after upgrading. Before showing a device code or sign-in link, the CLI now prints the relay and the sign-in provider's host it is about to use, so a swapped relay or provider is visible before the user approves anything. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`t3 connect link --publish-only` skipped the managed tunnel, but a self-hosted relay with channels still handed the host a relay channel, which gives approved devices remote control. The CLI only said "start T3 to publish agent activity". - `t3 connect link --activity-only` (and a link that `t3 connect publish` creates) records that this link refuses relay channels. - `T3CODE_RELAY_REMOTE_CONTROL=false` refuses them for every link; a bad value fails closed. - The host drops a relay channel config it is refused, and never starts one stored earlier. - `--publish-only`, `link` and `status` state whether remote control is on. - A reachable relay channel reads "Relay channel connected", and the startup log says remote control is on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Channels could make the relay buffer 64 MiB request bodies and unbounded socket frames, any client could claim any X-Forwarded-For, and absolute redirects from an environment sent visitors anywhere from the relay origin. - Per-channel caps on pending requests and carried sockets, a shared memory budget for bodies and frames, and a 50 MiB body limit; slow socket readers are closed with 1013 instead of buffered without end. - Writers wait for the peer to drain before sending more. - Forwarding and hop-by-hop headers are dropped; the relay sets X-Forwarded-For from its own peer, or the front proxy's last entry. - Redirects must resolve under the environment's own /env/<key>/ path. - Credential rechecks can be woken early, and four failed lookups in a row end the channel instead of keeping it open forever. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An operator had no way to cut one account off, and a revoked credential kept its channel open until the next 25 second recheck. - offboardOidcSubject revokes the account's links and the credentials behind them in one transaction, and deletes its devices and live activities (push tokens). - Revoking credentials sends pg_notify on t3_relay_credentials_revoked after commit, so relays recheck their channels at once. - pruneRevoked forgets credentials revoked long ago. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The self-hosted relay read request bodies without a limit, accepted 100 MiB WebSocket frames, let one account link any number of environments, and could only read its database URL from the environment. - RELAY_API_MAX_BODY_BYTES (1 MiB) bounds every relay API body, including the unauthenticated DPoP token route. - Channel limits and the WebSocket frame limit come from RELAY_CHANNEL_* and RELAY_WS_MAX_FRAME_BYTES; the frame default follows the body limit. - RELAY_MAX_ENVIRONMENTS_PER_USER (25) caps active links. The link and its credential are written in one transaction, so a refused or failed link leaves nothing behind. - <NAME>_FILE reads secrets such as DATABASE_URL_FILE from files. - The relay listens for credential revocations to close channels. - `node src/node.mjs offboard --subject <sub> [--issuer <iss>]`. - The cron drops activity rows abandoned for 7 days and credentials revoked 30 days ago. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop build-policy guidance that belongs to individual forks, use the real offboard command, and remove the Android transport section whose code is not part of this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The server layer was built whenever the arguments did not parse as an offboard command, so a mistyped offboard inside the running container failed with EADDRINUSE before it could print usage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A source review of the self-hosted relay and OIDC sign-in in pingdotgg#34302 found no auth bypass, but found several ways a relay, a look-alike relay or a client could get more than it should:
T3CODE_RELAY_URLchanged.localStorage.public) in the compose file, and checked by hostname only, so a name that resolves to an internal address reached the relay's network.--publish-onlystill gave a host a relay channel, which means remote control.Change
Clients
T3CODE_RELAY_URLthe same way, and the CLI prints the relay and sign-in host before showing a code.T3CODE_RELAY_PINNED=trueorT3CODE_RELAY_ALLOWLIST(web, desktop, mobile) to stop users from choosing another relay. Unset keeps today's behavior.sessionStorage. Desktop keeps it in the main process, encrypted withsafeStorage, and posts token requests from there. This also fixes Entra refusing to redeem a code from thet3code://origin (AADSTS9002326).t3 connect link --activity-onlyandT3CODE_RELAY_REMOTE_CONTROL=falserefuse relay channels.link,--publish-onlyandstatussay whether remote control is on.Relay
at+jwt, noscp,azpmust match when present). Discovery is https only (http for loopback), refuses redirects, caps the document size, and refuses a bad issuer at startup.RELAY_API_MAX_BODY_BYTES(1 MiB),RELAY_CHANNEL_*andRELAY_WS_MAX_FRAME_BYTES, andRELAY_MAX_ENVIRONMENTS_PER_USER(25). Slow socket readers get closed./env/<key>/path.node src/node.mjs offboard --subject <sub> [--issuer <iss>]revokes an account's links and credentials and deletes its devices in one transaction. Revocations notify all relays, which close those channels at once.<NAME>_FILEreads any secret from a file.Self-host stack
relayrole that owns only its database.gen-keys.sh. Containers are read-only, drop all capabilities and run with no-new-privileges./env/) and adds security headers. Base images are pinned by digest.relayrole.OPERATING.mdcovers running the relay: host, identity provider settings, offboarding and known limitations.Scope
This targets the pingdotgg#34302 branch. It changes the self-hosted relay, OIDC sign-in, and the client code that picks a relay. The hosted (Clerk) sign-in flow is unchanged, except that its stored CLI credential is now also bound to the relay URL.
What users will notice:
relayrole is a README step.--activity-onlyorT3CODE_RELAY_REMOTE_CONTROL=falseopts out of remote control.Left out on purpose, since these are product or policy decisions or need their own design:
Verification
vp run check:changed c417cb8eb3passes: format, lint, knip, graphql, typecheck (38 packages), tests (23 files, 302 tests) and react compiler. New and extended tests cover session binding, relay policy, ID-token checks, endpoint vetting, channel limits, link caps, offboarding and the CLI binding.infra/relay/selfhostbuilt from this branch:relayrole, which is not a superuser./.well-known/t3-relayanswers./env/body gets 413.offwhen unset.http://issuer refuses startup.offboard --subject <sub>prints its counts.offboardwith bad arguments tried to bind port 8080. That is fixed in the last commit.Not verified:
Model and harness: Claude Opus 5.5 in Claude Code (T3 Code).
🤖 Generated with Claude Code