Harden RBAC and reduce over-privileged access in ztvp-certificates#158
Open
p-rog wants to merge 1 commit into
Open
Harden RBAC and reduce over-privileged access in ztvp-certificates#158p-rog wants to merge 1 commit into
p-rog wants to merge 1 commit into
Conversation
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
The
ztvp-certificateschart grants its CA extraction ServiceAccount significantly broader permissions than it needs. This PR applies the principle of least privilege across four areas:Namespace-scoped secrets/configmaps access — the
ca-readerClusterRole previously granted cluster-widesecrets:[get,list]andconfigmaps:[get,list]. Replaced with namespace-scopedRole+RoleBindingpairs limited to the 4 namespaces the Job actually reads from:openshift-ingress-operator,openshift-ingress,openshift-config,openshift-config-managed.Read-only proxy access with declarative management — the SA previously had
proxies:[get,patch]to imperatively patchproxy/cluster.spec.trustedCA. Reduced toproxies:[get]withresourceNames:[cluster]. The trustedCA configuration is now managed declaratively via a new ArgoCD-synced template (proxy-trustedca.yaml) usingServerSideApply, leveraging ArgoCD's cluster-admin privileges instead of granting patch access to the Job SA.Namespace-scoped rollout restart — the rollout
ClusterRoleBinding(allowing workload restarts in any namespace) is replaced with per-namespaceRoleBinding(s) driven by a new.Values.rollout.namespaceslist. The extraction script was also aligned to iteraterollout.namespacesinstead ofdistribution.targetNamespaces, ensuring RBAC permissions and script behavior stay in sync.Redact sensitive credentials from ACS Job logs — the
create-auth-providerJob previously logged the full OIDC configuration JSON including the plaintextclient_secret. Replaced withjq-based redaction that masks the secret value before printing. Falls back gracefully ifjqis unavailable.Changes
charts/ztvp-certificates/templates/rbac.yamlcharts/ztvp-certificates/templates/proxy-trustedca.yamlProxyresource managed by ArgoCD (sync-wave 24, ServerSideApply)charts/ztvp-certificates/files/extract-certificates.sh.tploc patch proxy/clustercalls; align rollout iteration torollout.namespacescharts/ztvp-certificates/values.yamlrollout.namespaceslist (default:[qtodo])overrides/values-ztvp-certificates.yamlrollout.namespaces: [qtodo]charts/acs-central/templates/jobs/create-auth-provider.yamlclient_secretfrom OIDC debug outputTest plan
Verified on an OCP 4.21 cluster with a full ZTVP pattern deployment:
getallowed,patchdenied);proxy/cluster.spec.trustedCA.namecorrectly set toztvp-proxy-caby ArgoCD"OIDC Configuration JSON (client_secret redacted):"with no plaintext secretMade with Cursor