Skip to content

Commit 96ff1e0

Browse files
committed
fix: Remove permissions that don't exist
We're using ArgoCD Service Account Impersonation to deploy. This relies on [Privilege escalation prevention](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#privilege-escalation-prevention-and-bootstrapping) Currently I'm getting errors like: ``` clusterroles.rbac.authorization.k8s.io "shield-cluster" is forbidden: user "system:serviceaccount:security-system:argocd-deployer" (groups=["system:serviceaccounts" "system:serviceaccounts:security-system" "system:authenticated"]) is attempting to grant RBAC permissions not currently held: {APIGroups:[""], Resources:["clusterrolebindings"], Verbs:["get" "list" "watch"]} {APIGroups:[""], Resources:["clusterroles"], Verbs:["get" "list" "watch"]} {APIGroups:[""], Resources:["clusterversions"], Verbs:["get" "list" "watch"]} {APIGroups:[""], Resources:["controllerrevisions"], Verbs:["get" "list" "watch"]} {APIGroups:[""], Resources:["cronjobs"], Verbs:["get" "list" "watch" "get" "list" "watch"]} {APIGroups:[""], Resources:["daemonsets"], Verbs:["get" "list" "watch" "get" "list" "watch"]} {APIGroups:[""], Resources:["deployments"], Verbs:["get" "list" "watch" "get" "list" "watch"]} {APIGroups:[""], Resources:["horizontalpodautoscalers"], Verbs:["get" "list" "watch"]} {APIGroups:[""], Resources:["ingressclasses"], Verbs:["get" "list" "watch"]} {APIGroups:[""], Resources:["ingresses"], Verbs:["get" "list" "watch"]} {APIGroups:[""], Resources:["jobs"], Verbs:["get" "list" "watch" "get" "list" "watch"]} {APIGroups:[""], Resources:["networkpolicies"], Verbs:["get" "list" "watch"]} {APIGroups:[""], Resources:["pods"], Verbs:["delete"]} {APIGroups:[""], Resources:["podsecuritypolicies"], Verbs:["get" "list" "watch"]} {APIGroups:[""], Resources:["replicasets"], Verbs:["get" "list" "watch" "get" "list" "watch"]} {APIGroups:[""], Resources:["rolebindings"], Verbs:["get" "list" "watch"]} {APIGroups:[""], Resources:["roles"], Verbs:["get" "list" "watch"]} {APIGroups:[""], Resources:["secrets"], Verbs:["get" "list" "watch" "get" "list" "watch" "get" "get" "list" "watch"]} {APIGroups:[""], Resources:["statefulsets"], Verbs:["get" "list" "watch" "get" "list" "watch"]} {APIGroups:[""], Resources:["storageclasses"], Verbs:["get" "list" "watch"]} {APIGroups:[""], Resources:["volumeattachments"], Verbs:["get" "list" "watch"]} ...many more ``` This appears to be because the ClusterRoles are misconfigured to reference lots of permissions that do not actually exist. This PR cleans those up by using the correct api groups to reference them. In addition it removes some "*" grants, as per least-privilege best practice.
1 parent 3a073f1 commit 96ff1e0

2 files changed

Lines changed: 141 additions & 44 deletions

File tree

charts/shield/templates/cluster/clusterrole.yaml

