@@ -15,13 +15,13 @@ weight: 90
15
15
-->
16
16
17
17
<!-- overview -->
18
- <!--
19
- The Kubernetes API server is the main point of entry to a cluster for external parties
20
- (users and services) interacting with it.
18
+ <!--
19
+ The Kubernetes API server is the main point of entry to a cluster for external parties
20
+ (users and services) interacting with it.
21
21
-->
22
22
Kubernetes API 服务器是外部(用户和服务)与集群交互的主要入口。
23
23
24
- <!--
24
+ <!--
25
25
As part of this role, the API server has several key built-in security controls, such as
26
26
audit logging and {{< glossary_tooltip text="admission controllers" term_id="admission-controller" >}}. However, there are ways to modify the configuration
27
27
or content of the cluster that bypass these controls.
@@ -30,7 +30,7 @@ or content of the cluster that bypass these controls.
30
30
例如审计日志和{{< glossary_tooltip text="准入控制器" term_id="admission-controller" >}}。
31
31
但是,有一些方法可以绕过这些安全控制从而修改集群的配置或内容。
32
32
33
- <!--
33
+ <!--
34
34
This page describes the ways in which the security controls built into the
35
35
Kubernetes API server can be bypassed, so that cluster operators
36
36
and security architects can ensure that these bypasses are appropriately restricted.
@@ -39,12 +39,12 @@ and security architects can ensure that these bypasses are appropriately restric
39
39
以便集群运维人员和安全架构师可以确保这些绕过方式被适当地限制。
40
40
41
41
<!-- body -->
42
- <!--
42
+ <!--
43
43
## Static Pods {#static-pods}
44
44
-->
45
45
## 静态 Pod {#static-pods}
46
46
47
- <!--
47
+ <!--
48
48
The {{< glossary_tooltip text="kubelet" term_id="kubelet" >}} on each node loads and
49
49
directly manages any manifests that are stored in a named directory or fetched from
50
50
a specific URL as [*static Pods*](/docs/tasks/configure-pod-container/static-pod) in
@@ -57,7 +57,7 @@ source, or could introduce new static Pods.
57
57
获取的[ ** 静态 Pod** ] ( /zh-cn/docs/tasks/configure-pod-container/static-pod ) 清单。
58
58
API 服务器不管理这些静态 Pod。对该位置具有写入权限的攻击者可以修改从该位置加载的静态 Pod 的配置,或引入新的静态 Pod。
59
59
60
- <!--
60
+ <!--
61
61
Static Pods are restricted from accessing other objects in the Kubernetes API. For example,
62
62
you can't configure a static Pod to mount a Secret from the cluster. However, these Pods can
63
63
take other security sensitive actions, such as using `hostPath` mounts from the underlying
66
66
静态 Pod 被限制访问 Kubernetes API 中的其他对象。例如,你不能将静态 Pod 配置为从集群挂载 Secret。
67
67
但是,这些 Pod 可以执行其他安全敏感的操作,例如挂载来自下层节点的 ` hostPath ` 卷。
68
68
69
- <!--
69
+ <!--
70
70
By default, the kubelet creates a {{< glossary_tooltip text="mirror pod" term_id="mirror-pod">}}
71
71
so that the static Pods are visible in the Kubernetes API. However, if the attacker uses an invalid
72
72
namespace name when creating the Pod, it will not be visible in the Kubernetes API and can only
@@ -76,20 +76,20 @@ be discovered by tooling that has access to the affected host(s).
76
76
以便静态 Pod 在 Kubernetes API 中可见。但是,如果攻击者在创建 Pod 时使用了无效的名字空间名称,
77
77
则该 Pod 将在 Kubernetes API 中不可见,只能通过对受影响主机有访问权限的工具发现。
78
78
79
- <!--
79
+ <!--
80
80
If a static Pod fails admission control, the kubelet won't register the Pod with the
81
81
API server. However, the Pod still runs on the node. For more information, refer to
82
82
[kubeadm issue #1541](https://github.com/kubernetes/kubeadm/issues/1541#issuecomment-487331701).
83
83
-->
84
84
如果静态 Pod 无法通过准入控制,kubelet 不会将 Pod 注册到 API 服务器。但该 Pod 仍然在节点上运行。
85
85
有关更多信息,请参阅 [ kubeadm issue #1541 ] ( https://github.com/kubernetes/kubeadm/issues/1541#issuecomment-487331701 ) 。
86
86
87
- <!--
87
+ <!--
88
88
### Mitigations {#static-pods-mitigations}
89
89
-->
90
90
### 缓解措施 {#static-pods-mitigations}
91
91
92
- <!--
92
+ <!--
93
93
- Only [enable the kubelet static Pod manifest functionality](/docs/tasks/configure-pod-container/static-pod/#static-pod-creation)
94
94
if required by the node.
95
95
- If a node uses the static Pod functionality, restrict filesystem access to the static Pod manifest directory
@@ -104,12 +104,12 @@ API server. However, the Pod still runs on the node. For more information, refer
104
104
- 限制对 kubelet 配置参数和文件的访问,以防止攻击者设置静态 Pod 路径或 URL。
105
105
- 定期审计并集中报告所有对托管静态 Pod 清单和 kubelet 配置文件的目录或 Web 存储位置的访问。
106
106
107
- <!--
107
+ <!--
108
108
## The kubelet API {#kubelet-api}
109
109
-->
110
110
## kubelet API {#kubelet-api}
111
111
112
- <!--
112
+ <!--
113
113
The kubelet provides an HTTP API that is typically exposed on TCP port 10250 on cluster
114
114
worker nodes. The API might also be exposed on control plane nodes depending on the Kubernetes
115
115
distribution in use. Direct access to the API allows for disclosure of information about
@@ -120,25 +120,26 @@ kubelet 提供了一个 HTTP API,通常暴露在集群工作节点上的 TCP
120
120
在某些 Kubernetes 发行版中,API 也可能暴露在控制平面节点上。
121
121
对 API 的直接访问允许公开有关运行在节点上的 Pod、这些 Pod 的日志以及在节点上运行的每个容器中执行命令的信息。
122
122
123
- <!--
123
+ <!--
124
124
When Kubernetes cluster users have RBAC access to `Node` object sub-resources, that access
125
125
serves as authorization to interact with the kubelet API. The exact access depends on
126
- which sub-resource access has been granted, as detailed in [kubelet authorization](https://kubernetes.io/docs/reference/access-authn-authz/kubelet-authn-authz/#kubelet-authorization).
126
+ which sub-resource access has been granted, as detailed in
127
+ [kubelet authorization](/docs/reference/access-authn-authz/kubelet-authn-authz/#kubelet-authorization).
127
128
-->
128
129
当 Kubernetes 集群用户具有对 ` Node ` 对象子资源 RBAC 访问权限时,该访问权限可用作与 kubelet API 交互的授权。
129
130
实际的访问权限取决于授予了哪些子资源访问权限,详见
130
131
[ kubelet 鉴权] ( /zh-cn/docs/reference/access-authn-authz/kubelet-authn-authz/#kubelet-authorization ) 。
131
132
132
- <!--
133
+ <!--
133
134
Direct access to the kubelet API is not subject to admission control and is not logged
134
135
by Kubernetes audit logging. An attacker with direct access to this API may be able to
135
136
bypass controls that detect or prevent certain actions.
136
137
-->
137
138
对 kubelet API 的直接访问不受准入控制影响,也不会被 Kubernetes 审计日志记录。
138
139
能直接访问此 API 的攻击者可能会绕过能检测或防止某些操作的控制机制。
139
140
140
- <!--
141
- The kubelet API can be configured to authenticate requests in a number of ways.
141
+ <!--
142
+ The kubelet API can be configured to authenticate requests in a number of ways.
142
143
By default, the kubelet configuration allows anonymous access. Most Kubernetes providers
143
144
change the default to use webhook and certificate authentication. This lets the control plane
144
145
ensure that the caller is authorized to access the `nodes` API resource or sub-resources.
@@ -148,32 +149,35 @@ kubelet API 可以配置为以多种方式验证请求。
148
149
默认情况下,kubelet 的配置允许匿名访问。大多数 Kubernetes 提供商将默认值更改为使用 Webhook 和证书身份认证。
149
150
这使得控制平面能够确保调用者访问 ` Node ` API 资源或子资源是经过授权的。但控制平面不能确保默认的匿名访问也是如此。
150
151
151
- <!--
152
+ <!--
152
153
### Mitigations
153
154
-->
154
155
### 缓解措施 {#mitigations}
155
156
156
- <!--
157
+ <!--
157
158
- Restrict access to sub-resources of the `nodes` API object using mechanisms such as
158
- [RBAC](/docs/reference/access-authn-authz/rbac/). Only grant this access when required,
159
- such as by monitoring services.
159
+ [RBAC](/docs/reference/access-authn-authz/rbac/). Only grant this access when required,
160
+ such as by monitoring services.
160
161
- Restrict access to the kubelet port. Only allow specified and trusted IP address
161
- ranges to access the port.
162
- - [Ensure that kubelet authentication is set to webhook or certificate mode](/docs/reference/access-authn-authz/kubelet-authn-authz/#kubelet-authentication).
162
+ ranges to access the port.
163
+ - Ensure that [kubelet authentication](/docs/reference/access-authn-authz/kubelet-authn-authz/#kubelet-authentication).
164
+ is set to webhook or certificate mode.
163
165
- Ensure that the unauthenticated "read-only" Kubelet port is not enabled on the cluster.
164
166
-->
165
167
- 使用 [ RBAC] ( /zh-cn/docs/reference/access-authn-authz/rbac/ ) 等机制限制对 ` Node ` API 对象的子资源的访问。
166
168
只在有需要时才授予此访问权限,例如监控服务。
167
169
- 限制对 kubelet 端口的访问。只允许指定和受信任的 IP 地址段访问该端口。
168
- - [ 确保将 kubelet 身份验证设置为 Webhook 或证书模式] ( /zh-cn/docs/reference/access-authn-authz/kubelet-authn-authz/#kubelet-authentication ) 。
170
+ - 确保将
171
+ [ kubelet 身份验证] ( /zh-cn/docs/reference/access-authn-authz/kubelet-authn-authz/#kubelet-authentication )
172
+ 设置为 Webhook 或证书模式。
169
173
- 确保集群上未启用不作身份认证的“只读” Kubelet 端口。
170
174
171
- <!--
175
+ <!--
172
176
## The etcd API
173
177
-->
174
178
## etcd API {#the-etcd-api}
175
179
176
- <!--
180
+ <!--
177
181
Kubernetes clusters use etcd as a datastore. The `etcd` service listens on TCP port 2379.
178
182
The only clients that need access are the Kubernetes API server and any backup tooling
179
183
that you use. Direct access to this API allows for disclosure or modification of any
@@ -182,15 +186,15 @@ data held in the cluster.
182
186
Kubernetes 集群使用 etcd 作为数据存储。` etcd ` 服务监听 TCP 端口 2379。
183
187
只有 Kubernetes API 服务器和你所使用的备份工具需要访问此存储。对该 API 的直接访问允许公开或修改集群中保存的数据。
184
188
185
- <!--
189
+ <!--
186
190
Access to the etcd API is typically managed by client certificate authentication.
187
191
Any certificate issued by a certificate authority that etcd trusts allows full access
188
192
to the data stored inside etcd.
189
193
-->
190
194
对 etcd API 的访问通常通过客户端证书身份认证来管理。
191
195
由 etcd 信任的证书颁发机构所颁发的任何证书都可以完全访问 etcd 中存储的数据。
192
196
193
- <!--
197
+ <!--
194
198
Direct access to etcd is not subject to Kubernetes admission control and is not logged
195
199
by Kubernetes audit logging. An attacker who has read access to the API server's
196
200
etcd client certificate private key (or can create a new trusted client certificate) can gain
@@ -203,9 +207,8 @@ or create new workloads inside the cluster.
203
207
的攻击者可以通过访问集群 Secret 或修改访问规则来获得集群管理员权限。
204
208
即使不提升其 Kubernetes RBAC 权限,可以修改 etcd 的攻击者也可以在集群内检索所有 API 对象或创建新的工作负载。
205
209
206
-
207
- <!--
208
- Many Kubernetes providers configure
210
+ <!--
211
+ Many Kubernetes providers configure
209
212
etcd to use mutual TLS (both client and server verify each other's certificate for authentication).
210
213
There is no widely accepted implementation of authorization for the etcd API, although
211
214
the feature exists. Since there is no authorization model, any certificate
@@ -217,7 +220,7 @@ that are only used for health checking can also grant full read and write access
217
220
由于缺少鉴权模型,任何具有对 etcd 的客户端访问权限的证书都可以用于获得对 etcd 的完全访问权限。
218
221
通常,仅用于健康检查的 etcd 客户端证书也可以授予完全读写访问权限。
219
222
220
- <!--
223
+ <!--
221
224
### Mitigations {#etcd-api-mitigations}
222
225
-->
223
226
### 缓解措施 {#etcd-api-mitigations}
@@ -234,13 +237,13 @@ that are only used for health checking can also grant full read and write access
234
237
- 控制对 etcd 服务器证书的私钥以及 API 服务器的客户端证书和密钥的访问。
235
238
- 考虑在网络层面限制对 etcd 端口的访问,仅允许来自特定和受信任的 IP 地址段的访问。
236
239
237
- <!--
240
+ <!--
238
241
## Container runtime socket {#runtime-socket}
239
242
-->
240
243
## 容器运行时套接字 {#runtime-socket}
241
244
242
- <!--
243
- On each node in a Kubernetes cluster, access to interact with containers is controlled
245
+ <!--
246
+ On each node in a Kubernetes cluster, access to interact with containers is controlled
244
247
by the container runtime (or runtimes, if you have configured more than one). Typically,
245
248
the container runtime exposes a Unix socket that the kubelet can access. An attacker with
246
249
access to this socket can launch new containers or interact with running containers.
@@ -249,7 +252,7 @@ access to this socket can launch new containers or interact with running contain
249
252
通常,容器运行时会公开一个 kubelet 可以访问的 UNIX 套接字。
250
253
具有此套接字访问权限的攻击者可以启动新容器或与正在运行的容器进行交互。
251
254
252
- <!--
255
+ <!--
253
256
At the cluster level, the impact of this access depends on whether the containers that
254
257
run on the compromised node have access to Secrets or other confidential
255
258
data that an attacker could use to escalate privileges to other worker nodes or to
@@ -258,21 +261,21 @@ control plane components.
258
261
在集群层面,这种访问造成的影响取决于在受威胁节点上运行的容器是否可以访问 Secret 或其他机密数据,
259
262
攻击者可以使用这些机密数据将权限提升到其他工作节点或控制平面组件。
260
263
261
- <!--
264
+ <!--
262
265
### Mitigations {#runtime-socket-mitigations}
263
266
-->
264
267
### 缓解措施 {#runtime-socket-mitigations}
265
268
266
- <!--
267
- - Ensure that you tightly control filesystem access to container runtime sockets.
269
+ <!--
270
+ - Ensure that you tightly control filesystem access to container runtime sockets.
268
271
When possible, restrict this access to the `root` user.
269
272
- Isolate the kubelet from other components running on the node, using
270
273
mechanisms such as Linux kernel namespaces.
271
274
- Ensure that you restrict or forbid the use of [`hostPath` mounts](/docs/concepts/storage/volumes/#hostpath)
272
275
that include the container runtime socket, either directly or by mounting a parent
273
276
directory. Also `hostPath` mounts must be set as read-only to mitigate risks
274
277
of attackers bypassing directory restrictions.
275
- - Restrict user access to nodes, and especially restrict superuser access to nodes.
278
+ - Restrict user access to nodes, and especially restrict superuser access to nodes.
276
279
-->
277
280
- 确保严格控制对容器运行时套接字所在的文件系统访问。如果可能,限制为仅 ` root ` 用户可访问。
278
281
- 使用 Linux 内核命名空间等机制将 kubelet 与节点上运行的其他组件隔离。
0 commit comments