GeezerVison is showing github.com — fix(server): a loopback port forward on macOS no longer takes over local agents' T3 tools by juliusmarminge · Pull Request #42013 · pingdotgg/t3code
Conversation
On macOS with network access on, another app could quietly take over 127.0.0.1 on T3 Code's port. Opening a remote workspace in Cursor does this: Cursor forwards the remote T3 server's port to the same local port. Local agents then sent their T3 tool calls to the remote server and got sign-in errors. The server now also holds the loopback address when it listens on all interfaces, so loopback traffic always reaches the local T3 Code backend and the forward has to use another port.
Fixes #42006
Reproduction on main
Commit 84a0c05 (origin/main) on a pool Mac (macOS 26, Apple silicon), in a fresh worktree after vp i. Steps: (1) Started the 'local' backend the way desktop network access binds it: node apps/server/src/bin.ts serve --no-browser --host 0.0.0.0 --port P --base-dir <run>/local-home. (2) Started a second T3 server standing in for the remote environment: serve --host 127.0.0.1 --port Q --base-dir <run>/remote-home. (3) GET /.well-known/t3/environment on 127.0.0.1:P and on :P both returned the local server's environment id. (4) Started a Node listener net.createServer().listen(P, '127.0.0.1') that pipes to 127.0.0.1:Q, the same kind of loopback listener a VS Code/Cursor Remote SSH port forward creates. macOS accepted the bind, and lsof -iTCP:P -sTCP:LISTEN showed both *:P (T3) and 127.0.0.1:P (forward). (5) After that, 127.0.0.1:P returned the REMOTE server's environment id, while :P still returned the local one. A POST to http://127.0.0.1:P/mcp (the endpoint T3 gives agents, from McpSessionRegistry) got 401 invalid_mcp_credential with www-authenticate: Bearer error="invalid_token", and the remote server logged rejected MCP request with an unusable credential {reason: 'unknown_or_expired_token'}, matching the reporter's remote-side logs. Cursor itself and a real Codex thread were not run (no Cursor install or ChatGPT OAuth on workers); the forward was simulated with the same loopback bind Cursor's forwarder makes.
Evidence
On macOS 26.6.2 (Apple silicon), started fresh real local and remote T3 backends, confirmed local routing, attempted the same loopback TCP forward, then repeated loopback and LAN discovery requests.
Reproduction driver. The MCP probe intentionally used an invalid credential and returned 401 on both commits; the demonstrated difference is backend routing and competing-listener rejection.
Not shown:
- Cursor's actual Remote SSH UI was not run; its loopback TCP forward was simulated using the same bind and forwarding behavior as the supplied triage reproduction.
- Permanent blocker: first-party ChatGPT OAuth is unavailable on workers, so a signed-in Codex thread successfully calling local T3 tools was not demonstrated. Routing preservation was demonstrated against real T3 servers.
- Electron network-access controls were not exercised; the local backend was launched directly with the documented equivalent wildcard bind.
Tests
vp test run src/httpResponseErrorGuard.test.ts (apps/server, Linux): 6 passed
vp test run src/httpResponseErrorGuard.test.ts -t holdLoopback on macOS 26: passes with the fix; fails with main's code (expected 'listening' to be 'EADDRINUSE')
- End to end on macOS,
serve --host 0.0.0.0 plus a 127.0.0.1 bind on the same port: the forward gets EADDRINUSE, and loopback reaches the local environment
vp run typecheck (apps/server): passed
vp lint on the changed files and vp run knip:check: passed
- PR CI: all 38 checks passed on 805f77e
Not in this change
Who did the work
- Written by Claude Opus 5.5, in Claude Code
- Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
- Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5
Run by the t3code factory in T3 Code.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Thread transfer impact
✅ Thread transfer remains within every enforced ceiling.
| Provider |
Metric |
Main baseline |
This PR |
Impact |
PR ceiling |
|
| Codex |
Total thread wire |
5.0 KiB |
5.0 KiB |
0 B (0.0%) |
6.8 KiB |
✅ |
| Codex |
Thread snapshot wire |
3.8 KiB |
3.8 KiB |
0 B (0.0%) |
4.9 KiB |
✅ |
| Codex |
Live turn WebSocket wire |
1.2 KiB |
1.2 KiB |
0 B (0.0%) |
2.0 KiB |
✅ |
| Codex |
Live turn WebSocket decoded |
21.5 KiB |
21.5 KiB |
0 B (0.0%) |
24.4 KiB |
✅ |
| Codex |
Live turn messages |
1 |
1 |
0 (0.0%) |
8 |
✅ |
| Claude |
Total thread wire |
5.0 KiB |
5.0 KiB |
0 B (0.0%) |
6.8 KiB |
✅ |
| Claude |
Thread snapshot wire |
3.8 KiB |
3.8 KiB |
0 B (0.0%) |
4.9 KiB |
✅ |
| Claude |
Live turn WebSocket wire |
1.2 KiB |
1.2 KiB |
0 B (0.0%) |
2.0 KiB |
✅ |
| Claude |
Live turn WebSocket decoded |
21.9 KiB |
21.9 KiB |
0 B (0.0%) |
24.4 KiB |
✅ |
| Claude |
Live turn messages |
1 |
1 |
0 (0.0%) |
8 |
✅ |
Other scenarios
All 64 scenario measurements match main.
All 64 scenario measurements
| Provider |
Scenario |
Metric |
Main baseline |
This PR |
Impact |
PR ceiling |
|
| Codex |
short turn resume |
WebSocket decoded |
10.5 KiB |
10.5 KiB |
0 B (0.0%) |
12.7 KiB |
✅ |
| Codex |
short turn resume |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Codex |
long turn running, cold open |
HTTP decoded |
281.7 KiB |
281.7 KiB |
0 B (0.0%) |
302.7 KiB |
✅ |
| Codex |
long turn running, cold open |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Codex |
long turn running, history page |
HTTP decoded |
92.4 KiB |
92.4 KiB |
0 B (0.0%) |
107.4 KiB |
✅ |
| Codex |
long turn running, history page |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Codex |
long turn finished, cold open |
HTTP decoded |
381.5 KiB |
381.5 KiB |
0 B (0.0%) |
410.2 KiB |
✅ |
| Codex |
long turn finished, cold open |
rows |
151 |
151 |
0 (0.0%) |
151 |
✅ |
| Codex |
long turn finished, socket cold open |
WebSocket decoded |
381.6 KiB |
381.6 KiB |
0 B (0.0%) |
410.2 KiB |
✅ |
| Codex |
long turn finished, socket cold open |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Codex |
long turn finished, socket cold open |
rows |
151 |
151 |
0 (0.0%) |
151 |
✅ |
| Codex |
long turn finished, work page |
HTTP decoded |
186.2 KiB |
186.2 KiB |
0 B (0.0%) |
200.2 KiB |
✅ |
| Codex |
long turn finished, work page |
rows |
150 |
150 |
0 (0.0%) |
150 |
✅ |
| Codex |
idle thread resume |
WebSocket decoded |
65 B |
65 B |
0 B (0.0%) |
200 B |
✅ |
| Codex |
idle thread resume |
WebSocket messages |
1 |
1 |
0 (0.0%) |
1 |
✅ |
| Codex |
fleet shell snapshot |
HTTP decoded |
42.4 KiB |
42.4 KiB |
0 B (0.0%) |
53.7 KiB |
✅ |
| Codex |
fleet shell snapshot |
rows |
27 |
27 |
0 (0.0%) |
27 |
✅ |
| Codex |
fleet shell subscribe |
WebSocket decoded |
65 B |
65 B |
0 B (0.0%) |
200 B |
✅ |
| Codex |
fleet shell subscribe |
WebSocket messages |
1 |
1 |
0 (0.0%) |
1 |
✅ |
| Codex |
fleet shell resume check |
HTTP decoded |
18 B |
18 B |
0 B (0.0%) |
100 B |
✅ |
| Codex |
fleet shell resume check |
rows |
0 |
0 |
0 |
0 |
✅ |
| Codex |
stale shell reload |
HTTP decoded |
42.4 KiB |
42.4 KiB |
0 B (0.0%) |
53.7 KiB |
✅ |
| Codex |
stale shell reload |
rows |
27 |
27 |
0 (0.0%) |
27 |
✅ |
| Codex |
stale shell resume |
WebSocket decoded |
140 B |
140 B |
0 B (0.0%) |
400 B |
✅ |
| Codex |
stale shell resume |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Codex |
stale todo list cold open |
HTTP decoded |
72.4 KiB |
72.4 KiB |
0 B (0.0%) |
83.0 KiB |
✅ |
| Codex |
stale todo list cold open |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Codex |
stale todo list cold open |
nodes |
2 |
2 |
0 (0.0%) |
4 |
✅ |
| Codex |
stale todo list cold open |
subagents |
2 |
2 |
0 (0.0%) |
4 |
✅ |
| Codex |
stale todo list cold open |
plans |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Codex |
stale todo list cold open |
providerTurns |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Codex |
stale todo list cold open |
checkpoints |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Claude |
short turn resume |
WebSocket decoded |
10.6 KiB |
10.6 KiB |
0 B (0.0%) |
12.7 KiB |
✅ |
| Claude |
short turn resume |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Claude |
long turn running, cold open |
HTTP decoded |
283.3 KiB |
283.3 KiB |
0 B (0.0%) |
302.7 KiB |
✅ |
| Claude |
long turn running, cold open |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Claude |
long turn running, history page |
HTTP decoded |
93.4 KiB |
93.4 KiB |
0 B (0.0%) |
107.4 KiB |
✅ |
| Claude |
long turn running, history page |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Claude |
long turn finished, cold open |
HTTP decoded |
384.2 KiB |
384.2 KiB |
0 B (0.0%) |
410.2 KiB |
✅ |
| Claude |
long turn finished, cold open |
rows |
151 |
151 |
0 (0.0%) |
151 |
✅ |
| Claude |
long turn finished, socket cold open |
WebSocket decoded |
384.3 KiB |
384.3 KiB |
0 B (0.0%) |
410.2 KiB |
✅ |
| Claude |
long turn finished, socket cold open |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Claude |
long turn finished, socket cold open |
rows |
151 |
151 |
0 (0.0%) |
151 |
✅ |
| Claude |
long turn finished, work page |
HTTP decoded |
188.1 KiB |
188.1 KiB |
0 B (0.0%) |
200.2 KiB |
✅ |
| Claude |
long turn finished, work page |
rows |
150 |
150 |
0 (0.0%) |
150 |
✅ |
| Claude |
idle thread resume |
WebSocket decoded |
66 B |
66 B |
0 B (0.0%) |
200 B |
✅ |
| Claude |
idle thread resume |
WebSocket messages |
1 |
1 |
0 (0.0%) |
1 |
✅ |
| Claude |
fleet shell snapshot |
HTTP decoded |
43.0 KiB |
43.0 KiB |
0 B (0.0%) |
53.7 KiB |
✅ |
| Claude |
fleet shell snapshot |
rows |
27 |
27 |
0 (0.0%) |
27 |
✅ |
| Claude |
fleet shell subscribe |
WebSocket decoded |
66 B |
66 B |
0 B (0.0%) |
200 B |
✅ |
| Claude |
fleet shell subscribe |
WebSocket messages |
1 |
1 |
0 (0.0%) |
1 |
✅ |
| Claude |
fleet shell resume check |
HTTP decoded |
18 B |
18 B |
0 B (0.0%) |
100 B |
✅ |
| Claude |
fleet shell resume check |
rows |
0 |
0 |
0 |
0 |
✅ |
| Claude |
stale shell reload |
HTTP decoded |
43.0 KiB |
43.0 KiB |
0 B (0.0%) |
53.7 KiB |
✅ |
| Claude |
stale shell reload |
rows |
27 |
27 |
0 (0.0%) |
27 |
✅ |
| Claude |
stale shell resume |
WebSocket decoded |
140 B |
140 B |
0 B (0.0%) |
400 B |
✅ |
| Claude |
stale shell resume |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Claude |
stale todo list cold open |
HTTP decoded |
73.4 KiB |
73.4 KiB |
0 B (0.0%) |
83.0 KiB |
✅ |
| Claude |
stale todo list cold open |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Claude |
stale todo list cold open |
nodes |
2 |
2 |
0 (0.0%) |
4 |
✅ |
| Claude |
stale todo list cold open |
subagents |
2 |
2 |
0 (0.0%) |
4 |
✅ |
| Claude |
stale todo list cold open |
plans |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Claude |
stale todo list cold open |
providerTurns |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Claude |
stale todo list cold open |
checkpoints |
1 |
1 |
0 (0.0%) |
2 |
✅ |
Baseline: de8551b · PR result: 805f77e · Source CI: success
Scenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 24, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
The HTTP server now holds a loopback listener on the same port when it listens on a wildcard address. The listener forwards accepted sockets while the main server is listening. A test checks that another listener cannot bind that loopback port and that the HTTP server still responds.
Changes: Wildcard loopback binding
| Layer / File(s) |
Summary |
Add and integrate loopback listener apps/server/src/httpResponseErrorGuard.ts, apps/server/src/server.ts, apps/server/src/httpResponseErrorGuard.test.ts |
holdLoopbackOnWildcard opens a loopback listener on the port used by a wildcard-bound server and forwards accepted sockets while the main server is listening. The server setup applies the function before the existing guards. The test checks the port conflict and confirms the server returns status 200. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
pingdotgg/t3code#25161 — The issue reports a wildcard and specific-address listener collision. This change also addresses listener behavior on the same port, although its effect on the Linux case is not established.
Merge Risk: Minimal · up to 805f7
-
This change makes the server hold the loopback address on the same port when it listens on all interfaces. That stops a loopback port forward from taking requests meant for the local backend on macOS. No concrete merge-blocking risk was found. IPv6 loopback is explicitly not covered.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title is a conventional commit that names the main change: a loopback port forward on macOS no longer takes over local T3 agent tools. It matches the summarized change, which holds 127.0.0.1 when … |
| Linked Issues check |
 |
