Repository navigation
Closed
Labels
scope/k8sKubernetes commands, Helm charts, pods, services, and policiessource/agentFiled by an agenttype/bugType bug: the code does not do what it must
Description
Problem
Lines cited at 05e9388 (release/v0.2.29).
- Token clusters get anonymous requests.
_auth_headers(k8s/service_proxy.py:223-234) turns eachconfiguration.api_keyentry into a header of the same name. Only a key literally namedauthorizationis mapped.- kubernetes 36.0.3 stores the token under
BearerToken(kubernetes/config/kube_config.py:530,kubernetes/config/incluster_config.py:91). - So the proxied request carries a
BearerToken: Bearer …header, and the API server treats it as anonymous. - Only client-certificate kubeconfigs work. In-cluster service accounts, OIDC, exec plugins and static tokens do not.
- The client's own
Configuration.auth_settings()(kubernetes/client/configuration.py:401-421) maps the key toAuthorization, and it is not used.
- The token is read once.
_kube_configurationcaches the configuration on the context and the kubeconfig's mtime (service_proxy.py:171). It loads in-cluster configuration first (:177-185).- The client's
refresh_api_key_hookis never called. - Inside a pod there is no kubeconfig, so the mtime key never changes.
- The informer gets untyped objects.
PodInformer.stream_eventspasses a lambda toWatch.stream(k8s/informer.py:109-116).Watchreads the return type from the list function's docstring, so for a namespaced watch it finds none and yields raw dicts.- The status projection then falls back to the phase (
:43), which the docstring at:33-34rules out. - The reconnect loop (
:156-168) has no backoff and does not resume from the lastresourceVersion.
- The docs overstate the check.
- AGENTS.md:468 lists the Kubernetes API among the connectors checked at the connect.
- The
k8s://proxy is checked (factory, private level). The in-processkubernetesclient is not: it dials through urllib3.
Proposed remedy
- Proxy auth. Build the proxy's headers per request from
configuration.auth_settings(), after callingconfiguration.refresh_api_key_hookwhen one is set. - Informer.
- Call
w.stream(core_v1.list_namespaced_pod, namespace=..., **kwargs), orlist_pod_for_all_namespaces, without a wrapper. - Reconnect with tenacity's exponential backoff (tenacity is already a dependency), resuming from the last seen
resourceVersion. - Relist on 410 Gone.
- Call
- AGENTS.md:468. Correct it to say the
k8s://proxy and the cluster-service clients are checked at the connect. The in-processkubernetesclient (urllib3) is not. It is trusted because its address comes from the operator's kubeconfig or the in-cluster environment.
Acceptance criteria
- With a token kubeconfig and with an in-cluster token, the request recorded at the HTTP fake carries
Authorization: Bearer <token>and noBearerTokenheader. - A client-certificate kubeconfig still works.
- A refresh hook that rotates the token is called before each request, and the new token is sent.
- Namespaced and all-namespace watches yield
V1Podobjects from refactor(k8s): KubernetesService is the Kubernetes API seam, with a shared fake cluster and its contract suite #1315's fake cluster. - A persistent watch error backs off instead of looping, and a reconnect passes the last
resourceVersion. - AGENTS.md:468 says which Kubernetes clients are checked at the connect and which are not.
- Tests run offline with fakes only at process and HTTP edges; each new test runs under 1 s.
-
uv run devops cipasses.
Related: #1315, #1314, #1322, #898.
Found by the 2026-10-08 client-library audit.
Opened as a borrow (#1153, budget/borrowed): the agent filing quota is spent for this cycle, and this is a defect or security finding of the owner-requested 2026-10-08 client-library audit.
Metadata
Metadata
Assignees
Labels
scope/k8sKubernetes commands, Helm charts, pods, services, and policiessource/agentFiled by an agenttype/bugType bug: the code does not do what it must
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty-bot commentedon Oct 8, 2026
Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.
The k8s:// proxy is non-functional for in-cluster service accounts, OIDC, exec plugins, and static tokens—i.e. the majority of real-world cluster configurations—making it a core-functionality break.Without the fix the proxy is unusable for any token-based cluster, which is the dominant authentication model in production Kubernetes.Requires rewriting header construction from auth_settings(), wiring the refresh hook, switching the informer to typed list calls, adding tenacity backoff with resourceVersion resume, and a one-line docs correction across a handful of files.