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
Copy file name to clipboardExpand all lines: guide/docs/scenarios/scenario-2/scenario-2.md
+17-33Lines changed: 17 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ By the end of the scenario, we will understand and learn the following
22
22
23
23
### ⚡️ The story
24
24
25
-
Most of the CI/CD and pipeline systems use the underlying host Docker runtime to build containers for you within the pipeline by using something called DIND (docker-in-docker) with a UNIX socket. Here in this scenario, we try to exploit this misconfiguration and gain access to the host system by escaping out of the docker container.
25
+
Most of the CI/CD and pipeline systems use the underlying host container runtime to build containers for you within the pipeline by using something called DIND (docker-in-docker) with a UNIX socket. Here in this scenario, we try to exploit this misconfiguration and gain access to the host system of the worker node by escaping out of the docker container.
26
26
27
27
:::info
28
28
@@ -34,7 +34,7 @@ Most of the CI/CD and pipeline systems use the underlying host Docker runtime to
34
34
35
35
### 🎯 Goal
36
36
37
-
The goal of this scenario is to escape out of the running docker container to the host system where the container is running and able to access and perform actions on the host system.
37
+
The goal of this scenario is to escape out of the running docker container to the host system where the container is running and able to access and perform actions on other container running on the same node.
38
38
39
39
:::tip
40
40
@@ -54,31 +54,14 @@ If you can able to obtain container images in the host system then you have comp
54
54
<details>
55
55
<summary><b>✨ Able to run system commands, not sure how to access containers? </b></summary>
56
56
<div>
57
-
<div>Identify the mounted UNIX socket volume, and use docker binary to communicate with that with <b>-H</b> flag 🎉</div>
57
+
<div>Identify the mounted UNIX socket volume, and use the crictl binary to communicate with that with <b>-r</b> flag 🎉</div>
58
58
</div>
59
59
</details>
60
60
61
61
## 🎉 Solution & Walkthrough
62
62
63
63
### 🎲 Method 1
64
64
65
-
- Start by checking that DNS resolution is working for your cluster. If this doesn't work, check to see if you have a DNS service like CoreDNS running on your cluster.
66
-
67
-
```bash
68
-
www.google.com
69
-
```
70
-
71
-
:::tip
72
-
- if you get your local domain appended, try using
73
-
74
-
```bash
75
-
www.google.com.
76
-
```
77
-
78
-
- If you have to do this, you should always add a . after a url, even in wget commands. The extra dot is required is that kubernetes has a default option of ndots:5 in /etc/resolv.conf, which is verifiable in this scenario. This means that unless a minimum of 5 dots are present, the domain is not assumed to be a FQDN.
79
-
:::
80
-
81
-
82
65
- By looking at the application functionality and dabbling with the input and output, we can see it has standard command injection vulnerability. Assuming it's running in a Linux container we can use the `;` delimiter to run/pass other commands
83
66
84
67
```bash
@@ -89,52 +72,53 @@ www.google.com.
89
72
90
73
- As we can see it returns the response for the `id` command, now we can analyze the system and see what potential information we can obtain
91
74
92
-
- It contains `docker.sock` mounted into the file system as it's not available commonly in standard systems
75
+
- It contains `containerd.sock` mounted into the file system as it's not available commonly in standard systems
93
76
94
77
```bash
95
78
; mount
96
79
```
97
80
98
81

99
82
100
-
- Wow! we can see the `/custom/docker/docker.sock` mounted in the file system and assuming it's mounted from the host system we need to talk to it for communicating with the UNIX socket
83
+
- Wow! we can see the `/custom/containerd/containerd.sock` mounted in the file system and assuming it's mounted from the host system we need to talk to it for communicating with the UNIX socket
101
84
102
85
:::tip
103
86
104
-
We can use multiple methods for communicating with the `docker.sock` UNIX socket. Some of them include [official docker binary](https://download.docker.com/linux/static/stable/), or a simple `curl` program as well.
87
+
We can use multiple methods for communicating with the `containerd.sock` UNIX socket. Some of them include [crictl binary](https://github.com/kubernetes-sigs/cri-tools/blob/master/docs/crictl.md), or a simple `curl` program as well.
105
88
106
89
:::
107
90
108
-
- Next we can download the official `docker` static binary from the internet [https://download.docker.com/linux/static/stable/](https://download.docker.com/linux/static/stable/). In order to determine which binary we need, we can run the following command for system discovery
91
+
- Next we can download the `crictl` static binary from the internet [https://github.com/kubernetes-sigs/cri-tools/releases](https://github.com/kubernetes-sigs/cri-tools/releases). In order to determine which binary we need, we can run the following command for system discovery
109
92
110
93
```bash
111
94
;uname -a
112
95
```
113
96
114
-
- We can examine the output to determine our system architecture and OS, then download the appropriate docker binary to the container. For example, if our target system is a x86\_64 Linux box, we can use the following command
97
+
- We can examine the output to determine our system architecture and OS, then download the appropriate binary to the container. For example, if our target system is a x86\_64 Linux box, we can use the following command

135
118
136
-
- Hooray 🥳 , now we can see that it has a lot of container images in the host system. We can now use different docker commands to gain more access and further exploitation
119
+
- Hooray 🥳 , now we can see that it has a lot of container images in the host system. We can now use different crictl commands to gain more access and further exploitation
137
120
138
-
## 🔖 References
121
+
:::tip
139
122
140
-
-[Protect the Docker daemon socket](https://docs.docker.com/engine/security/protect-access/)
123
+
You can do the analog steps with `ctr` and interact with the containerd runtime. `crictl` shows you containers as visible in kubernetes. `ctr` shows also additional containers, such as kubernetes hidden pause containers.
0 commit comments