fix(pam): bind and advertise local session proxies on loopback#279
fix(pam): bind and advertise local session proxies on loopback#279Vligai wants to merge 2 commits into
Conversation
The local database, redis, and kubernetes session proxies created their TCP listener with an empty host, which Go resolves to all interfaces. Bind them to 127.0.0.1 and advertise 127.0.0.1 in the printed connection string so the client connects to exactly the address the proxy listens on, matching the rdp proxy which already does this. The printed connection string changes from localhost:<port> to 127.0.0.1:<port>.
|
💬 Discussion in Slack: #pr-review-cli-279-fix-pam-bind-and-advertise-local-session-proxies-on-loopback Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel. |
|
| Filename | Overview |
|---|---|
| packages/pam/local/database-proxy.go | Listener now bound to 127.0.0.1 for both random-port and fixed-port cases; all six advertised connection strings updated from localhost to 127.0.0.1. |
| packages/pam/local/redis-proxy.go | Same loopback-bind fix as database proxy; both username and anonymous redis:// connection strings updated to 127.0.0.1. |
| packages/pam/local/kubernetes-proxy.go | Listener bound to loopback and kubeconfig cluster Server URL updated to http://127.0.0.1:; behaviour matches the pre-existing RDP proxy pattern. |
| packages/pam/local/proxy_loopback_test.go | New white-box test verifying loopback binding for database, redis, and kubernetes proxies; RDP proxy (which was already correct) is not included in the test suite. |
Reviews (1): Last reviewed commit: "fix(pam): bind and advertise local sessi..." | Re-trigger Greptile
RDPProxyServer also binds 127.0.0.1; include it in the loopback regression test so all four local proxies are covered.
Context
The local PAM proxies for database, redis, and kubernetes sessions create their TCP listener with an
empty host (
":0"/":<port>"), which Go resolves to all interfaces (0.0.0.0/[::]). Theseproxies are consumed by the local client on the same machine, so they should only accept loopback
connections. This binds them to
127.0.0.1and advertises127.0.0.1in the printed connectionstring, so the client connects to exactly the address the proxy listens on. The rdp proxy already
binds and advertises
127.0.0.1; this brings the other three in line.Behavior: the proxy now accepts connections only from the local host. A client running on the same
machine connects via the printed
127.0.0.1URL, as it already does for rdp sessions. Reaching theproxy from another host, or from outside a container via a published port, no longer works (run the
client on the same machine). The printed connection string changes from
localhost:<port>to127.0.0.1:<port>.:0/:<port>(all interfaces); connection string usedlocalhost.127.0.0.1:0/127.0.0.1:<port>(loopback only); connection string uses127.0.0.1.Changed files:
packages/pam/local/database-proxy.gopackages/pam/local/redis-proxy.gopackages/pam/local/kubernetes-proxy.gopackages/pam/local/proxy_loopback_test.go(test)Screenshots
Steps to verify the change
go test ./packages/pam/local/ -run TestLocalProxiesBindLoopback.It drives each proxy's
Start()and asserts the listener binds a loopback address.127.0.0.1only (for examplelsof -iTCP -sTCP:LISTENornetstat), and that the local clientstill connects via the printed
127.0.0.1URL.Type
Checklist
type(scope): short description(scope is optional, e.g.,fix: prevent crash on syncorfix(api): handle null response).