Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): an empty preview port no longer answers 403 to remote desktops #48087

Mergedthefrikidude(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/48087/headmerged by juliusmarminge View on GitHub

Problem

The desktop app checks whether a remote server runs on the same machine. It asks the server's preview tunnel for a port that nothing on the server listens on, and the server answers 403 Forbidden. Intrusion filters flag that status. The reporter's gateway then drops all traffic to the server for 300 seconds, so the client cannot stay connected.

Change

A port with no listener now answers 404 Not Found. The x-t3-tunnel-port-refused header and the body stay the same, and desktop and mobile read the header before the status.

502 would also describe it, but Cloudflare replaces an origin 502 with its own page (#39763).

Scope

Fixes #48028. It is a small fix to one status code.

Missing permission, a disabled tunnel, and the server's own port still answer 403. A port forward that stays open after someone disables the tunnel still gets 403 on each connection. That happens without this change and is not part of it.

Verification

I reproduced the bug with a Linux server in Docker and the desktop dev app on macOS, then repeated the steps with the fix.

StepBeforeAfter
Tunnel request for an empty port403404, same header and body
Reload the app with a remote thread open403404
Restart the server and let the app reconnect403404
Same-machine check resultdifferent machinedifferent machine
Suricata 8.0.8 with ET Open rule 2101201, on the captured trafficalertsno alerts
  • The updated test for an empty port failed with 403 before the change. The server and desktop tunnel tests pass with it (32 tests), and so does vp run check:changed.
  • The iOS tunnel listener, compiled on macOS, and the Android listener, run on a desktop JVM, both read the 404 as a port failure.

Not checked: a phone or simulator, a Windows client, T3 Connect through Cloudflare, an SSH forward, and a UniFi gateway. The Suricata run shows that the rule no longer fires, not that a gateway keeps the connection.

Model: Claude Sonnet 5.5. Harness: Claude Code in T3 Code.

🤖 Generated with Claude Code

    1. Pushed9b8ab38

    2. Evidence

      Evidence\n\nSteps on both commits: start the real PreviewTunnel server; bind and close an ephemeral loopback port; request /api/preview/tunnel?port=<closed-port>; record the HTTP status and x-t3-tunnel-port-refused header.\n\n| Before — base 3eb58949194ce010be0af51d861d3292127e8a37 | After — head 9b8ab3815c18b5a173a9834096b6bee609e2e274 |\n|---|---|\n| Base capture — observed status:403, portRefused:true | Head capture — observed status:404, portRefused:true |

      Not shown:

      • The desktop shell's same-machine classification and IDS/IPS reaction were not separately captured; this run directly exercised the server response that drives that classification.
    3. juliusmarminge added labelstakeover:ready

    4. juliusmarminge removed labelstakeover:in-progress

    5. juliusmarminge merged this7b7ca65

    6. juliusmarminge closed this

    7. juliusmarminge removed labelstakeover:ready

Sign in to join this conversation.