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: content/blog/ctfzone2024-registry/index.md
+20-26
Original file line number
Diff line number
Diff line change
@@ -16,19 +16,19 @@ summary: |
16
16
We're given an Attack/Defense challenge containing 5 services:
17
17
18
18
- registration \
19
-
A custom service written in Go, used to registering (adding to database) new accounts
19
+
A custom service written in Go, used to registering (adding to database) new accounts
20
20
21
21
- auth \
22
-
Authentication server for Docker, based on [cesanta/docker_auth](https://github.com/cesanta/docker_auth) project
22
+
Authentication server for Docker, based on [cesanta/docker_auth](https://github.com/cesanta/docker_auth) project
23
23
24
24
- registry \
25
-
Container images distribution server, based on official implementation of registry [distribution/distribution](https://github.com/distribution/distribution)
25
+
Container images distribution server, based on official implementation of registry [distribution/distribution](https://github.com/distribution/distribution)
26
26
27
27
- image-builder \
28
-
A custom service written in Python and Bash, used to rebuild and flatten container images
28
+
A custom service written in Python and Bash, used to rebuild and flatten container images
29
29
30
30
- nginx \
31
-
Reverse proxy, entry point to internal endpoints
31
+
Reverse proxy, entry point to internal endpoints
32
32
33
33
The checker's flow is following:
34
34
@@ -42,23 +42,23 @@ Auth policy allows to pull (push, delete, etc) an image only for its owner, so i
42
42
43
43
```yaml
44
44
acl:
45
-
- match: {ip: "127.0.0.0/8"}
45
+
- match: {ip: "127.0.0.0/8"}
46
46
actions: ["*"]
47
47
comment: "Allow everything from localhost (IPv4)"
48
48
49
-
- match: {ip: "::1"}
49
+
- match: {ip: "::1"}
50
50
actions: ["*"]
51
51
comment: "Allow everything from localhost (IPv6)"
52
52
53
-
- match: {account: "service-user"}
53
+
- match: {account: "service-user"}
54
54
actions: ["*"]
55
55
comment: "Admin has full access to everything."
56
56
57
-
- match: {account: "/.+/", name: "${account}/*"}
57
+
- match: {account: "/.+/", name: "${account}/*"}
58
58
actions: ["*"]
59
59
comment: "Logged in users have full access to images that are in their 'namespace'"
@@ -96,7 +96,7 @@ Due to deploy mistake all vulnboxes have the same password for `service-user` ac
96
96
foufons1atxnrpia
97
97
```
98
98
99
-
First blood by [dtl](https://ctftime.org/team/157017/) exploited this vulnerability. We supposed that the password *actually* was generated during the startup so didn't event checked this.
99
+
First blood by [dtl](https://ctftime.org/team/157017/) exploited this vulnerability. We supposed that the password _actually_ was generated during the startup so didn't event checked this.
100
100
101
101
Since `service-user` has full access, it lead to destructive action: someone started to delete checker images from registry.
102
102
@@ -182,9 +182,7 @@ The file `manifest.json` contains a path to config file:
@@ -364,13 +358,13 @@ The file `vzlomik.tar` is already presented in `.overlay` from the previous imag
364
358
Since the image-builder was running from `root` user, we could easily get RCE just by replacing `/usr/bin/skopeo` with our custom binary or shell script, but [renbou](https://t.me/renbou) suggested another clever way: replace `auth_config.yml`. It was possible because volumes for all containers were mounted with readwrite access. We registered new `service_user` account and grant it full access:
365
359
366
360
```yaml
367
-
- match: {account: "service-user"}
368
-
actions: ["*"]
369
-
comment: "Admin has full access to everything."
361
+
- match: {account: "service-user"}
362
+
actions: ["*"]
363
+
comment: "Admin has full access to everything."
370
364
371
-
- match: {account: "service_user"}
372
-
actions: ["*"]
373
-
comment: "Admin has full access to everything."
365
+
- match: {account: "service_user"}
366
+
actions: ["*"]
367
+
comment: "Admin has full access to everything."
374
368
```
375
369
376
370
All that's left to do is to use this account and download all checker images.
0 commit comments