Skip to content

Commit d4bb215

Browse files
koki-developclaude
andcommitted
test: add comprehensive security e2e tests for sandbox attack vectors
Cover container escape, device access, dynamic linker injection, Go runtime exploits, host credential theft, multi-stage attacks, process manipulation, and reverse shell scenarios. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f987145 commit d4bb215

8 files changed

Lines changed: 1773 additions & 0 deletions
Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
tests:
2+
- name: "escape via /proc/self/root traversal to host shadow file"
3+
requests:
4+
- input:
5+
runtime: bash
6+
files:
7+
- name: main.sh
8+
type: plain
9+
content: |
10+
cat /proc/self/root/etc/shadow
11+
output:
12+
status: 200
13+
body:
14+
run:
15+
stdout: ""
16+
stderr: "cat: /proc/self/root/etc/shadow: No such file or directory\n"
17+
output: "cat: /proc/self/root/etc/shadow: No such file or directory\n"
18+
exit_code: 1
19+
status: "OK"
20+
signal: null
21+
22+
- name: "double /proc/self/root traversal to escape chroot"
23+
requests:
24+
- input:
25+
runtime: bash
26+
files:
27+
- name: main.sh
28+
type: plain
29+
content: |
30+
cat /proc/self/root/../../../etc/shadow
31+
output:
32+
status: 200
33+
body:
34+
run:
35+
stdout: ""
36+
stderr: "cat: /proc/self/root/../../../etc/shadow: No such file or directory\n"
37+
output: "cat: /proc/self/root/../../../etc/shadow: No such file or directory\n"
38+
exit_code: 1
39+
status: "OK"
40+
signal: null
41+
42+
- name: "chroot escape attempt"
43+
requests:
44+
- input:
45+
runtime: bash
46+
files:
47+
- name: main.sh
48+
type: plain
49+
content: |
50+
chroot / cat /etc/shadow
51+
output:
52+
status: 200
53+
body:
54+
run:
55+
stdout: ""
56+
stderr: "/sandbox/main.sh: line 1: chroot: command not found\n"
57+
output: "/sandbox/main.sh: line 1: chroot: command not found\n"
58+
exit_code: 127
59+
status: "OK"
60+
signal: null
61+
62+
- name: "/sys filesystem is not accessible"
63+
requests:
64+
- input:
65+
runtime: bash
66+
files:
67+
- name: main.sh
68+
type: plain
69+
content: |
70+
ls /sys
71+
output:
72+
status: 200
73+
body:
74+
run:
75+
stdout: ""
76+
stderr: "ls: cannot access '/sys': No such file or directory\n"
77+
output: "ls: cannot access '/sys': No such file or directory\n"
78+
exit_code: 2
79+
status: "OK"
80+
signal: null
81+
82+
- name: "cgroup filesystem is not accessible"
83+
requests:
84+
- input:
85+
runtime: bash
86+
files:
87+
- name: main.sh
88+
type: plain
89+
content: |
90+
ls /sys/fs/cgroup
91+
output:
92+
status: 200
93+
body:
94+
run:
95+
stdout: ""
96+
stderr: "ls: cannot access '/sys/fs/cgroup': No such file or directory\n"
97+
output: "ls: cannot access '/sys/fs/cgroup': No such file or directory\n"
98+
exit_code: 2
99+
status: "OK"
100+
signal: null
101+
102+
- name: "Docker socket is not accessible via filesystem"
103+
requests:
104+
- input:
105+
runtime: bash
106+
files:
107+
- name: main.sh
108+
type: plain
109+
content: |
110+
ls -la /var/run/docker.sock
111+
output:
112+
status: 200
113+
body:
114+
run:
115+
stdout: ""
116+
stderr: "ls: cannot access '/var/run/docker.sock': No such file or directory\n"
117+
output: "ls: cannot access '/var/run/docker.sock': No such file or directory\n"
118+
exit_code: 2
119+
status: "OK"
120+
signal: null
121+
122+
- name: "overwrite nsjail config to weaken sandbox"
123+
requests:
124+
- input:
125+
runtime: bash
126+
files:
127+
- name: main.sh
128+
type: plain
129+
content: |
130+
echo "mode: LISTEN" > /etc/nsjail/nsjail.cfg
131+
output:
132+
status: 200
133+
body:
134+
run:
135+
stdout: ""
136+
stderr: "/sandbox/main.sh: line 1: /etc/nsjail/nsjail.cfg: No such file or directory\n"
137+
output: "/sandbox/main.sh: line 1: /etc/nsjail/nsjail.cfg: No such file or directory\n"
138+
exit_code: 1
139+
status: "OK"
140+
signal: null
141+
142+
- name: "debugfs is not accessible"
143+
requests:
144+
- input:
145+
runtime: bash
146+
files:
147+
- name: main.sh
148+
type: plain
149+
content: |
150+
ls /sys/kernel/debug
151+
output:
152+
status: 200
153+
body:
154+
run:
155+
stdout: ""
156+
stderr: "ls: cannot access '/sys/kernel/debug': No such file or directory\n"
157+
output: "ls: cannot access '/sys/kernel/debug': No such file or directory\n"
158+
exit_code: 2
159+
status: "OK"
160+
signal: null
161+
162+
- name: "tracefs is not accessible"
163+
requests:
164+
- input:
165+
runtime: bash
166+
files:
167+
- name: main.sh
168+
type: plain
169+
content: |
170+
ls /sys/kernel/tracing
171+
output:
172+
status: 200
173+
body:
174+
run:
175+
stdout: ""
176+
stderr: "ls: cannot access '/sys/kernel/tracing': No such file or directory\n"
177+
output: "ls: cannot access '/sys/kernel/tracing': No such file or directory\n"
178+
exit_code: 2
179+
status: "OK"
180+
signal: null
181+
182+
- name: "symlink to /proc/1/root for escape"
183+
requests:
184+
- input:
185+
runtime: bash
186+
files:
187+
- name: main.sh
188+
type: plain
189+
content: |
190+
ln -s /proc/1/root/etc/shadow /tmp/shadow_link && cat /tmp/shadow_link
191+
output:
192+
status: 200
193+
body:
194+
run:
195+
stdout: ""
196+
stderr: "cat: /tmp/shadow_link: No such file or directory\n"
197+
output: "cat: /tmp/shadow_link: No such file or directory\n"
198+
exit_code: 1
199+
status: "OK"
200+
signal: null
201+
202+
- name: "containerd socket is not accessible"
203+
requests:
204+
- input:
205+
runtime: bash
206+
files:
207+
- name: main.sh
208+
type: plain
209+
content: |
210+
ls -la /run/containerd/containerd.sock
211+
output:
212+
status: 200
213+
body:
214+
run:
215+
stdout: ""
216+
stderr: "ls: cannot access '/run/containerd/containerd.sock': No such file or directory\n"
217+
output: "ls: cannot access '/run/containerd/containerd.sock': No such file or directory\n"
218+
exit_code: 2
219+
status: "OK"
220+
signal: null
221+
222+
- name: "write to /proc/self/attr/current to change security context"
223+
requests:
224+
- input:
225+
runtime: bash
226+
files:
227+
- name: main.sh
228+
type: plain
229+
content: |
230+
echo "unconfined" > /proc/self/attr/current
231+
output:
232+
status: 200
233+
body:
234+
run:
235+
stdout: ""
236+
stderr: "/sandbox/main.sh: line 1: /proc/self/attr/current: Read-only file system\n"
237+
output: "/sandbox/main.sh: line 1: /proc/self/attr/current: Read-only file system\n"
238+
exit_code: 1
239+
status: "OK"
240+
signal: null

0 commit comments

Comments
 (0)