Repository navigation
fix(server): WebSocket DPoP proofs verify behind proxies that forward wss - #40729
juliusmarminge wants to merge 2 commits into
Conversation
Reproduces #40725: X-Forwarded-Proto: wss on the /ws upgrade makes the server verify the proof against http:// and reject it with url_mismatch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… wss Traefik sends X-Forwarded-Proto: wss on WebSocket upgrades. requestUrl only treated https as secure, so /ws was rebuilt as http:// and the client's DPoP proof for https:// was rejected with url_mismatch. Treat wss as secure too. Fixes #40725 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: Scenario and decoded snapshot size10 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.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Behind a TLS-terminating proxy like Traefik, remote clients could not open the WebSocket connection. Traefik sends
X-Forwarded-Proto: wsson the/wsupgrade, and the server only treatedhttpsas secure. So it checked the client's DPoP proof, signed forhttps://, against anhttp://URL and rejected it with 401.requestUrlnow treatswssas secure as well.Fixes #40725
Reproduction on main
Commit 11224f6 (origin/main). Ran
T3CODE_DEV_SEED=0 node src/bin.ts serve --mode web --host 127.0.0.1 --port 38773 --base-dir <scratch>from apps/server. In front of it ran a Node proxy that imitates Traefik's TLS termination: it rewrites Host to t3.example.com, sends X-Forwarded-Proto: https on normal HTTP requests and wss (or https, as a control) on the WebSocket upgrade. A client driver made a P-256 DPoP key, exchanged a pairing token at POST /oauth/token with a DPoP proof (htu https://t3.example.com/oauth/token), got POST /api/auth/websocket-ticket/rpc, then sent GET /ws?orchestrationProtocol=2&wsTicket=..&dpop=<proof for https://t3.example.com/ws>. With X-Forwarded-Proto: wss: descriptor 200, token 200, ticket 200, /ws 401 {code:auth_invalid, reason:invalid_credential, dpopFailureReason:request_mismatch}, and the server trace recorded environment.dpop.failure_code=url_mismatch. Same flow with X-Forwarded-Proto: https on a fresh pairing token: /ws 101 Switching Protocols. Unit check: HttpServerRequest.fromWeb with x-forwarded-proto wss gives requestUrl http://t3.example.com/ws, while https gives https://. Failing test pushed on factory/repro-40725 (9487506): the wss case fails on main and the https case passes. Accepting 'wss' in requestUrl makes both pass; that fix was discarded and is not on the branch.Evidence
Being captured: before and after in the real app. This section is filled in before the pull request can merge.
Tests
vp test run src/auth/EnvironmentAuth.test.ts -t "TLS proxy forwards"(before fix): 1 failed (wss), 1 passed (https)vp test run src/auth/EnvironmentAuth.test.ts(after fix): 31 passedvp run check:changed: format, lint, knip, typecheck (3 packages) and tests (2 files, 33 tests) all passNot in this change
Who did the work
Run by the t3code factory in T3 Code.