Lines changed: 112 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -38,72 +38,145 @@ rules:
3838
{{- if (include "cluster.container_vulnerability_management_enabled" .) }}
3939
- apiGroups:
4040
- ""
41-
- apps
42-
- batch
43-
- extensions
4441
resources:
45-
- cronjobs
46-
- daemonsets
47-
- deployments
48-
- jobs
4942
- namespaces
5043
- nodes
5144
- pods
52-
- replicasets
5345
- replicationcontrollers
5446
- secrets
55-
- statefulsets
5647
verbs:
5748
- get
5849
- list
5950
- watch
60-
{{- end }}
61-
{{- if (include "cluster.posture_enabled" .) }}
6251
- apiGroups:
63-
- ""
64-
- rbac.authorization.k8s.io
65-
- extensions
6652
- apps
67-
- batch
68-
- networking.k8s.io
69-
- autoscaling
70-
- policy
71-
- storage.k8s.io
72-
- config.openshift.io
7353
resources:
74-
- pods
75-
- pods/log
76-
- namespaces
77-
- deployments
7854
- daemonsets
55+
- deployments
56+
- replicasets
7957
- statefulsets
80-
- jobs
58+
verbs:
59+
- get
60+
- list
61+
- watch
62+
- apiGroups:
63+
- batch
64+
resources:
8165
- cronjobs
82-
- clusterroles
83-
- clusterrolebindings
84-
- roles
85-
- rolebindings
86-
- services
87-
- serviceaccounts
88-
- nodes
89-
- ingresses
90-
- ingressclasses
91-
- networkpolicies
92-
- replicasets
66+
- jobs
67+
verbs:
68+
- get
69+
- list
70+
- watch
71+
- apiGroups:
72+
- extensions
73+
resources:
74+
verbs:
75+
- get
76+
- list
77+
- watch
78+
{{- end }}
79+
{{- if (include "cluster.posture_enabled" .) }}
80+
- apiGroups:
81+
- ""
82+
resources:
9383
- configmaps
9484
- events
9585
- limitranges
96-
- persistentvolumes
86+
- namespaces
87+
- nodes
9788
- persistentvolumeclaims
89+
- persistentvolumes
90+
- pods
91+
- pods/log
9892
- replicationcontrollers
9993
- resourcequotas
94+
- secrets
95+
- serviceaccounts
96+
- services
97+
verbs:
98+
- get
99+
- list
100+
- watch
101+
- apiGroups:
102+
- apps
103+
resources:
100104
- controllerrevisions
105+
- daemonsets
106+
- deployments
107+
- replicasets
108+
- statefulsets
109+
verbs:
110+
- get
111+
- list
112+
- watch
113+
- apiGroups:
114+
- autoscaling
115+
resources:
101116
- horizontalpodautoscalers
117+
verbs:
118+
- get
119+
- list
120+
- watch
121+
- apiGroups:
122+
- batch
123+
resources:
124+
- cronjobs
125+
- jobs
126+
verbs:
127+
- get
128+
- list
129+
- watch
130+
- apiGroups:
131+
- config.openshift.io
132+
resources:
133+
- clusterversions
134+
verbs:
135+
- get
136+
- list
137+
- watch
138+
- apiGroups:
139+
- extensions
140+
resources:
141+
- ingresses
142+
verbs:
143+
- get
144+
- list
145+
- watch
146+
- apiGroups:
147+
- networking.k8s.io
148+
resources:
149+
- ingresses
150+
- ingressclasses
151+
- networkpolicies
152+
verbs:
153+
- get
154+
- list
155+
- watch
156+
- apiGroups:
157+
- policy
158+
resources:
102159
- podsecuritypolicies
160+
verbs:
161+
- get
162+
- list
163+
- watch
164+
- apiGroups:
165+
- rbac.authorization.k8s.io
166+
resources:
167+
- clusterroles
168+
- clusterrolebindings
169+
- roles
170+
- rolebindings
171+
verbs:
172+
- get
173+
- list
174+
- watch
175+
- apiGroups:
176+
- storage.k8s.io
177+
resources:
103178
- storageclasses
104179
- volumeattachments
105-
- clusterversions
106-
- secrets
107180
verbs:
108181
- get
109182
- list

charts/shield/templates/cluster/role.yaml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ rules:
1717
- "leases"
1818
resourceNames:
1919
- {{ include "cluster.posture_lease_name" . }}
20-
verbs: ["*"]
20+
verbs:
21+
- create
22+
- delete
23+
- deletecollection
24+
- get
25+
- list
26+
- patch
27+
- update
28+
- watch
2129
- apiGroups: ["", "coordination.k8s.io"]
2230
resources:
2331
- "leases"
@@ -29,22 +37,38 @@ rules:
2937
- "leases"
3038
resourceNames:
3139
- {{ include "cluster.container_vulnerability_management_lease_name" . }}
32-
verbs: ["*"]
40+
verbs:
41+
- create
42+
- delete
43+
- deletecollection
44+
- get
45+
- list
46+
- patch
47+
- update
48+
- watch
3349
- apiGroups: ["", "coordination.k8s.io"]
3450
resources:
3551
- "leases"
3652
verbs: ["create"]
37-
- apiGroups: ["*"]
53+
- apiGroups: [""]
3854
resources:
3955
- "endpoints"
4056
verbs: ["get", "watch", "list"]
41-
- apiGroups: ["*"]
57+
- apiGroups: [""]
4258
resources:
4359
- "endpoints"
4460
# Following is required for OpenShift. See https://docs.openshift.com/container-platform/3.11/architecture/core_concepts/pods_and_services.html#endpoints
4561
- "endpoints/restricted"
4662
resourceNames:
4763
- {{ include "cluster.container_vulnerability_management_service_name" . }}
48-
verbs: ["*"]
64+
verbs:
65+
- create
66+
- delete
67+
- deletecollection
68+
- get
69+
- list
70+
- patch
71+
- update
72+
- watch
4973
{{- end }}
5074
{{- end }}

0 commit comments

Comments
 (0)