@@ -18,8 +18,8 @@ weight: 60
18
18
<!-- overview -->
19
19
20
20
<!--
21
- Kubernetes {{< glossary_tooltip text="RBAC" term_id="rbac" >}} is a key security control
22
- to ensure that cluster users and workloads have only the access to resources required to
21
+ Kubernetes {{< glossary_tooltip text="RBAC" term_id="rbac" >}} is a key security control
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
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.
@@ -48,28 +48,28 @@ Kubernetes {{< glossary_tooltip text="RBAC" term_id="rbac" >}}
48
48
### 最小特权 {#least-privilege}
49
49
50
50
<!--
51
- Ideally, minimal RBAC rights should be assigned to users and service accounts. Only permissions
52
- explicitly required for their operation should be used. While each cluster will be different,
51
+ Ideally, minimal RBAC rights should be assigned to users and service accounts. Only permissions
52
+ explicitly required for their operation should be used. While each cluster will be different,
53
53
some general rules that can be applied are :
54
54
-->
55
55
理想情况下,分配给用户和服务帐户的 RBAC 权限应该是最小的。
56
56
仅应使用操作明确需要的权限,虽然每个集群会有所不同,但可以应用的一些常规规则:
57
57
58
58
<!--
59
- - Assign permissions at the namespace level where possible. Use RoleBindings as opposed to
59
+ - Assign permissions at the namespace level where possible. Use RoleBindings as opposed to
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
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
- - Administrators should not use `cluster-admin` accounts except where specifically needed.
65
+ - Administrators should not use `cluster-admin` accounts except where specifically needed.
66
66
Providing a low privileged account with
67
67
[impersonation rights](/docs/reference/access-authn-authz/authentication/#user-impersonation)
68
68
can avoid accidental modification of cluster resources.
69
- - Avoid adding users to the `system:masters` group. Any user who is a member of this group
70
- bypasses all RBAC rights checks and will always have unrestricted superuser access, which cannot be
71
- revoked by removing RoleBindings or ClusterRoleBindings. As an aside, if a cluster is
72
- using an authorization webhook, membership of this group also bypasses that webhook (requests
69
+ - Avoid adding users to the `system:masters` group. Any user who is a member of this group
70
+ bypasses all RBAC rights checks and will always have unrestricted superuser access, which cannot be
71
+ revoked by removing RoleBindings or ClusterRoleBindings. As an aside, if a cluster is
72
+ using an authorization webhook, membership of this group also bypasses that webhook (requests
73
73
from users who are members of that group are never sent to the webhook)
74
74
-->
75
75
- 尽可能在命名空间级别分配权限。授予用户在特定命名空间中的权限时使用 RoleBinding
@@ -92,20 +92,20 @@ some general rules that can be applied are :
92
92
93
93
<!--
94
94
Ideally, pods shouldn't be assigned service accounts that have been granted powerful permissions
95
- (for example, any of the rights listed under [privilege escalation risks](#privilege-escalation-risks)).
95
+ (for example, any of the rights listed under [privilege escalation risks](#privilege-escalation-risks)).
96
96
In cases where a workload requires powerful permissions, consider the following practices:
97
97
98
- - Limit the number of nodes running powerful pods. Ensure that any DaemonSets you run
98
+ - Limit the number of nodes running powerful pods. Ensure that any DaemonSets you run
99
99
are necessary and are run with least privilege to limit the blast radius of container escapes.
100
- - Avoid running powerful pods alongside untrusted or publicly-exposed ones. Consider using
101
- [Taints and Toleration](/docs/concepts/scheduling-eviction/taint-and-toleration/),
102
- [NodeAffinity](/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity), or
103
- [PodAntiAffinity](/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity)
104
- to ensure pods don't run alongside untrusted or less-trusted Pods. Pay especial attention to
105
- situations where less-trustworthy Pods are not meeting the **Restricted** Pod Security Standard.
100
+ - Avoid running powerful pods alongside untrusted or publicly-exposed ones. Consider using
101
+ [Taints and Toleration](/docs/concepts/scheduling-eviction/taint-and-toleration/),
102
+ [NodeAffinity](/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity), or
103
+ [PodAntiAffinity](/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity)
104
+ to ensure pods don't run alongside untrusted or less-trusted Pods. Pay especial attention to
105
+ situations where less-trustworthy Pods are not meeting the **Restricted** Pod Security Standard.
106
106
-->
107
- 理想情况下,不应为 Pod 分配具有强大权限(例如,在[ 特权提级的风险] ( #privilege-escalation-risks ) 中列出的任一权限)的服务帐户。
108
- 如果工作负载需要比较大的权限,请考虑以下做法:
107
+ 理想情况下,不应为 Pod 分配具有强大权限(例如,在[ 特权提级的风险] ( #privilege-escalation-risks ) 中列出的任一权限)
108
+ 的服务帐户。 如果工作负载需要比较大的权限,请考虑以下做法:
109
109
110
110
- 限制运行此类 Pod 的节点数量。确保你运行的任何 DaemonSet 都是必需的,
111
111
并且以最小权限运行,以限制容器逃逸的影响范围。
@@ -119,9 +119,9 @@ In cases where a workload requires powerful permissions, consider the following
119
119
<!--
120
120
### Hardening
121
121
122
- Kubernetes defaults to providing access which may not be required in every cluster. Reviewing
122
+ Kubernetes defaults to providing access which may not be required in every cluster. Reviewing
123
123
the RBAC rights provided by default can provide opportunities for security hardening.
124
- In general, changes should not be made to rights provided to `system:` accounts some options
124
+ In general, changes should not be made to rights provided to `system:` accounts some options
125
125
to harden cluster rights exist:
126
126
-->
127
127
### 加固 {#hardening}
@@ -148,7 +148,7 @@ Kubernetes 默认提供访问权限并非是每个集群都需要的。
148
148
<!--
149
149
### Periodic review
150
150
151
- It is vital to periodically review the Kubernetes RBAC settings for redundant entries and
151
+ It is vital to periodically review the Kubernetes RBAC settings for redundant entries and
152
152
possible privilege escalations.
153
153
If an attacker is able to create a user account with the same name as a deleted user,
154
154
they can automatically inherit all the rights of the deleted user, especially the
@@ -166,7 +166,7 @@ rights assigned to that user.
166
166
Within Kubernetes RBAC there are a number of privileges which, if granted, can allow a user or a service account
167
167
to escalate their privileges in the cluster or affect systems outside the cluster.
168
168
169
- This section is intended to provide visibility of the areas where cluster operators
169
+ This section is intended to provide visibility of the areas where cluster operators
170
170
should take care, to ensure that they do not inadvertently allow for more access to clusters than intended.
171
171
-->
172
172
## Kubernetes RBAC - 权限提权的风险 {#privilege-escalation-risks}
@@ -222,8 +222,9 @@ or other (third party) mechanisms to implement that enforcement.
222
222
可以运行特权 Pod 的用户可以利用该访问权限获得节点访问权限,
223
223
并可能进一步提升他们的特权。如果你不完全信任某用户或其他主体,
224
224
不相信他们能够创建比较安全且相互隔离的 Pod,你应该强制实施 ** Baseline**
225
- 或 ** Restricted** Pod 安全标准。
226
- 你可以使用 [ Pod 安全性准入] ( /zh-cn/docs/concepts/security/pod-security-admission/ ) 或其他(第三方)机制来强制实施这些限制。
225
+ 或 ** Restricted** Pod 安全标准。你可以使用
226
+ [ Pod 安全性准入] ( /zh-cn/docs/concepts/security/pod-security-admission/ ) 或其他(第三方)
227
+ 机制来强制实施这些限制。
227
228
228
229
<!--
229
230
For these reasons, namespaces should be used to separate resources requiring different levels of
@@ -248,12 +249,13 @@ to the underlying host filesystem(s) on the associated node. Granting that abili
248
249
这意味着 Pod 将可以访问对应节点上的下层主机文件系统。授予该能力会带来安全风险。
249
250
250
251
<!--
251
- There are many ways a container with unrestricted access to the host filesystem can escalate privileges, including
252
+ There are many ways a container with unrestricted access to the host filesystem can escalate privileges, including
252
253
reading data from other containers, and abusing the credentials of system services, such as Kubelet.
253
254
254
255
You should only allow access to create PersistentVolume objects for:
255
256
-->
256
- 不受限制地访问主机文件系统的容器可以通过多种方式提升特权,包括从其他容器读取数据以及滥用系统服务(例如 Kubelet)的凭据。
257
+ 不受限制地访问主机文件系统的容器可以通过多种方式提升特权,包括从其他容器读取数据以及滥用系统服务
258
+ (例如 kubelet)的凭据。
257
259
258
260
你应该只允许以下实体具有创建 PersistentVolume 对象的访问权限:
259
261
@@ -268,7 +270,7 @@ You should only allow access to create PersistentVolume objects for:
268
270
这通常由 Kubernetes 提供商或操作员在安装 CSI 驱动程序时进行设置。
269
271
270
272
<!--
271
- Where access to persistent storage is required trusted administrators should create
273
+ Where access to persistent storage is required trusted administrators should create
272
274
PersistentVolumes, and constrained users should use PersistentVolumeClaims to access that storage.
273
275
-->
274
276
在需要访问持久存储的地方,受信任的管理员应创建 PersistentVolume,而受约束的用户应使用
@@ -277,21 +279,21 @@ PersistentVolumeClaim 来访问该存储。
277
279
<!--
278
280
### Access to `proxy` subresource of Nodes
279
281
280
- Users with access to the proxy sub-resource of node objects have rights to the Kubelet API,
281
- which allows for command execution on every pod on the node(s) to which they have rights.
282
- This access bypasses audit logging and admission control, so care should be taken before
282
+ Users with access to the proxy sub-resource of node objects have rights to the Kubelet API,
283
+ which allows for command execution on every pod on the node(s) to which they have rights.
284
+ This access bypasses audit logging and admission control, so care should be taken before
283
285
granting rights to this resource.
284
286
-->
285
287
### 访问 Node 的 ` proxy ` 子资源 {#access-to-proxy-subresource-of-nodes}
286
288
287
- 有权访问 Node 对象的 proxy 子资源的用户有权访问 Kubelet API,
289
+ 有权访问 Node 对象的 proxy 子资源的用户有权访问 kubelet API,
288
290
这允许在他们有权访问的节点上的所有 Pod 上执行命令。
289
291
此访问绕过审计日志记录和准入控制,因此在授予对此资源的权限前应小心。
290
292
291
293
<!--
292
294
### Escalate verb
293
295
294
- Generally, the RBAC system prevents users from creating clusterroles with more rights than the user possesses.
296
+ Generally, the RBAC system prevents users from creating clusterroles with more rights than the user possesses.
295
297
The exception to this is the `escalate` verb. As noted in the [RBAC documentation](/docs/reference/access-authn-authz/rbac/#restrictions-on-role-creation-or-update),
296
298
users with this right can effectively escalate their privileges.
297
299
-->
@@ -305,8 +307,8 @@ users with this right can effectively escalate their privileges.
305
307
<!--
306
308
### Bind verb
307
309
308
- Similar to the `escalate` verb, granting users this right allows for the bypass of Kubernetes
309
- in-built protections against privilege escalation, allowing users to create bindings to
310
+ Similar to the `escalate` verb, granting users this right allows for the bypass of Kubernetes
311
+ in-built protections against privilege escalation, allowing users to create bindings to
310
312
roles with rights they do not already have.
311
313
-->
312
314
### bind 动词 {#bind-verb}
@@ -317,8 +319,8 @@ roles with rights they do not already have.
317
319
<!--
318
320
### Impersonate verb
319
321
320
- This verb allows users to impersonate and gain the rights of other users in the cluster.
321
- Care should be taken when granting it, to ensure that excessive permissions cannot be gained
322
+ This verb allows users to impersonate and gain the rights of other users in the cluster.
323
+ Care should be taken when granting it, to ensure that excessive permissions cannot be gained
322
324
via one of the impersonated accounts.
323
325
-->
324
326
### impersonate 动词 {#impersonate-verb}
@@ -329,9 +331,9 @@ via one of the impersonated accounts.
329
331
<!--
330
332
### CSRs and certificate issuing
331
333
332
- The CSR API allows for users with `create` rights to CSRs and `update` rights on `certificatesigningrequests/approval`
333
- where the signer is `kubernetes.io/kube-apiserver-client` to create new client certificates
334
- which allow users to authenticate to the cluster. Those client certificates can have arbitrary
334
+ The CSR API allows for users with `create` rights to CSRs and `update` rights on `certificatesigningrequests/approval`
335
+ where the signer is `kubernetes.io/kube-apiserver-client` to create new client certificates
336
+ which allow users to authenticate to the cluster. Those client certificates can have arbitrary
335
337
names including duplicates of Kubernetes system components. This will effectively allow for privilege escalation.
336
338
-->
337
339
### CSR 和证书颁发 {#csrs-and-certificate-issuing}
@@ -346,8 +348,8 @@ CSR API 允许用户拥有 `create` CSR 的权限和 `update`
346
348
<!--
347
349
### Token request
348
350
349
- Users with `create` rights on `serviceaccounts/token` can create TokenRequests to issue
350
- tokens for existing service accounts.
351
+ Users with `create` rights on `serviceaccounts/token` can create TokenRequests to issue
352
+ tokens for existing service accounts.
351
353
-->
352
354
### 令牌请求 {#token-request}
353
355
@@ -357,8 +359,8 @@ TokenRequest 来发布现有服务帐户的令牌。
357
359
<!--
358
360
### Control admission webhooks
359
361
360
- Users with control over `validatingwebhookconfigurations` or `mutatingwebhookconfigurations`
361
- can control webhooks that can read any object admitted to the cluster, and in the case of
362
+ Users with control over `validatingwebhookconfigurations` or `mutatingwebhookconfigurations`
363
+ can control webhooks that can read any object admitted to the cluster, and in the case of
362
364
mutating webhooks, also mutate admitted objects.
363
365
-->
364
366
### 控制准入 Webhook {#control-admission-webhooks}
@@ -371,6 +373,7 @@ mutating webhooks, also mutate admitted objects.
371
373
## Kubernetes RBAC - denial of service risks {#denial-of-service-risks}
372
374
373
375
### Object creation denial-of-service {#object-creation-dos}
376
+
374
377
Users who have rights to create objects in a cluster may be able to create sufficient large
375
378
objects to create a denial of service condition either based on the size or number of objects, as discussed in
376
379
[etcd used by Kubernetes is vulnerable to OOM attack](https://github.com/kubernetes/kubernetes/issues/107325). This may be
@@ -397,4 +400,4 @@ to limit the quantity of objects which can be created.
397
400
* To learn more about RBAC, see the [RBAC documentation](/docs/reference/access-authn-authz/rbac/).
398
401
-->
399
402
400
- * 了解有关 RBAC 的更多信息,请参阅 [ RBAC 文档] ( /zh-cn/docs/reference/access-authn-authz/rbac/ ) 。
403
+ * 了解有关 RBAC 的更多信息,请参阅 [ RBAC 文档] ( /zh-cn/docs/reference/access-authn-authz/rbac/ ) 。
0 commit comments