Skip to content

Commit 7a4b5e7

Browse files
committed
fix(e2e): remove broken WS credential injection test (upstream limitation)
1 parent fc68024 commit 7a4b5e7

2 files changed

Lines changed: 7 additions & 49 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ Extends phantom swap to handle OAuth credentials bidirectionally. Static credent
162162
|----------|---------------------|-------------------|--------------------|
163163
| HTTP/HTTPS | Built-in MITM, phantom swap | Full request/response | Per-request (allow-once = one HTTP request) |
164164
| gRPC | Header phantom swap via go-mitmproxy Addon hooks (per HTTP/2 stream) | Request/response metadata | Per-request (each HTTP/2 stream is a separate policy check) |
165-
| WebSocket | Handshake headers + text frame phantom swap | Text frame deny + redact rules | Per-connection (one upgrade = one session) |
165+
| WebSocket | Text frame phantom swap (handshake header injection blocked by go-mitmproxy upstream limitation) | Text frame deny + redact rules | Per-connection (one upgrade = one session) |
166166
| SSH | Jump host, key from vault | N/A | Per-connection (channels belong to one session) |
167167
| IMAP/SMTP | AUTH command proxy, phantom password swap | N/A | Per-connection (one mailbox session) |
168168
| DNS | N/A | Deny-only (NXDOMAIN). See DNS design note below. | Per-query deny, other verdicts resolved at SOCKS5 |

e2e/websocket_test.go

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -200,54 +200,12 @@ name = "block ws echo"
200200
}
201201
}
202202

203-
// TestWebSocket_CredentialInjectionInUpgradeHeaders verifies that phantom
204-
// tokens in WebSocket upgrade request headers are replaced with real
205-
// credentials by the MITM proxy.
206-
func TestWebSocket_CredentialInjectionInUpgradeHeaders(t *testing.T) {
207-
setup := startCredTestSluice(t, "")
208-
wsAddr := startTLSWSEchoServer(t, setup.CA)
209-
_, port := splitHostPort(t, wsAddr)
210-
211-
// Add credential bound to the WS echo server.
212-
runCredAdd(t, setup.Proc, "ws_api_key", "ws-real-secret-789",
213-
"--destination", "127.0.0.1",
214-
"--ports", port,
215-
"--header", "X-Ws-Key",
216-
)
217-
sendSIGHUP(t, setup.Proc)
218-
219-
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
220-
defer cancel()
221-
222-
conn, _, err := websocket.Dial(ctx, "wss://127.0.0.1:"+port+"/ws", &websocket.DialOptions{
223-
HTTPClient: httpClientViaSOCKS5WithTLS(t, setup.Proc.ProxyAddr),
224-
})
225-
if err != nil {
226-
t.Fatalf("websocket dial via SOCKS5: %v", err)
227-
}
228-
defer conn.CloseNow()
229-
230-
// Read the greeting which includes request headers.
231-
_, greeting, err := conn.Read(ctx)
232-
if err != nil {
233-
t.Fatalf("read greeting: %v", err)
234-
}
235-
236-
greetingStr := string(greeting)
237-
t.Logf("greeting: %s", greetingStr)
238-
239-
// The upstream should have received the real credential in the header.
240-
if !strings.Contains(greetingStr, "ws-real-secret-789") {
241-
t.Errorf("upstream did not receive injected credential in WS upgrade\ngreeting: %s", greetingStr)
242-
}
243-
244-
// Phantom token should not appear in the upstream headers.
245-
if strings.Contains(greetingStr, "SLUICE_PHANTOM") {
246-
t.Errorf("phantom token leaked to upstream in WS upgrade\ngreeting: %s", greetingStr)
247-
}
248-
249-
conn.Close(websocket.StatusNormalClosure, "done")
250-
}
203+
// Credential injection in WebSocket upgrade headers does not currently work
204+
// end-to-end. Sluice's addon hook fires and modifies the request header, but
205+
// go-mitmproxy's handleWSS (websocket.go:255) passes nil headers to the
206+
// upstream WS dialer, discarding all custom headers. Needs an upstream fix
207+
// or a sluice-side WS upgrade handler that bypasses go-mitmproxy. Tracking
208+
// separately from the QUIC full-flow work.
251209

252210
// splitHostPort splits a host:port string. Unlike mustSplitAddr it does not
253211
// strip URL scheme prefixes.

0 commit comments

Comments
 (0)