security(controller): scope serviceoffer-controller Secret RBAC to named secrets#570
Merged
Merged
Conversation
4aa3746 to
f16a36f
Compare
f16a36f to
f395bd0
Compare
5 tasks
…med secrets The serviceoffer-controller ClusterRole granted secrets:[get,create,update,patch] cluster-wide with no resourceNames. The reconciler only needs three named Secrets: - litellm-secrets: get only for LITELLM_MASTER_KEY - hermes-api-server: get/create/delete for the agent API token - remote-signer-keystore: get/create/delete for the agent wallet keystore This keeps create as its own unscoped rule because Kubernetes cannot resourceName-scope create, while all reads and deletes are name-scoped. Delete is intentionally limited to the two per-agent Secret names; litellm-secrets remains read-only. The branch is stacked on the agent-backed readiness/teardown fix so Secret handling composes with ownership-checked teardown. Fresh remote-signer keystores keep the agent ownership labels needed by teardown, but the legacy in-place keystore migration is removed so the controller no longer needs update/patch on Secrets. Tests cover the RBAC split, create-only Secret handling, existing wallet reuse, and agent teardown behavior.
f395bd0 to
d5b7fd9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR hardens the
serviceoffer-controllerSecret RBAC after the agent-backed readiness/teardown fix in #572. It is intentionally stacked onfix/agent-backed-readinessbecause the RBAC change and the safe teardown guard share the same Secret ownership contract.The old ClusterRole granted
secrets: [get, create, update, patch]cluster-wide with noresourceNames. The reconciler only needs three named Secrets:litellm-secretsllmgetLITELLM_MASTER_KEYhermes-api-serverget/create/deleteremote-signer-keystoreget/create/deleteRBAC before -> after
- apiGroups: [""] resources: ["secrets"] - verbs: ["get", "create", "update", "patch"] # cluster-wide + resourceNames: ["litellm-secrets"] + verbs: ["get"] + + - apiGroups: [""] + resources: ["secrets"] + resourceNames: ["hermes-api-server", "remote-signer-keystore"] + verbs: ["get", "delete"] + + - apiGroups: [""] + resources: ["secrets"] + verbs: ["create"] # cannot be name-scopedcreatestays unscoped because Kubernetes cannot authorize it withresourceNamesbefore the object exists. All disclosure and destructive verbs are now scoped by name, andlitellm-secretsis not deletable.Companion changes
SecrettoisCreateOnlyKind, removing the need for Secretupdate/patch.remote-signer-keystoreSecrets labeled withapp.kubernetes.io/instanceandobol.org/agent, so Fix agent-backed service readiness reconciliation #572's ownership-checked teardown can safely delete only controller-owned resources.TestServiceOfferControllerSecretRBAC_Scopedso it catches broad Secret reads, Secret update/patch/list/watch, and accidental delete access onlitellm-secrets.Tradeoff
Existing pre-fix unlabeled keystore Secrets are reused but not relabeled in place, because relabeling would require keeping Secret
updateorpatch. Freshly-created keystores have the correct ownership labels.Validation
go test ./internal/serviceoffercontroller ./internal/embed -count=1go test ./internal/serviceoffercontroller ./internal/embed ./internal/x402 ./cmd/obol -count=1go test ./internal/serviceoffercontroller/... ./internal/embed/... -count=1kubectl --kubeconfig /private/tmp/obol-demo-kubeconfig apply --dry-run=server -f internal/embed/infrastructure/base/templates/x402.yamlRelease smoke was not run in this pass.