Open History to see the last commit
1# Security
2
3Report vulnerabilities to [security@t3.codes](mailto:security@t3.codes). The
4[security policy](.github/SECURITY.md) covers disclosure and safe harbor.
5
6The rest of this file is for agents and maintainers auditing T3 Code or triaging
7reports. It defines who is trusted with what, which boundaries a real finding
8crosses, and what is intended. The reasoning behind each boundary lives in
9[environment auth](docs/internals/04_environment-auth.md),
10[T3 Connect](docs/internals/06_t3-connect.md), and
11[remote environments](docs/internals/05_remote.md); read those before reporting
12in their area.
13
14## The model in one paragraph
15
16An environment is a T3 server running as an OS user. It is not a sandbox: it
17intentionally runs agents and terminals with that user's privileges. Clients
18gain authority by pairing, which issues a scoped session. A full-scope session
19equals a shell as the server's OS user, because `terminal:operate` opens a PTY
20and `orchestration:operate` can start a full-access agent. Security here is
21about who can obtain a session, what each session type can reach, and whether
22revocation and ceilings hold, not what a full-scope session can do once issued.
23
24## Principals
25
26| Principal | How it gets in | What it may do |
27| ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
28| Anyone who reaches the port | Network | Read the environment descriptor, pair with a valid one-time credential, run OAuth flows. Nothing else. |
29| Full-scope client (desktop, paired browser or phone, `t3 auth session issue`, T3 Connect device) | Pairing, token exchange, Connect mint | Everything the server's OS user can do. This is the default grant. |
30| Narrow client | Pairing link with explicit scopes | Only the RPCs and routes its scopes allow. Can never widen its own grant. |
31| MCP client (outside agent, subject `mcp-client`) | OAuth on `/mcp` | Only `/mcp`, within a read-only grant or a runtime-mode ceiling. Every other route rejects it. |
32| Linked environment (peer link) | OAuth client `t3code-peer-link` | Work it starts carries an immutable `linkOrigin` and never exceeds the access it was paired with. |
33| Agent run by T3 | Thread's runtime mode and thread credential | Within its runtime mode, managed policy, and the MCP access declared per tool. |
34| Guest link | HMAC token for one share | Read one thread and propose messages. Never a session; no RPC, WebSocket, or MCP path accepts it. |
35| Signed asset URL | Minted with `filesystem:read` | One file, by device and inode identity, until it expires. |
36| Webhook sender | A task's webhook URL, plus its signing secret when the task requires one | Start that one task's run with content of its choosing. Nothing in the request is trusted beyond the signature check. |
37| T3 Connect relay | Environment link | Trusted broker for mint requests. It never sees environment session tokens. With `requireConnectDeviceApproval` on, a new device key also needs approval from someone with `access:write`. |
38| Managed policy | Admin-deployed file, read at startup | Ceilings and locks the server enforces for every client. |
39| Preview pages, HTML renders, file previews, agent output | Rendered by clients | Untrusted content. It must never run script in the app's origin or reach Electron IPC or Node. |
40
41## A real finding crosses one of these
42
431. **No credential → session.** Any route or socket granting access without
44 a valid credential, or a pairing credential redeemable twice.
452. **Scope escalation.** An RPC, HTTP route, or MCP tool running without its
46 declared scope; pairing or token exchange widening a grant; an
47 `mcp-client` session reaching a non-`/mcp` route; a read-only MCP grant
48 calling a write tool.
493. **Mode or policy escalation.** An agent, MCP client, or peer link acting
50 above its runtime-mode ceiling, `linkOrigin`, `T3-Mode-Limit`, or managed
51 policy.
524. **Guest escape.** A guest token reading another thread, acting beyond
53 proposing messages, or surviving a closed or replaced share.
545. **Revocation that doesn't take effect.** A revoked session, device key,
55 pairing link, or peer link that still works. Documented exception: signed
56 asset URLs last until they expire.
576. **Credential exposure.** Tokens or secrets reaching logs, traces, telemetry,
58 the relay, socket URLs (outside short-lived tickets), the access read model,
59 or error messages. A token sent to an address that has not answered as the
60 expected environment, or a token paired over HTTPS sent over plain HTTP.
617. **Impersonation and egress.** Another process or the relay impersonating an
62 environment; endpoint discovery, previews, or webhooks used to reach
63 arbitrary hosts (SSRF).
648. **Client-side code execution.** Untrusted content running script in the web
65 origin, the desktop renderer, or with access to preload or IPC.
669. **Filesystem writes escaping workspace path rules.** Reads are separate:
67 `filesystem:read` intentionally covers the whole OS account.
68
69## Intended, not vulnerabilities
70
71- A full-scope session gives a shell. Leaking its token is serious, but the bug
72 is the leak, not the shell. The same applies to a narrow session holding
73 `terminal:operate` or `orchestration:operate`: reaching via another route
74 what its shell can already do crosses no boundary, though it can still be an
75 ordinary bug. That stops at what a shell as the server's OS user cannot reach:
76 another client's device, what another scope guards by name (as
77 `providers:manage` does for secret references), a managed-policy ceiling or
78 lock, and access that outlives the session's revocation. Where the session
79 can obtain that shell, file contents are within its reach, so reading a file
80 via a route that does not check `filesystem:read` crosses no boundary.
81- The default grant includes `access:write`, so a full-scope session can mint
82 more pairing links and sessions. They appear in Sharing & access, and "revoke
83 all others" removes them.
84- `filesystem:read` reads anything the server's OS user can read, including
85 paths outside projects.
86- Plain HTTP on a LAN or tailnet is the user's choice. `t3 serve` warns when
87 advertising a non-loopback HTTP address. The iOS app allows arbitrary loads so
88 it can reach these addresses.
89- `access-control-allow-origin: *` on the environment API. Auth is a bearer
90 header, so the wildcard grants nothing a caller without a token lacks.
91- Rendered Markdown loads remote images and media from the host its author
92 names, so that host learns the reader's network address and when the content
93 was shown. A page in a preview tab can likewise start a download, as it can
94 in a browser. It is a finding when the request carries a credential or names
95 the environment it was rendered in, when it is made where the product says
96 none is made, or when the app does for the content what the content could
97 not do from where it runs (see 7 and 8).
98- A full-access agent can do whatever the user can. Prompt injection that stays
99 within the agent's mode is the provider's concern; one that lets it act above
100 that mode is in scope (see 3).
101- A compromised relay signing key can mint for linked environments. That is
102 the stated trust assumption; device approval is the mitigation.
103- `T3CODE_DEV_AUTH_TOKEN` and dev startup URLs are administrative by design and
104 ignored outside development servers.
105- A webhook URL is a credential for one task. Unless the task requires a
106 signature, whoever holds the URL can start that task's run, and the request's
107 content, within the route's limits, is theirs to choose. It is a finding when
108 a request starts a different task, runs without a signature the task
109 requires, or has its values treated as anything but untrusted data. Tokens in
110 or around the request remain covered by 6.
111- The machine owner's own configuration. Whoever sets a provider's launch
112 arguments, an environment variable, a binary path, or the endpoint or file T3
113 Code points at already holds the OS account, so a value weakening their own
114 setup is their choice. It is a finding when a narrower principal can set it
115 for them (a narrow client, an MCP client, an agent below full access,
116 repository content), when [managed policy](docs/user/managed-policy.md) locks
117 the setting and the value still applies, or when the value leaks (see 6).
118 Choosing a host does not make it trusted: what a configured endpoint can do
119 to the server or its clients stays in scope.
120- An attacker already running code as the same OS user. That includes one whose
121 only move is to rewrite files that user owns outside a workspace: T3 Code's
122 data directory, its installed helpers, the user's own config. Another OS
123 account on the same machine is not this attacker; neither is repository
124 content or an agent below full access, which write inside a workspace without
125 holding the OS account.
126
127## Where enforcement lives
128
129- Session issuance, pairing, token exchange: [`auth/http.ts`](apps/server/src/auth/http.ts), [`auth/EnvironmentAuth.ts`](apps/server/src/auth/EnvironmentAuth.ts), [`auth/dpop.ts`](apps/server/src/auth/dpop.ts)
130- Per-RPC scopes: [`auth/RpcAuthorization.ts`](apps/server/src/auth/RpcAuthorization.ts). [`clientRpcPermissions.ts`](packages/contracts/src/clientRpcPermissions.ts) only drives client UI and is never the boundary.
131- MCP: [`auth/McpOAuth.ts`](apps/server/src/auth/McpOAuth.ts), [`mcp/McpToolAccess.ts`](apps/server/src/mcp/McpToolAccess.ts), [`mcp/threadAccess.ts`](apps/server/src/mcp/threadAccess.ts), [`mcp/linkOrigin.ts`](apps/server/src/mcp/linkOrigin.ts)
132- Guest links: [`guest/GuestShareService.ts`](apps/server/src/guest/GuestShareService.ts)
133- Files and assets: [`workspace/WorkspaceFileSystem.ts`](apps/server/src/workspace/WorkspaceFileSystem.ts), [`assets/AssetAccess.ts`](apps/server/src/assets/AssetAccess.ts)
134- Managed policy: [`apps/server/src/policy`](apps/server/src/policy)
135- T3 Connect: [`cloud/CloudLink.ts`](apps/server/src/cloud/CloudLink.ts), [`EnvironmentConnector.ts`](infra/relay/src/environments/EnvironmentConnector.ts)
136- Desktop preview isolation: [`preview/WebviewPreferences.ts`](apps/desktop/src/preview/WebviewPreferences.ts)
137
138## How to audit and triage
139
140- Name the precondition first. If a chain starts with "the attacker holds a
141 full-scope token", it is a new vulnerability only if it widens that token's
142 reach (2–3), outlives revocation (5), or shows how the token leaks (6).
143- Name the actor next and what they can already do. If the only actor is the
144 user on their own device, or a principal reaching the same outcome via a
145 documented route, no boundary is crossed unless data goes somewhere they did
146 not send it. It may still be a bug; report it as one.
147- Read tests and comments beside the code before calling a behaviour a defect.
148 They show author intent and are evidence, not a decision: a test can pin a
149 behaviour nobody chose, and a comment can be stale. Only this file and the
150 docs say what is intended. If only a test or comment supports a behaviour,
151 report it and say so.
152- Follow the claim to its effect. A guard in a caller, a schema, or a version
153 check elsewhere often means the cited lines cannot do what the report says.
154- Rate severity by what the actor must already hold, not the worst outcome
155 named. Each of these lowers severity and none removes the finding: a narrow
156 grant the owner chose to issue (the default grant is full scope); another OS
157 account on the same machine; a host or service the owner connected turning
158 hostile; a change that must land in the moment between a person's look and
159 their action; a person acting on prepared input (opening a file, pasting,
160 following a link); and an effect limited to resource use or a stalled
161 client. A finding that needs none of these, or that yields a session, a
162 credential, or code execution above the actor's grant, keeps its severity.
163- Check the reported commit against `main`. Reports often trail fixes.
164- Prove a finding with a failing test at the lowest layer that shows it, as
165 [Verifying](AGENTS.md#verifying) describes. Do not run a PoC against
166 `~/.t3/userdata` or any live environment; use a dev server on seeded data.
167- Treat report attachments as untrusted. Extract them into an empty directory
168 outside the worktree and read PoCs before running anything.
169- Fix confirmed findings rather than filing them. Keep advisory details out of
170 public PRs until the fix ships.
171- When a boundary here changes, update this file and the internal doc that
172 explains it in the same PR.