@@ -21,7 +21,7 @@ weight: 60
21
21
Kubernetes {{< glossary_tooltip text="RBAC" term_id="rbac" >}} is a key security control
22
22
to ensure that cluster users and workloads have only the access to resources required to
23
23
execute their roles. It is important to ensure that, when designing permissions for cluster
24
- users, the cluster administrator understands the areas where privilge escalation could occur,
24
+ users, the cluster administrator understands the areas where privilge escalation could occur,
25
25
to reduce the risk of excessive access leading to security incidents.
26
26
27
27
The good practices laid out here should be read in conjunction with the general
@@ -60,7 +60,7 @@ some general rules that can be applied are :
60
60
ClusterRoleBindings to give users rights only within a specific namespace.
61
61
- Avoid providing wildcard permissions when possible, especially to all resources.
62
62
As Kubernetes is an extensible system, providing wildcard access gives rights
63
- not just to all object types that currently exist in the cluster, but also to all future object types
63
+ not just to all object types that currently exist in the cluster, but also to all object types
64
64
which are created in the future.
65
65
- Administrators should not use `cluster-admin` accounts except where specifically needed.
66
66
Providing a low privileged account with
@@ -82,9 +82,9 @@ some general rules that can be applied are :
82
82
可以避免意外修改集群资源。
83
83
- 避免将用户添加到 ` system:masters ` 组。任何属于此组成员的用户都会绕过所有 RBAC 权限检查,
84
84
始终具有不受限制的超级用户访问权限,并且不能通过删除 ` RoleBinding ` 或 ` ClusterRoleBinding `
85
- 来取消其权限。顺便说一句,如果集群是使用 Webhook 鉴权,此组的成员身份也会绕过该
85
+ 来取消其权限。顺便说一句,如果集群使用 Webhook 鉴权,此组的成员身份也会绕过该
86
86
Webhook(来自属于该组成员的用户的请求永远不会发送到 Webhook)。
87
-
87
+
88
88
<!--
89
89
### Minimize distribution of privileged tokens
90
90
-->
@@ -106,12 +106,13 @@ In cases where a workload requires powerful permissions, consider the following
106
106
-->
107
107
理想情况下,不应为 Pod 分配具有强大权限(例如,在[ 特权提级的风险] ( #privilege-escalation-risks ) 中列出的任一权限)的服务帐户。
108
108
如果工作负载需要比较大的权限,请考虑以下做法:
109
+
109
110
- 限制运行此类 Pod 的节点数量。确保你运行的任何 DaemonSet 都是必需的,
110
111
并且以最小权限运行,以限制容器逃逸的影响范围。
111
112
- 避免将此类 Pod 与不可信任或公开的 Pod 在一起运行。
112
113
考虑使用[ 污点和容忍度] ( /zh-cn/docs/concepts/scheduling-eviction/taint-and-toleration/ ) 、
113
114
[ 节点亲和性] ( /zh-cn/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity ) 或
114
- [ Pod 反亲和性] ( /zh-cn/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity ) 确保
115
+ [ Pod 反亲和性] ( /zh-cn/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity ) 确保
115
116
Pod 不会与不可信或不太受信任的 Pod 一起运行。
116
117
特别注意可信度不高的 Pod 不符合 ** Restricted** Pod 安全标准的情况。
117
118
@@ -152,8 +153,9 @@ possible privilege escalations.
152
153
If an attacker is able to create a user account with the same name as a deleted user,
153
154
they can automatically inherit all the rights of the deleted user, especially the
154
155
rights assigned to that user.
155
- -->
156
+ -->
156
157
### 定期检查 {#periodic-review}
158
+
157
159
定期检查 Kubernetes RBAC 设置是否有冗余条目和提权可能性是至关重要的。
158
160
如果攻击者能够创建与已删除用户同名的用户账号,
159
161
他们可以自动继承被删除用户的所有权限,尤其是分配给该用户的权限。
@@ -187,22 +189,27 @@ includes the contents of all Secrets.
187
189
188
190
大家都很清楚,若允许对 Secrets 执行 ` get ` 访问,用户就获得了访问 Secret 内容的能力。
189
191
同样需要注意的是:` list ` 和 ` watch ` 访问也会授权用户获取 Secret 的内容。
190
- 例如,当返回 List 响应时(例如,通过
192
+ 例如,当返回 List 响应时(例如,通过
191
193
` kubectl get secrets -A -o yaml ` ),响应包含所有 Secret 的内容。
192
194
193
195
<!--
194
196
### Workload creation
195
197
196
- Users who are able to create workloads (either Pods, or
197
- [workload resources](/docs/concepts/workloads/controllers/) that manage Pods) will
198
- be able to gain access to the underlying node unless restrictions based on the Kubernetes
199
- [Pod Security Standards](/docs/concepts/security/pod-security-standards/) are in place.
198
+ Permission to create workloads (either Pods, or
199
+ [workload resources](/docs/concepts/workloads/controllers/) that manage Pods) in a namespace
200
+ implicitly grants access to many other resources in that namespace, such as Secrets, ConfigMaps, and
201
+ PersistentVolumes that can be mounted in Pods. Additionally, since Pods can run as any
202
+ [ServiceAccount](/docs/reference/access-authn-authz/service-accounts-admin/), granting permission
203
+ to create workloads also implicitly grants the API access levels of any service account in that
204
+ namespace.
200
205
-->
201
206
### 工作负载的创建 {#workload-creation}
202
207
203
- 能够创建工作负载的用户(Pod 或管理 Pod 的[ 工作负载资源] ( /zh-cn/docs/concepts/workloads/controllers/ ) )
204
- 能够访问下层的节点,除非基于 Kubernetes 的
205
- [ Pod 安全标准] ( /zh-cn/docs/concepts/security/pod-security-standards/ ) 做限制。
208
+ 在一个命名空间中创建工作负载(Pod 或管理 Pod 的[ 工作负载资源] ( /zh-cn/docs/concepts/workloads/controllers/ ) )
209
+ 的权限隐式地授予了对该命名空间中许多其他资源的访问权限,例如可以挂载在
210
+ Pod 中的 Secret、ConfigMap 和 PersistentVolume。
211
+ 此外,由于 Pod 可以被任何[ 服务账号] ( /zh-cn/docs/reference/access-authn-authz/service-accounts-admin/ ) 运行,
212
+ 因此授予创建工作负载的权限也会隐式地授予该命名空间中任何服务账号的 API 访问级别。
206
213
207
214
<!--
208
215
Users who can run privileged Pods can use that access to gain node access and potentially to
@@ -218,22 +225,15 @@ or other (third party) mechanisms to implement that enforcement.
218
225
或 ** Restricted** Pod 安全标准。
219
226
你可以使用 [ Pod 安全性准入] ( /zh-cn/docs/concepts/security/pod-security-admission/ ) 或其他(第三方)机制来强制实施这些限制。
220
227
221
- <!--
222
- You can also use the deprecated [PodSecurityPolicy](/docs/concepts/security/pod-security-policy/) mechanism
223
- to restrict users' abilities to create privileged Pods (N.B. PodSecurityPolicy is scheduled for removal
224
- in version 1.25).
225
- -->
226
- 你还可以使用已弃用的 [ PodSecurityPolicy] ( /zh-cn/docs/concepts/security/pod-security-policy/ )
227
- 机制以限制用户创建特权 Pod 的能力 (特别注意:PodSecurityPolicy 已计划在版本 1.25 中删除)。
228
-
229
- <!--
230
- Creating a workload in a namespace also grants indirect access to Secrets in that namespace.
231
- Creating a pod in kube-system or a similarly privileged namespace can grant a user access to
232
- Secrets they would not have through RBAC directly.
228
+ <!--
229
+ For these reasons, namespaces should be used to separate resources requiring different levels of
230
+ trust or tenancy. It is still considered best practice to follow [least privilege](#least-privilege)
231
+ principles and assign the minimum set of permissions, but boundaries within a namespace should be
232
+ considered weak.
233
233
-->
234
- 在命名空间中创建工作负载还会授予对该命名空间中 Secret 的间接访问权限 。
235
- 在 kube-system 或类似特权的命名空间中创建 Pod
236
- 可以授予用户不需要通过 RBAC 即可获取 Secret 访问权限 。
234
+ 出于这些原因,命名空间应该用于隔离不同的信任级别或不同租户所需的资源 。
235
+ 遵循 [ 最小特权 ] ( #least-privilege ) 原则并分配最小权限集仍被认为是最佳实践,
236
+ 但命名空间内的边界概念应视为比较弱 。
237
237
238
238
<!--
239
239
### Persistent volume creation
@@ -245,7 +245,7 @@ PersistentVolumes, and constrained users should use PersistentVolumeClaims to ac
245
245
-->
246
246
### 持久卷的创建 {#persistent-volume-creation}
247
247
248
- 如 [ PodSecurityPolicy] ( /zh-cn/docs/concepts/security/pod-security-policy/#volumes-and-file-systems )
248
+ 如 [ PodSecurityPolicy] ( /zh-cn/docs/concepts/security/pod-security-policy/#volumes-and-file-systems )
249
249
文档中所述,创建 PersistentVolumes 的权限可以提权访问底层主机。
250
250
如果需要访问 PersistentVolume,受信任的管理员应该创建 ` PersistentVolume ` ,
251
251
受约束的用户应该使用 ` PersistentVolumeClaim ` 访问该存储。
@@ -272,6 +272,7 @@ The exception to this is the `escalate` verb. As noted in the [RBAC documentatio
272
272
users with this right can effectively escalate their privileges.
273
273
-->
274
274
### esclate 动词 {#escalate-verb}
275
+
275
276
通常,RBAC 系统会阻止用户创建比他所拥有的更多权限的 ` ClusterRole ` 。
276
277
而 ` escalate ` 动词是个例外。如
277
278
[ RBAC 文档] ( /zh-cn/docs/reference/access-authn-authz/rbac/#restrictions-on-role-creation-or-update )
@@ -326,7 +327,7 @@ tokens for existing service accounts.
326
327
-->
327
328
### 令牌请求 {#token-request}
328
329
329
- 拥有 ` serviceaccounts/token ` 的 ` create ` 权限的用户可以创建
330
+ 拥有 ` serviceaccounts/token ` 的 ` create ` 权限的用户可以创建
330
331
TokenRequest 来发布现有服务帐户的令牌。
331
332
332
333
<!--
@@ -336,7 +337,7 @@ Users with control over `validatingwebhookconfigurations` or `mutatingwebhookcon
336
337
can control webhooks that can read any object admitted to the cluster, and in the case of
337
338
mutating webhooks, also mutate admitted objects.
338
339
-->
339
- ### 控制准入 Webhook {#control-admission-webhooks}
340
+ ### 控制准入 Webhook {#control-admission-webhooks}
340
341
341
342
可以控制 ` validatingwebhookconfigurations ` 或 ` mutatingwebhookconfigurations `
342
343
的用户可以控制能读取任何允许进入集群的对象的 webhook,
@@ -359,6 +360,7 @@ to limit the quantity of objects which can be created.
359
360
## Kubernetes RBAC - 拒绝服务攻击的风险 {#denial-of-service-risks}
360
361
361
362
### 对象创建拒绝服务 {#object-creation-dos}
363
+
362
364
有权在集群中创建对象的用户根据创建对象的大小和数量可能会创建足够大的对象,
363
365
产生拒绝服务状况,如 [ Kubernetes 使用的 etcd 容易受到 OOM 攻击] ( https://github.com/kubernetes/kubernetes/issues/107325 ) 中的讨论。
364
366
允许太不受信任或者不受信任的用户对系统进行有限的访问在多租户集群中是特别重要的。
@@ -370,4 +372,5 @@ to limit the quantity of objects which can be created.
370
372
<!--
371
373
* To learn more about RBAC, see the [RBAC documentation](/docs/reference/access-authn-authz/rbac/).
372
374
-->
373
- * 了解有关 RBAC 的更多信息,请参阅 [ RBAC 文档] ( /zh-cn/docs/reference/access-authn-authz/rbac/ ) 。
375
+
376
+ * 了解有关 RBAC 的更多信息,请参阅 [ RBAC 文档] ( /zh-cn/docs/reference/access-authn-authz/rbac/ ) 。
0 commit comments