Repository navigation
Read-only mode: refuse proxy requests to pods, services and nodes - #7
Conversation
A GET through .../pods/<name>/proxy/..., .../services/<name>/proxy/... or .../nodes/<name>/proxy/... is passed on to whatever listens behind it, and behind a node proxy is the kubelet, whose own API includes exec. The read-only transport let those through: it only knew the stream subresources, which always end the path. proxy is followed by the path it forwards, so the guard now looks for it anywhere in the path, anchored on "namespaces" for pods and services and on "v1" for nodes, which keeps objects that are merely named "proxy" readable. k10s never sends these requests itself. Suggested in the review of p10node#5.
|
Reviewed, approving. Verified locally on Go 1.27.1: I also ran the new test rows and The anchoring is right. Pod and service proxy need Merging. That closes follow-up 2 from #5. |
Follow-up 2 from the review of #5.
A GET through
.../pods/<name>/proxy/...,.../services/<name>/proxy/...or.../nodes/<name>/proxy/...is passed on to whatever listens behind it. Behind a node proxy is the kubelet, whose own API includes exec, so nothing sent through a proxy is known to only read. The guard only knew exec, attach and portforward, which always end the path; proxy is followed by the path it forwards, so it never matched.streamSubresourcenow also looks forproxyanywhere in the path, anchored onnamespacesfor pods and services and onv1for nodes. Objects that are merely named "proxy" stay readable, and so does an API server served under a path prefix. The refusal names what it refused ("pod exec", "node proxy"). k10s itself never sends these requests, so nothing visible changes.Tests: new rows in
TestCheckReadOnlyAllowsOnlyReads, andTestReadOnlyClientProxiesNothingdrives client-go's own proxy helpers (pod and serviceProxyGet, a node proxy GET) against the recording server and checks that none of them reaches it.Checked with
gofmt,go vet ./...andgo test ./...on Go 1.26.8.