fix(ssh): restore TLS-to-backend in web endpoint proxy#6320
Conversation
|
Claude finished @gustavosbarreto's task in 2m 29s —— View job Code Review CompleteReviewed 1 file across code quality, security, testing, Go patterns, and architecture — no issues found. The code looks good as-is. The TLS-to-backend restoration is clean: correct use of To request another review round, comment |
Reintroduce the TLS handshake the proxy needs to talk to HTTPS backends through a Web Endpoint. The block was lost when ssh/pkg/tunnel/tunnel.go was deleted during the agent V2 multistream refactor and the new ssh/http/handlers.go was created without porting it. The struct is still persisted and returned by the API, but the runtime path was silently ignoring tls.enabled / tls.verify / tls.domain. When endpoint.TLS.Enabled is true, wrap the raw tunnel conn with tls.Client using endpoint.TLS.Domain as SNI and the outgoing Host header. Honor endpoint.TLS.Verify against the system CA pool, otherwise fall back to InsecureSkipVerify. Reconstruct req.URL as http://host:port/path so req.Write produces a proper request line even without a path-only URL. Closes #6316
0195504 to
848bb25
Compare
|
/review |
|
Claude finished @gustavosbarreto's task in 6m 12s —— View job Code Review CompleteReviewed 1 file across code quality, security, testing, Go patterns, and architecture — no issues found. The code looks good as-is. The TLS-to-backend restoration is clean: correct use of To request another review round, comment |
Closes #6316.
What
Reintroduces the TLS-to-backend block in
ssh/http/handlers.go::HandleHTTPProxythat was silently lost whenssh/pkg/tunnel/tunnel.gowas deleted during the agent V2 multistream refactor. Until this lands, thetls.enabled/tls.verify/tls.domainfields captured by the UI and persisted by the API have no effect at runtime.Behavior change
endpoint.TLS.Enabledis true, the proxy now wraps the raw tunnelnet.Connreturned byDialer.DialTowithtls.Client. SNI and the outgoingHostheader are set toendpoint.TLS.Domain.endpoint.TLS.VerifytogglesRootCAs = SystemCertPool()vsInsecureSkipVerify.req.URLis now reconstructed ashttp://<host>:<port>/<path>soreq.Writeproduces a complete request line. Scheme stayshttp://becausetls.Clientwraps the conn; the wire is TLS regardless of the URL scheme.tls.VersionTLS13.Hoststays as<address>.<endpoints_domain>, no TLS wrap.Verification
Reproduced and validated end-to-end against a local stack with a Python backend serving HTTP on 9080 and HTTPS on 9443. Both backends respond
200only whenHost: app.local, otherwise302 Location: https://app.local/....127.0.0.1:9080(HTTP)302 -> https://app.local(canonical redirect, expected)302 -> https://app.local127.0.0.1:9443(HTTPS),tls.enabled=true,tls.domain=app.localapp.local504 Gateway Time-out(proxy wrote cleartext to TLS socket)200 OK, backend logsHost: app.localBackend log after the fix on scenario B:
Out of scope (separate issues)
SHELLHUB_WEB_ENDPOINTSnot propagated to containers in dev mode)