🚧Linux Seccomp Labs

🚧 Under Construction!!

🎯 Objective

Understand how seccomp filters syscalls using profiles and explore how processes can be restricted from making unsafe system calls.


🧰 Prerequisites

  • Linux system with kernel β‰₯ 4.4

  • Tools: gcc, make, strace, seccomp-tools

Install dependencies:

sudo apt update
sudo apt install gcc make strace seccomp-tools

πŸ”Ή Lab 1: Inspect syscalls with strace

1.1 Trace system calls of a command

strace ls

βœ… Expected: You'll see many syscalls like openat, read, write, etc.

1.2 Trace network command

βœ… Expected: You’ll see calls like socket, sendto, recvmsg, etc.


πŸ”Ή Lab 2: Block syscalls with seccomp in C

2.1 Create a C program that uses write

Compile:

βœ… Expected: It prints: Hello, world!


πŸ”Ή Lab 3: Apply a seccomp filter to block write

3.1 Modify the C code to add seccomp

3.2 Compile and run

❌ Expected: The program is killed by seccomp when calling write.


πŸ”Ή Lab 4: Use seccomp-tools to inspect a binary

Install seccomp-tools (if not installed):

Inspect:

βœ… Expected: Shows a summary of syscall filtering rules.


πŸ”Ή Lab 5: Use prctl for strict mode filtering

βœ… Expected: Works with only read, write, _exit, sigreturn.


βœ… Wrap-Up

  • You used strace to observe syscall activity

  • You created seccomp profiles in C

  • You used strict and filtered seccomp modes

  • You understood how seccomp improves security by syscall whitelisting


Last updated