The environment issues its own sessions and enforces their capabilities. Cloud identity and relay credentials belong to a separate trust boundary, described in T3 Connect. A relay token is never an environment login. See SECURITY.md for the overall threat model.
- Narrowing only. Pairing delegates a set of scopes. Exchanging a bootstrap credential can narrow a grant, never widen it. Client labels and device metadata have no authorization role.
access:writehands out what the session holds and revokes anything. Every route that returns a credential to the caller requiresaccess:writeand every scope that credential carries: a pairing link, an MCP sign-in approval, a link code from a linked environment, and a guest link (which reads a thread). Revoking is not capped by the caller's scopes. Admitting a T3 Connect device is not delegation; see T3 Connect.- Why the default grant includes management scopes.
terminal:operateandorchestration:operatealready grant OS-user execution (which can invoket3 auth session issue), so withholding access or relay management from the default grant would not be a real boundary. Narrower clients receive explicit scopes. - No recoverable secrets in read models. Only the creation response returns a raw pairing credential; access listings expose metadata only.
- DPoP binding. Browser cookies, bearer tokens, and DPoP tokens share the scoped session model. DPoP binds tokens to a client proof key; an invalid proof must fail rather than fall back to bearer auth. Plain paired DPoP sessions renew in place so live sockets and Sharing & access rows stay stable; T3 Connect, CLI, and desktop sessions never self-renew so revoking/unlinking cuts them off.
- WebSocket tickets and per-RPC authorization. Bearer and DPoP clients mint short-lived tickets
over authenticated HTTP so long-lived tokens never appear in socket URLs. DPoP RPC tickets stay
proof-key bound at upgrade. A successful handshake grants no extra authority: every RPC declares
and checks its required scope in
RpcAuthorization.ts. - Secret references need
providers:manage. A request that names a secret for the server to read needsproviders:manageon top of its method's scope, whether the reference is saved in settings or used once, as in a secret request answered with a reference. Typed values need only the method's scope. Clients hide the secret provider picker from sessions without it. - Project scripts need
orchestration:operate. The host runs a saved project script itself, on worktree creation and on settle, so saving one needsorchestration:operateon top ofsettings:write, whether it arrives in a settings patch or a project update. - Backward-compatible scope evolution. Token exchange intersects requested scopes with the
pairing grant, dropping retired/unknown names and failing before consuming a link if none remain.
Stored grants are never expanded when scopes split. Auth responses preserve legacy
scopesalongside exactpermissionsso older clients and servers stay compatible.
- Guest links are not sessions. GuestShareService
issues HMAC tokens bound to one share in the thread projection—never
SessionStorerows—so no RPC, WebSocket, or MCP route can accept one. Closing, replacing, or archiving the share revokes every token. Guest routes also require T3 Connect to still serve the link's hostname (never rely on the requestHostheader alone). - MCP clients (
mcp-client) are a separate audience. Outside agents authenticate on/mcpvia PKCE OAuth (McpOAuth), with stateless client registration so unauthenticated callers cannot grow server state. Users grant read-only access or a runtime-mode ceiling rather than raw scopes. Every non-/mcpHTTP and WebSocket route rejectsmcp-clientsessions (except the read-only thread relay and client-pairing routes restricted to peer links). Every MCP tool must statically declare its access level inMcpToolAccess.ts, and thread-only tools must still refuse outside callers in handlers—hiding from tool listings is only discovery. A workflow run picks its own modes, so only a caller at the broadest mode a thread may run in here (full access, or an administrator's ceiling below it) can start or change runs, change what workflows store, or read webhook paths. Narrower callers can still read runs. - A project's worktree layout commands run only as a person approved them. The commands come
from the project folder's
t3.jsonand run as the server's OS user, so each runs only after a client session holdingterminal:operateapproved its exact text for that project.TaskFoldersis the only place they run and checks the approval, managed policy, and who asked at every run. Recording an approval is a client RPC only:t3code/no-layout-command-approval-writeskeeps the write side out of every other module, MCP tools included. For an agent's own worktree request, a thread below Full access gets neither these commands nor the project's setup script, approved or not. The asking thread's modes are read when each is about to run, a thread recorded above the administrator'smaxRuntimeModeis not in Full access, and neither is an asking thread that can no longer be read. A command that waited for another one's turn is checked again, who asked, file and approval, before it starts; one refused then ran nothing, so the project'sremovedoes not run for it either. - A repository's push hooks run for an agent below Full access only as a person approved
them.
pull_request_createpushes as the server's OS user, and Git would run the checkout'spre-pushandreference-transactionhooks, which the agent may have written. By the rule above for who is in Full access, a thread below it gets every Git command of that call with hooks off (GitVcsDriver.RepositoryHooks), except the push itself once a person approved the hooks by a digest of their contents. Hooks are the files in the hooks directory and the ones Git's configuration defines (hook.<name>.commandwithhook.<name>.event, which Git 2.54 and later run, read from every configuration file Git reads and whatever those include). Off means-c core.hooksPath=/dev/nullon the command line, which every supported Git honors, andhook.<name>.enabled=falsefor each configured hook. The driver reads the hooks again as its last step before starting that push. If they are not the approved ones, nothing is pushed and the person is asked about the hooks as they are now; if none is left to run, the push goes ahead with hooks off and no request. A hook file or a setting that cannot be read (anything but a missing file) fails the push: unknown never counts as no hook. The approved push gets a hooks directory of its own for as long as it runs, made underpush-hooksin the server's state directory (outside every checkout, and not the system temp directory), holding one launcher per approved hook that starts the hook by its own path (so husky's$0-relative lookups still work); a file that appears among the repository's hooks during the push is not run, and every configured hook but the approved ones is disabled. Git skips a hook file it may not execute and pushes without it, so before Git starts the driver writes one more script there the same way and runs it. Unless that script ran and exited 0 (the directory is on anoexecmount, the run was refused, or it did not end in time), nothing is pushed and the tool says the hooks could not be started. That is checked for the launchers only: a hook the launcher cannot start in turn fails the push in Git, as any failing hook does. Windows has no such permission and is not checked. The digest covers what it names and no more: each configured hook's name, command and the points of the push that start it, each hook file Git starts and, where that file is the shim husky 9 and Vite+ install (. "$(dirname "$0")/h"), the runnerhbeside it and the script of the hook's name one directory up, such as.husky/pre-push. A named file edited after that last read and before Git starts it runs as edited, as does a configured hook added in that time. Only hooks are limited: other programs Git's configuration can name for a push, such ascore.sshCommand, a credential helper or a remote helper, run as configured. The tool asks by MCP elicitation (McpClientInput): a sessionless client is answered with the request and calls the tool again with the reply, so a handler that asks must be safe to run from the start twice. It reads that reply before any push (McpClientInput.answered): a decline pushes nothing, whatever the hooks are by then. A call asks at most three times; the request's state carries the count, so it holds across a sessionless client's calls. A client that cannot be asked gets the push with hooks off. The Claude and Codex adapters never answer a request T3 Code's own tool made, whatever the turn's runtime mode and whatever was allowed for the session: it always reaches the person. In those threads the approval is the person's answer in the app, not the client's reply. The request is kept with the thread's MCP session under an id of its own and the state it was asked for; the adapter, which receives the person's pending-request response, leaves the answer with the thread's requests that ask that message; and the tool pushes only when the request the reply names (by the id in its state) holds an approval for that state. That reads the request once and ends it. A reply of "accept" for a request the person did not approve, or one that is gone because the server restarted or the thread's session was replaced, pushes nothing: the tool fails saying T3 Code has no approval from the person, and the next call asks again. A decline or cancel in the reply pushes nothing whatever the app recorded. For a client T3 Code shows no request for (an outside MCP client that declared elicitation, or a provider whose adapter does not pass on the person's answer), the client's reply is all there is and is taken as the person's answer. What those files go on to run, such as a package script or a file they source, is not part of the digest, so an approval is for the named files and not for everything the push executes. - Peer-link client pairing. Only a full-access peer link may mint a one-time client pairing on
the linked environment (since full-access agents can already run
t3 auth pairing create). The linked side enforces this itself, and the operation stays a human-triggered RPC/HTTP route rather than an MCP tool. The same route mints a code that links another environment at a chosen access level, and the linking side's RPC requires the caller to hold that level's scopes.
Web development servers can accept a fixed T3CODE_DEV_AUTH_TOKEN across worktrees and ports on one
hostname (see the development runbook). It
grants administrative access and is ignored by desktop and non-development servers.
Each environment hashes the value into its own database record and keeps independent SQLite state, signing keys, and revocation state. Normal credentials always take precedence: a rejected normal credential never falls back to the reusable dev credential.
Projects are organizational boundaries, not filesystem sandboxes. filesystem:read permits reading
any file the server's OS user can read (for example, artifacts an agent writes in a temp directory,
or a folder a worktree links in from outside it). Writes stay inside the workspace root, symlinks
included; see WorkspaceFileSystem.ts.
Signed asset URLs are bearer credentials for a single canonical file, rechecked by device/inode
identity on serve (AssetAccess.ts). They never
grant access to sibling files, with one exception: the URL of an HTML page opened from a workspace
also serves the files that page loads (styles, scripts, images, media, fonts and other pages) from
the page's own folder and the folders below it. It serves no hidden file, and no file that a link
in that folder points to outside it. Because filesystem:read is checked only at mint time, an
issued URL remains valid until it expires even if the session or grant is revoked.