Issue #42006 requires that a Cursor Remote SSH forward of the T3 port does not break local agent tools. At head 805f77e, holdLoopbackOnWildcard in apps/server/src/httpResponseErrorGuard.ts runs on… |
| Out of Scope Changes check |
 |
All changed areas serve the issue objective. The changes are in httpResponseErrorGuard.ts (new holdLoopbackOnWildcard), its test file (holdLoopbackOnWildcard test), and server.ts (import and w… |
| Description check |
 |
The description covers the problem, the change, scope, and verification, and it follows the template's section order. It explains the macOS loopback port-forward conflict that diverts T3 tool calls to… |
Full details: Title check
-
Explanation
The title is a conventional commit that names the main change: a loopback port forward on macOS no longer takes over local T3 agent tools. It matches the summarized change, which holds 127.0.0.1 when the server listens on a wildcard address. The title is somewhat long at 89 characters, but it stays specific and on topic.
Full details: Linked Issues check
-
Explanation
Issue #42006 requires that a Cursor Remote SSH forward of the T3 port does not break local agent tools. At head 805f77e, holdLoopbackOnWildcard in apps/server/src/httpResponseErrorGuard.ts runs on the listening event. When the server listens on a wildcard host, it binds 127.0.0.1 on the same port. Accepted loopback sockets go to the server only while it listens. This makes the local backend hold loopback, so a later forward on 127.0.0.1:P gets EADDRINUSE and cannot capture agent requests. The PR wraps the server with this function in apps/server/src/server.ts, before rejectRequestsUntilServing. The added test holdLoopbackOnWildcard in httpResponseErrorGuard.test.ts checks that a second bind on 127.0.0.1 fails with EADDRINUSE and that the original server still answers 200. The Mac reproduction in the PR description shows the same result end to end. I did not re-run that reproduction. The fix covers the case where T3 binds before the forward. If the forward binds first, the loopback bind fails silently and the fix does not apply. The issue describes T3 starting first, so this does not fail the requirement. Issue #19011 and the restart workaround are not acceptance criteria.
Full details: Out of Scope Changes check
-
Explanation
All changed areas serve the issue objective. The changes are in httpResponseErrorGuard.ts (new holdLoopbackOnWildcard), its test file (holdLoopbackOnWildcard test), and server.ts (import and wrapping call). The summary reports no exported declaration changes beyond the new function. The PR description says IPv6 loopback and the SSH launcher port logic (#19011) and automatic port selection (#41730) are unchanged. Those are exclusions, not extra changes. I found no unrelated change in the reviewed evidence.
Full details: Description check
-
Explanation
The description covers the problem, the change, scope, and verification, and it follows the template's section order. It explains the macOS loopback port-forward conflict that diverts T3 tool calls to a remote server. It links the issue (#42006) and gives a reproduction on main, the fix commit, and test results with evidence. Items the template asks for are present: the Problem section gives reproduction steps and environment, the Change section explains the wildcard loopback hold, and the Verification section lists focused tests with observed results and states what was not checked. The description also names the model and harness that did the work, as the template requests.
Finishing Touches
-
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between de8551b and 805f77e.
Files selected for processing: 3
-
apps/server/src/httpResponseErrorGuard.test.ts
apps/server/src/httpResponseErrorGuard.ts
apps/server/src/server.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size:S
10-29 changed lines (additions + deletions).
vouch:trusted
Author is trusted by repo permissions or the VOUCHED list.
Milestone
No milestone
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.
|