Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

service account has excessive permissions #77

Open
eric-carlsson opened this issue Jan 31, 2025 · 0 comments
Open

service account has excessive permissions #77

eric-carlsson opened this issue Jan 31, 2025 · 0 comments

Comments

@eric-carlsson
Copy link
Contributor

eric-carlsson commented Jan 31, 2025

Hi,

By default, the Helm chart creates a cluster role binding on the service account using a cluster role with a very wide set of permissions.

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "app.serviceAccountName" . }}
labels:
{{- include "app.labels" . | nindent 4 }}
rules:
- apiGroups: ["*"]
resources: ["*"]
verbs: ["get", "list", "watch"]

Deploying the Helm chart with no extra values and running

kubectl auth can-i get secrets --as=system:serviceaccount:komoplane:komoplane -n kube-system

returns yes, i.e. the service account can read all secrets in the cluster, which seems a bit excessive.


Crossplane ships with a crossplane-view cluster role that aggregates get/list/watch permissions for all relevant Crossplane objects if it is deployed with the RBAC manager pod. The only missing set of permissions is to list CRDs (to get providers). This can easily be granted with a custom cluster role.

I made a clean install of Komoplane in a cluster with a variety of providers, XRDs, XRs, and claims, removed the cluster role binding the Helm chart creates by default, and applied this instead:

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: komoplane-crossplane-view
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: crossplane-view
subjects:
  - kind: ServiceAccount
    namespace: komoplane
    name: komoplane
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: komoplane-view-crds
rules:
  - apiGroups: ["apiextensions.k8s.io"]
    resources: ["customresourcedefinitions"]
    verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: komoplane-view-crds
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: komoplane-view-crds
subjects:
  - kind: ServiceAccount
    namespace: komoplane
    name: komoplane

The outcome is that Komoplane runs exactly as before, but now the service account doesn't have excessive permissions (the previous kubectl auth query returns no).

The only drawback I can think of is that it would assume you are deploying Crossplane with the RBAC manager pod. This pod is deployed by default, and I doubt many would disable it, but it is nevertheless a possibility.

If we are OK with this I would be happy to make a PR.

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

No branches or pull requests

1 participant