Skip to content

fix(substrate): the credential providers read Secrets only where an actor's grant points - #1286

Merged
fiunchinho merged 4 commits into
mainfrom
secret-readers-where-bound
Nov 5, 2026
Merged

fiunchinho merged 4 commits into
mainfrom
secret-readers-where-bound

Conversation

@fiunchinho

Copy link
Copy Markdown
Member

Problem

On a management cluster every workload cluster's admin kubeconfig is a Secret. Substrate's credential provider and the Google access-token plugin each hold a Secret reader ClusterRole bound cluster-wide, so either could read every one of them. The management-cluster profile of the organizations plan calls this the blocker before any management-cluster rollout (#1269).

The narrowing itself already exists upstream of this chart:

This pull request wires them.

Change

  • Meta chart. From Substrate 1.18.0 and the plugin 0.3.0, the chart forwards to both releases the namespaces their readers are bound in: every allowedNamespaces entry of the derived namespacePolicies (kagent by default). With agentPlatformOrganizations.enabled, it forwards to the operator serviceAccountBindings for both readers, and the operator binds them in every organization namespace. The narrowing is held back in three cases, so that no namespace a grant names is left unbound:
    • a policy that selects namespaces by another label;
    • organizations on with an operator floor before 0.1.0-rc.13;
    • an own rbac.namespaces, which stays as set.
  • Operator pin 0.1.0-rc.13 (from 0.1.0-rc.5).
  • Connectivity chart, admission. The operator may bind each provider's ServiceAccount (ate-system/k8s-credential-provider, ate-system/google-access-token-credential-provider) in an organization namespace. It binds the ServiceAccount alone, to that provider's own reader only, by a RoleBinding named after the reader. It binds a reader to that provider only. Nobody else, a cluster-admin included, binds a provider's ServiceAccount there (agent-platform-organization-rolebinding-subjects, agent-platform-organization-operator-objects).
  • The install hooks' narrowing is security(hooks): the connectivity hooks read only the Secrets they write #1275 (merged; make verify-hooks-secrets).

The Substrate and plugin pins do not move here:

  • components.substrate.versionRange is >=1.17.5 <1.18.0. 1.18.0 has release candidates only, and the meta chart takes a stable range or an exact pin. The 1.18.0-rc.4 to rc.8 tags published images but no chart: their scan job failed, so charts never ran.
  • The plugin stays on >=0.2.0 <0.3.0 until 0.3.0 is stable.

The derivation takes effect when those ranges move, with nothing else to change. The operator pin moves now. With the Substrate range still on 1.17, the operator's bindings are additional to the cluster-wide ones.

Placement: upstream already has it (the charts' rbac.namespaces, Kubernetes RoleBindings to a ClusterRole). Platform for the operator wiring and the admission pins.

Tests

  • make verify-secret-readers (new) does two things:
    • Render checks: on and off, an old Substrate or plugin, an old operator, a grant on another label, own grants and own rbac.namespaces.
    • SubjectAccessReviews on a local API server (tests/apiserver.py). The RBAC is the Substrate chart 1.18.0-rc.8 (from the tag's tree while its chart is unpublished) and the plugin chart 0.3.0-rc.1, rendered with the forwarded values, beside the operator's bindings. ate-controller reads only ate-system/egress-mitm-ca-pool. Each provider gets a Secret in kagent and in an organization namespace. Each is refused one in ate-system, kube-system and a workload cluster's namespace (org-acme/acme-kubeconfig), and any list.
    • Against main's meta chart, 9 checks fail: the render checks, and the provider refusals. The controller checks show the same against the 1.17.5 control.
  • make verify-organization-admission gains the operator's reader bindings: admitted in an organization namespace, refused elsewhere, refused with another role, another name or another subject, and refused for a cluster-admin.
  • make verify-all (114 targets) on the merge with main and pre-commit run --all-files: all pass.

For agentlab's management-cluster profile tests (slice 8, agentlab#1149)

Run these SubjectAccessReviews on the lab's management cluster with the organizations on, Substrate 1.18.0 or later and the plugin 0.3.0 or later. Each one is kubectl auth can-i <verb> <resource> -n <ns> --as=system:serviceaccount:ate-system:<sa> --as-group=system:serviceaccounts --as-group=system:serviceaccounts:ate-system --as-group=system:authenticated.

ServiceAccount (ate-system/…) verb, resource namespace expected
ate-controller get, list, watch secrets/egress-mitm-ca-pool ate-system yes
ate-controller get secrets/<any other> ate-system no
ate-controller get secrets/<cluster>-kubeconfig the workload cluster's namespace (org-*) no
ate-controller list secrets all namespaces no
k8s-credential-provider get secrets/<any> kagent yes
k8s-credential-provider get secrets/<any> an organization namespace (agents-*) yes
k8s-credential-provider get secrets/<cluster>-kubeconfig the workload cluster's namespace no
k8s-credential-provider get secrets/<any> ate-system, kube-system, giantswarm, flux-giantswarm no
k8s-credential-provider list secrets an organization namespace, all namespaces no
google-access-token-credential-provider the same six rows as k8s-credential-provider the same

There is also the negative control for the binding itself: kubectl get rolebinding k8s-credential-provider-secret-reader google-access-token-credential-provider-secret-reader -n <organization namespace> exists, and kubectl get clusterrolebinding k8s-credential-provider-secret-reader google-access-token-credential-provider-secret-reader does not.

Review

An independent review (review-pr --deep) found no blocking finding.

id severity outcome one line
F1 non-blocking fixed (12a63bbd) An own grant of an agents-* namespace is left to the operator. UPGRADE.md says that a granted namespace must exist before the ranges move.
F2 non-blocking fixed (12a63bbd) With Substrate or the plugin outside ate-system, the operator gets no binding and the readers stay cluster-wide. Before this fix, the admission policy refused those bindings.
F3 non-blocking fixed (12a63bbd) A control: the same reviews against Substrate 1.17.5 (cluster-wide), which must be answered yes.
F4 non-blocking fixed (12a63bbd, merge) The operator entry of the Unreleased CHANGELOG names the 0.1.0-rc.13 pin.
F5 suggestion fixed (12a63bbd) A grant by another label, and an organization selector with one more requirement, with the organizations on.
F6 suggestion rejected The two admission rules check the pair from each side, and each has its own message. A shared variable makes them shorter but no clearer.

Towards #1269
Towards giantswarm/giantswarm#38891

…ctor's grant points

From Substrate 1.18.0 and the Google access-token plugin 0.3.0 the meta chart binds their Secret readers in the namespaces the derived namespacePolicies name, and with the organizations on agent-platform-operator 0.1.0-rc.13 binds both in every organization namespace. The organizations' admission policies admit the operator's binding of each provider's ServiceAccount to its own reader only. make verify-secret-readers proves the refusals with SubjectAccessReviews on a local API server.

Towards #1269
… from the readers' releases

An own grant of an agents-* namespace is the operator's to bind, Substrate or the plugin outside ate-system get no operator binding and stay cluster-wide, and verify-secret-readers proves its reviews against a cluster-wide Substrate 1.17.5 first.
@fiunchinho fiunchinho self-assigned this Nov 5, 2026
@fiunchinho
fiunchinho marked this pull request as ready for review November 5, 2026 16:18
@fiunchinho
fiunchinho requested a review from a team as a code owner November 5, 2026 16:18
@circleci-architect

Copy link
Copy Markdown

Published Helm chart agent-platform-connectivity

4.174.4-r1c95e814t20261105161812h8633bf5
Chart agent-platform-connectivity
Version 4.174.4-r1c95e814t20261105161812h8633bf5
OCI reference oci://gsoci.azurecr.io/charts/giantswarm/agent-platform-connectivity:4.174.4-r1c95e814t20261105161812h8633bf5
Digest sha256:1d092dae071465b3c0ceb7685c53f2f2a4c9bc51540211e976fa85360dd94b92
Registry public — gsoci.azurecr.io
Git catalog giantswarm-test-catalog (index)
Pull this chart
helm pull oci://gsoci.azurecr.io/charts/giantswarm/agent-platform-connectivity --version 4.174.4-r1c95e814t20261105161812h8633bf5

Posted by architect-orb · build 30095 · commit 8633bf5 · updated in place on every push

@circleci-architect

Copy link
Copy Markdown

Published Helm chart agent-platform

4.174.4-r1c95e814t20261105161812h8633bf5
Chart agent-platform
Version 4.174.4-r1c95e814t20261105161812h8633bf5
OCI reference oci://gsoci.azurecr.io/charts/giantswarm/agent-platform:4.174.4-r1c95e814t20261105161812h8633bf5
Digest sha256:73359af96e478d9c15a7287102f415847abc0844d482bc437a9ca73ec02be0a7
Registry public — gsoci.azurecr.io
Git catalog giantswarm-test-catalog (index)
Pull this chart
helm pull oci://gsoci.azurecr.io/charts/giantswarm/agent-platform --version 4.174.4-r1c95e814t20261105161812h8633bf5

Posted by architect-orb · build 30096 · commit 8633bf5 · updated in place on every push

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant