[Bug]: Network access serves the API, session tokens and WebSocket over plain HTTP#26431

opened19d agobyKklkr-dev

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Windows desktop app 0.1.3: turn on Network access.
  2. userdata/server-runtime.json now shows "host":"0.0.0.0","port":3773.
  3. From a second machine on the LAN, pair a T3 Code desktop client with http://<host>:3773 and use it.
  4. curl -k https://<host>:3773/ fails the TLS handshake. curl http://<host>:3773/api/auth/session returns 200.
  5. In userdata/logs/server.trace.ndjson, every request from the remote client has "url.scheme":"http", including POST /oauth/token and POST /api/auth/websocket-ticket/rpc.

Expected behavior

With Network access on, credentials and thread content don't cross the network unencrypted. Either the server speaks TLS (own cert, or a generated one pinned at pairing, as proposed in #26428), or it refuses plain HTTP on non-loopback interfaces.

Actual behavior

All of it goes over http/ws: the token exchange, the WebSocket ticket, and the RPC socket carrying prompts, diffs, file contents and terminal output. Anyone who can see the traffic can read it, and anyone who can get in the path (one machine doing ARP spoofing is enough) can change it. /api/auth/session lists bearer-access-token and browser-session-cookie among the session methods. Both can be replayed if captured, against a host where agents often run at Full access. I couldn't tell from the trace whether direct LAN sessions get DPoP-bound tokens. If they do, replay is off the table, but reading and tampering still work.

Auth itself holds: GET /api/orchestration/shell without a credential gets 401, from loopback too. The transport is the problem. The 0.1.3 server bundle imports node:http and nothing for TLS, and none of the T3CODE_* variables takes a cert or key.

Impact

Minor bug or occasional failure

Version or commit

0.1.3

Environment

Windows 11, T3 Code desktop 0.1.3 (Electron 44.9.3) as host. Client: T3 Code desktop 0.1.3 on another Windows machine, same LAN.

Logs or stack traces

shell
1{"name":"POST","attributes":{"http.route":"/oauth/token","url.full":"http://<host>:3773/oauth/token","url.scheme":"http","client.address":"<lan-client>","http.response.status_code":200}}
2{"name":"POST","attributes":{"http.route":"/api/auth/websocket-ticket/:use","url.full":"http://<host>:3773/api/auth/websocket-ticket/rpc","url.scheme":"http","client.address":"<lan-client>","http.response.status_code":200}}

Workaround

A TLS-terminating reverse proxy in front of :3773: Caddy in Docker with a self-signed leaf cert, imported into each client's CurrentUser\Root. The server honours X-Forwarded-Proto, so its trace shows the https URL for proxied requests, and auth still returns 401 without a credential. t3 pair --base-url https://<host>:<tls-port> gives a pairing link for it. The plaintext port stays reachable until you add a firewall rule blocking :3773 from non-loopback addresses. Every user who wants encryption has to build this themselves.

Related: #26428 (the feature side: native TLS and cert pinning), #22214, #26421.

Written up with Claude Code from a session on the affected machine.

Synced from GitHub

+1 for native TLS on the server listener. My use case is Linked environments between machines on my lab network (172.16.x).

Linking fails today with:

1PeerLinkError: This environment could not reach <machinename>: http://172.16.16.xxx:3773/ is plain http, which would send the link's credentials unencrypted. Use its https address, or its Tailscale address.

I can issue certs to these machines from my own CA and reach them by DNS name, so a bring-your-own cert option would solve this cleanly. I would rather not run a reverse proxy or add Tailscale on every box just to get TLS. Something along the lines of what #26428 proposed:

  1. T3CODE_TLS_CERT / T3CODE_TLS_KEY (plus matching t3 serve flags and a desktop setting) so the server listens on https directly
  2. t3 pair and the advertised routes use the https address when TLS is on
  3. Peer links trust the OS store or NODE_EXTRA_CA_CERTS for private CAs

At the moment the only options are Tailscale, T3 Connect, an SSH tunnel or a reverse proxy, and each one adds another moving part to run and maintain.

Related: #26840 tracks the peer link refusal itself.

Happy to test a build if that helps.

Thanks for writing this up. It asks for new behaviour rather than reporting a defect, so it does not belong in the bug tracker and I'm closing it as not planned here. Feature ideas are discussed in Discussions: please post it there.