Sandboxing
Computer security sandboxing refers to a technique used to isolate potentially malicious code or untrusted programs, ensuring they run in a confined environment where they cannot cause harm to the broader system. By creating a 'sandbox' or restricted space for these programs to operate in, any malicious actions are confined to this isolated area, preventing potential damage to the host system or access to sensitive data. This module explores sandboxing techniques as well as how hackers can escape a misconfigured sandbox.
Sandboxing: Introduction
Tips, Tricks, and Further Reading
Some tips and tricks for the challenge problems!
- Be very careful to understand the timeline of what the challenge does. A file opened BEFORE
chroot()is very different from a file opened AFTERchroot(). The sequence of actions makes a big difference. - There aren't any restrictions on shellcode (other than syscalls), so we highly recommend making sure your shellcode exits cleanly. That will make it easier to debug.
- You can determine the value of constants such as
AT_FDCWDby writing a quick C program that includes the relevant header files and doesprintf("%d\n", AT_FDCWD);. chroot()will fail if you're not running as root.stracecauses the SUID bit to be ignored, so you must usesudo straceto properly trace these challenges. Of course, this will only be possible in practice mode.- There is a known issue with strace that, in certain configurations, it will improperly resolve the syscall number of 32-bit syscalls in amd64. Using a newer Linux VM sometimes helps. If you're using
int 0x80to trigger system calls, the 32-bit ones ARE being used; strace is just lying to you. - On the subject of 32-bit syscalls: you do not have to assemble your shellcode in 32-bit mode (i.e., you don't need
-m32). It is perfectly valid to just up andint 0x80in the middle of an otherwise-64-bit shellcode. - Read this thoroughly, especially Section 3.6.1.
Filesystem Sandboxing
Sandboxing: chroot
chroot-escape-basic
Starting…Open Workspace
chroot-shellcode
Starting…Open Workspace
chroot-proper
Starting…Open Workspace
System Call Sandboxing
Sandboxing: seccomp
Sandboxing: Escaping seccomp
seccomp-basic
Starting…Open Workspace
seccomp-linkat
Starting…Open Workspace
seccomp-fchdir
Starting…Open Workspace
seccomp-rechroot
Starting…Open Workspace
seccomp-only
Starting…Open Workspace
seccomp-arch32
Starting…Open Workspace
seccomp-minimal
Starting…Open Workspace
seccomp-timebased
Starting…Open Workspace
seccomp-readonly
Starting…Open Workspace
process-isolation
Starting…Open Workspace
Sandboxing via Namespaces
Sandboxing: Namespacing Live Session 1
Sandboxing: Namespacing Live Session 2
mount-namespace
Starting…Open Workspace
mount-cleanup
Starting…Open Workspace
mount-readonly
Starting…Open Workspace
mount-shellcode
Starting…Open Workspace
mount-bindmount
Starting…Open Workspace