Seccomp and Landlock vs a VM Boundary for AI Agent Code
Updated November 26, 2026 .md
Short answer: Not on their own for code you didn't write. Seccomp decides which syscalls a process may make, and Landlock decides which files it may write and which TCP ports it may reach. Both worked in our test, but both run inside the kernel they protect, so a kernel bug gets past them. A VM gives the code its own kernel.
Part of Sandbox Isolation Compared: Containers, gVisor, Kata, MicroVMs, Wasm.
How we tested: two small C programs, one that installs a seccomp-bpf filter and one that installs a Landlock ruleset, each wrapping the same probe script, run as the ordinary user (no sudo) inside default Sandboxer sandboxes on 2026-11-26. Facts about seccomp and Landlock come from the Linux kernel docs, linked inline.
Seccomp vs Landlock vs a VM boundary#
| seccomp-bpf | Landlock | A VM (microVM) | |
|---|---|---|---|
| What it restricts | Which syscalls run, by number and raw argument values | File access under paths you list; TCP bind and connect by port (ABI 4+) | Nothing inside the VM by default; it separates the whole VM, with its own kernel, from the host |
| Who can turn it on | Any process, after PR_SET_NO_NEW_PRIVS |
Any process, after PR_SET_NO_NEW_PRIVS |
Whoever runs the VMM |
| Kernel the code talks to | The host's | The host's | The guest's own |
Our run: socket() blocked |
curl failed, DNS failed (EPERM on every socket) |
Not a syscall filter | No filter by default |
Our run: write ~/notes.txt |
Allowed | Permission denied |
Allowed |
Our run: write /tmp/work/out.txt |
Allowed | Allowed (the one writable path) | Allowed |
Our run: curl https:// (TCP 443) |
Failed (no socket) | 200 (the one allowed port) |
200 |
Our run: curl http:// (TCP 80) |
Failed (no socket) | Couldn't connect to server |
200 |
| Our run: DNS over UDP 53 | Failed | Resolved: ABI 7 has no UDP rules | Resolved |
Our run: unshare -U |
Killed, exit 159 (SIGSYS) | Allowed | Allowed |
Cost on 1M getppid() calls |
+0.12 s (about 0.12 µs per call) | No measurable change | Not per call |
| A bug in an allowed syscall | Reaches the host kernel | Reaches the host kernel | Stays in the guest kernel |
Last checked: 2026-11-26, on prod. default sandboxes (4 vCPU, 8 GB), Ubuntu 24.04, kernel 6.18.56-sandboxer, Landlock ABI 7, gcc from the image. The "A VM" column is the same probe with no wrapper: what the code reaches inside the VM.
Where Sandboxer fits#
A Sandboxer sandbox is a Cloud Hypervisor microVM with its own kernel, and sandboxes share no kernel with each other (Security, Machines). Its kernel has seccomp filters and Landlock built in, and both worked for an unprivileged user with no setup. So you can give each agent its own VM and still use seccomp and Landlock inside it to narrow what each tool call can do. Plans start at $20/mo.
What the kernel docs say each one does#
- seccomp-bpf filters system calls. A filter sees "system call number and the system call arguments", and "BPF programs may not dereference pointers", so it can't look at a path string or a buffer. A blocked call can return an errno (
SECCOMP_RET_ERRNO) or kill the process (SECCOMP_RET_KILL_PROCESS, which exits with SIGSYS). The process must setPR_SET_NO_NEW_PRIVSor holdCAP_SYS_ADMIN. The docs are direct about its scope: "System call filtering isn't a sandbox. It provides a clearly defined mechanism for minimizing the exposed kernel surface." (seccomp_filter) - Landlock is a stackable Linux security module whose goal is to "enable restriction of ambient rights (e.g. global filesystem or network access) for a set of processes", and it lets "any process, including unprivileged ones" restrict itself. Features arrive by ABI version: TCP bind and connect rules in ABI 4, IPC scoping in 6, UDP in 10. The docs list what it can't restrict yet, such as
chmod,chown,statand files opened before the ruleset. You check the version withlandlock_create_ruleset(NULL, 0, LANDLOCK_CREATE_RULESET_VERSION).ENOSYSmeans no kernel support andEOPNOTSUPPmeans it is turned off. (Landlock)
Both are checks inside the running kernel. The process still makes its syscalls into that kernel, and a syscall the policy allows runs the same kernel code as it would without a policy.
How tools use them#
You rarely write these filters by hand. Common tools wrap them:
- bubblewrap takes a seccomp program with
--seccomp FDor--add-seccomp-fd FD, "in the form of a compiled cBPF program, as generated by seccomp_export_bpf". Its manual lists no Landlock option. (bwrap.xml) - firejail has
--seccomp, which blocks a default syscall list (mount,ptrace,bpf,init_moduleand others, returning EPERM by default). It also has experimental--landlock.fs.read=,--landlock.fs.write=and--landlock.enforceoptions, and says "Currently only Landlock ABI version 1 is supported." (firejail man page) - Docker applies a default seccomp profile that "disables around 44 system calls out of 300+" and calls it "moderately protective while providing wide application compatibility." (Docker seccomp)
How bubblewrap and nsjail behave against a hostile script is in nsjail vs bubblewrap vs a microVM. What a Docker container still shares with the host, and what gVisor puts in front of it, is in Why use gVisor if Docker is already a sandbox?.
Test 1: a seccomp filter that blocks socket() and kills on unshare()#
nosock loads a nine-instruction BPF program, sets PR_SET_NO_NEW_PRIVS and execs the command. The filter is the whole policy:
BPF_STMT(BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, arch)),
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, AUDIT_ARCH_X86_64, 1, 0),
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS),
BPF_STMT(BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, nr)),
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_socket, 0, 1),
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ERRNO | EPERM),
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_unshare, 0, 1),
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS),
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW),The first three lines kill any call made with a different architecture, the usual guard against 32-bit syscall numbers. The probe script (full code in the copy-paste block) prints the kernel, the seccomp mode from /proc/self/status, and tries reads, writes, a delete, HTTPS, HTTP, DNS and a new user namespace:
== seccomp: socket() gets EPERM, unshare() kills
kernel: 6.18.56-sandboxer
seccomp mode: 2
read /etc/hostname: noble-balmy-maple
write ~/notes.txt: ok
write /tmp/work/out.txt: ok
rm ~/keep.txt: ok
https (tcp 443): curl: (6) Could not resolve host: example.com
000
http (tcp 80): curl: (6) Could not resolve host: example.com
000
dns (udp 53): failed
unshare -U (new user namespace): exit 159seccomp mode: 2 means a filter is active, and the filter passed to every child: curl, getent and unshare were all new processes. Blocking socket() stopped DNS first, so curl failed on name lookup before it tried to connect. Exit 159 is 128 + 31, SIGSYS. Every file operation went through, because the filter doesn't list them. That is the point of seccomp: it shrinks the syscall list. It doesn't know about paths.
Test 2: Landlock that allows writes in one directory and TCP to one port#
First, is Landlock on? In these sandboxes /sys/kernel/security/lsm doesn't exist: the kernel is built without securityfs (# CONFIG_SECURITYFS is not set), so the usual check gives No such file or directory. The kernel log and the syscall answer instead:
zcat /proc/config.gz | grep -E '^CONFIG_LSM=|LANDLOCK'
sudo dmesg | grep -i -E 'landlock|lsm'CONFIG_SECURITY_LANDLOCK=y
CONFIG_LSM="landlock,lockdown,yama,bpf"
[ 0.054004] LSM: initializing lsm=capability,landlock,yama,bpf
[ 0.054004] landlock: Up and running.rwonly DIR PORT cmd asks the kernel for its ABI version, then builds a ruleset that handles every write-type right (write, truncate, create, remove, rename across directories) and TCP connect. It grants those rights only beneath DIR and to /dev/null, and connect only to PORT. Reads and execs aren't handled, so they stay open:
== landlock: writes only in /tmp/work, TCP connect only to 443
landlock ABI: 7
kernel: 6.18.56-sandboxer
seccomp mode: 0
read /etc/hostname: noble-balmy-maple
write ~/notes.txt: ./probe.sh: 6: cannot create /home/user/notes.txt: Permission denied
write /tmp/work/out.txt: ok
rm ~/keep.txt: rm: cannot remove '/home/user/keep.txt': Permission denied
https (tcp 443): 200
http (tcp 80): curl: (7) Failed to connect to example.com port 80 after 4 ms: Couldn't connect to server
000
dns (udp 53): resolved
unshare -U (new user namespace): exit 0Landlock did what seccomp couldn't: it told two paths apart. HTTPS worked and HTTP didn't, by port. DNS still resolved, because UDP rules arrive in ABI 10 and this kernel has ABI 7. So an agent under this ruleset can still send data out over UDP. unshare -U worked because Landlock ABI 7 doesn't cover namespaces.
Our first run blocked more than we meant. Every >/dev/null in the probe failed with cannot create /dev/null: Permission denied, which also made curl -o /dev/null exit 23 and DNS look broken. A ruleset that handles WRITE_FILE covers device files too, so /dev/null needs its own rule.
The overhead#
One million os.getppid() calls from Python, three runs each, in one default sandbox:
plain 1M getppid(): 0.333 s 0.327 s 0.320 s
seccomp 1M getppid(): 0.456 s 0.427 s 0.455 s
landlock 1M getppid(): 0.354 s 0.342 s 0.306 sThe seccomp filter runs on every syscall, and added about 0.12 µs per call here. Landlock checks the operations it handles, such as opening a file for writing. getppid() isn't one of them, and it ran at the plain speed. Both are far cheaper than starting a VM, which is why they work well as a per-call layer inside one.
Why both still share the host kernel#
Every probe line above printed kernel: 6.18.56-sandboxer, with or without a policy. Seccomp and Landlock are rules the kernel checks on itself. When a call is allowed, the same kernel code runs. A memory-safety bug in, say, a filesystem or network path the policy allows is reached the same way under seccomp as without it. A policy can make that set smaller. It can't take the kernel out of the path.
A VM changes what "the kernel" is. The code in a microVM talks to the guest kernel, and the guest reaches the host only through the VMM and its virtual devices. A guest-kernel bug lands in the guest. For a deeper comparison of boundaries, see Container vs microVM.
Which should I use?#
- Your own tools, and you want to stop accidents: Landlock. Allow writes to the work directory and TCP to the ports the tool needs. It needs no root and no extra package.
- Cutting the kernel attack surface for a known program: seccomp, usually through a tool's profile (Docker's default, firejail's
--seccomp, a bubblewrap--seccompprogram). List what the program needs and deny the rest. - Code from an AI agent or a stranger, on a machine you care about: a VM boundary first, one per agent or task. Inside it, add Landlock and seccomp per tool call if you want calls kept apart from each other.
- You need to block UDP or namespaces with Landlock: check the ABI first. This kernel reports 7, so UDP (ABI 10) isn't covered. Use seccomp or a network namespace for that part.
Copy-paste: run the same probe under seccomp, Landlock and the bare VM#
Install the CLI with curl -fsSL https://sandboxer.com/install | sh and sign in with sbx login. Then paste this. It creates a default sandbox with --no-env, so none of your account's secrets reach it, compiles both wrappers with the image's gcc, runs the probe three ways and deletes the sandbox. It uses jq on your machine.
id=$(sbx new --name aeo-seclandlock-2 --type default --no-env --ttl 1800 --json | jq -r 'select(.event=="ready") | .id')
sbx exec "$id" --timeout 600 'set -e
mkdir -p ~/seclab /tmp/work && cd ~/seclab
cat > nosock.c <<"EOF"
/* nosock: run a command with socket() blocked and unshare() fatal by seccomp-bpf. */
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/prctl.h>
#include <sys/syscall.h>
#include <linux/audit.h>
#include <linux/filter.h>
#include <linux/seccomp.h>
int main(int argc, char **argv) {
struct sock_filter f[] = {
BPF_STMT(BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, arch)),
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, AUDIT_ARCH_X86_64, 1, 0),
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS),
BPF_STMT(BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, nr)),
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_socket, 0, 1),
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ERRNO | EPERM),
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_unshare, 0, 1),
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS),
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW),
};
struct sock_fprog prog = { .len = sizeof f / sizeof f[0], .filter = f };
if (argc < 2) { fprintf(stderr, "usage: nosock cmd...\n"); return 2; }
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) { perror("no_new_privs"); return 1; }
if (syscall(SYS_seccomp, SECCOMP_SET_MODE_FILTER, 0, &prog)) { perror("seccomp"); return 1; }
execvp(argv[1], argv + 1);
perror("execvp");
return 127;
}
EOF
cat > rwonly.c <<"EOF"
/* rwonly DIR PORT cmd...: Landlock allows writes only under DIR (and to /dev/null) and TCP connects only to PORT. */
#define _GNU_SOURCE
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/prctl.h>
#include <sys/syscall.h>
#include <linux/landlock.h>
int main(int argc, char **argv) {
if (argc < 4) { fprintf(stderr, "usage: rwonly DIR PORT cmd...\n"); return 2; }
int abi = syscall(SYS_landlock_create_ruleset, NULL, 0, LANDLOCK_CREATE_RULESET_VERSION);
if (abi < 0) { perror("landlock"); return 1; }
printf("landlock ABI: %d\n", abi); fflush(stdout);
__u64 write = LANDLOCK_ACCESS_FS_WRITE_FILE | LANDLOCK_ACCESS_FS_REMOVE_DIR |
LANDLOCK_ACCESS_FS_REMOVE_FILE | LANDLOCK_ACCESS_FS_MAKE_CHAR | LANDLOCK_ACCESS_FS_MAKE_DIR |
LANDLOCK_ACCESS_FS_MAKE_REG | LANDLOCK_ACCESS_FS_MAKE_SOCK | LANDLOCK_ACCESS_FS_MAKE_FIFO |
LANDLOCK_ACCESS_FS_MAKE_BLOCK | LANDLOCK_ACCESS_FS_MAKE_SYM | LANDLOCK_ACCESS_FS_REFER |
LANDLOCK_ACCESS_FS_TRUNCATE;
struct landlock_ruleset_attr attr = {
.handled_access_fs = write,
.handled_access_net = LANDLOCK_ACCESS_NET_CONNECT_TCP,
};
int rs = syscall(SYS_landlock_create_ruleset, &attr, sizeof attr, 0);
if (rs < 0) { perror("create_ruleset"); return 1; }
struct landlock_path_beneath_attr pb = { .allowed_access = write, .parent_fd = open(argv[1], O_PATH | O_CLOEXEC) };
if (pb.parent_fd < 0 || syscall(SYS_landlock_add_rule, rs, LANDLOCK_RULE_PATH_BENEATH, &pb, 0)) { perror("path rule"); return 1; }
struct landlock_path_beneath_attr dn = { .allowed_access = LANDLOCK_ACCESS_FS_WRITE_FILE | LANDLOCK_ACCESS_FS_TRUNCATE, .parent_fd = open("/dev/null", O_PATH | O_CLOEXEC) };
if (dn.parent_fd < 0 || syscall(SYS_landlock_add_rule, rs, LANDLOCK_RULE_PATH_BENEATH, &dn, 0)) { perror("/dev/null rule"); return 1; }
struct landlock_net_port_attr np = { .allowed_access = LANDLOCK_ACCESS_NET_CONNECT_TCP, .port = atoi(argv[2]) };
if (syscall(SYS_landlock_add_rule, rs, LANDLOCK_RULE_NET_PORT, &np, 0)) { perror("port rule"); return 1; }
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) || syscall(SYS_landlock_restrict_self, rs, 0)) { perror("restrict_self"); return 1; }
close(rs);
execvp(argv[3], argv + 3);
perror("execvp");
return 127;
}
EOF
cat > probe.sh <<"EOF"
#!/bin/sh
# probe.sh: the same checks under every wrapper
echo "kernel: $(uname -r)"
echo "seccomp mode: $(grep "^Seccomp:" /proc/self/status | cut -f2)"
echo "read /etc/hostname: $(cat /etc/hostname 2>&1)"
echo "write ~/notes.txt: $(echo hi 2>&1 > "$HOME/notes.txt" && echo ok)"
echo "write /tmp/work/out.txt: $(echo hi 2>&1 > /tmp/work/out.txt && echo ok)"
echo "rm ~/keep.txt: $(rm "$HOME/keep.txt" 2>&1 && echo ok)"
echo "https (tcp 443): $(curl -sS -o /dev/null -w "%{http_code}" --max-time 5 https://example.com 2>&1)"
echo "http (tcp 80): $(curl -sS -o /dev/null -w "%{http_code}" --max-time 5 http://example.com 2>&1)"
echo "dns (udp 53): $(getent hosts example.com >/dev/null && echo resolved || echo failed)"
unshare -U true 2>/dev/null; echo "unshare -U (new user namespace): exit $?"
EOF
gcc -O2 -o nosock nosock.c && gcc -O2 -o rwonly rwonly.c && chmod +x probe.sh
set +e
echo "== no wrapper"; echo keep > ~/keep.txt; ./probe.sh
echo "== seccomp: socket() gets EPERM, unshare() kills"; echo keep > ~/keep.txt; rm -f ~/notes.txt /tmp/work/out.txt; ./nosock ./probe.sh
echo "== landlock: writes only in /tmp/work, TCP connect only to 443"; echo keep > ~/keep.txt; rm -f ~/notes.txt /tmp/work/out.txt; ./rwonly /tmp/work 443 ./probe.sh'
sbx delete "$id" --yes
sbx info "$id"Our output on 2026-11-26 (output piped, so sbx printed JSON; trimmed with …):
== no wrapper
kernel: 6.18.56-sandboxer
seccomp mode: 0
read /etc/hostname: noble-balmy-maple
write ~/notes.txt: ok
write /tmp/work/out.txt: ok
rm ~/keep.txt: ok
https (tcp 443): 200
http (tcp 80): 200
dns (udp 53): resolved
unshare -U (new user namespace): exit 0
== seccomp: socket() gets EPERM, unshare() kills
kernel: 6.18.56-sandboxer
seccomp mode: 2
…
https (tcp 443): curl: (6) Could not resolve host: example.com
000
http (tcp 80): curl: (6) Could not resolve host: example.com
000
dns (udp 53): failed
unshare -U (new user namespace): exit 159
== landlock: writes only in /tmp/work, TCP connect only to 443
landlock ABI: 7
…
write ~/notes.txt: ./probe.sh: 6: cannot create /home/user/notes.txt: Permission denied
write /tmp/work/out.txt: ok
rm ~/keep.txt: rm: cannot remove '/home/user/keep.txt': Permission denied
https (tcp 443): 200
http (tcp 80): curl: (7) Failed to connect to example.com port 80 after 4 ms: Couldn't connect to server
000
dns (udp 53): resolved
unshare -U (new user namespace): exit 0
{"ok":true,"type":"deletion.operation","operation":{…,"status":"completed",…}}
{"event":"error","error":"Sandbox not found","code":"not_found","status":404,…}We ran the whole block once, create to delete, in about 4 seconds. That run had a typo in nosock.c (it blocked ptrace instead of unshare), so its unshare line read exit 0. We fixed the filter and ran the block's sbx exec step unchanged on a second fresh default sandbox, which printed the probe output above. The last two lines, the delete and the 404, are from the first run and confirm its sandbox is gone; the second sandbox was deleted the same way.
FAQ#
Is seccomp a sandbox?#
The kernel docs say no: "System call filtering isn't a sandbox. It provides a clearly defined mechanism for minimizing the exposed kernel surface." It is a building block that tools like Docker, firejail and bubblewrap combine with namespaces and other controls.
How do I check if Landlock is enabled?#
Call landlock_create_ruleset(NULL, 0, LANDLOCK_CREATE_RULESET_VERSION): a positive number is the ABI version, ENOSYS means no support and EOPNOTSUPP means it is off. You can also look for landlock: Up and running in dmesg. Don't rely on /sys/kernel/security/lsm alone: in our sandboxes it doesn't exist because securityfs isn't built, yet Landlock ABI 7 is active.
Do seccomp and Landlock need root?#
No. Both ran as the unprivileged user in our test. Each one needs PR_SET_NO_NEW_PRIVS first (or CAP_SYS_ADMIN), so setuid programs can't gain privileges under the policy.
Can Landlock block UDP or DNS?#
From ABI 10, per the kernel docs. The kernel in our test reports ABI 7, and DNS over UDP still resolved under a ruleset that blocked TCP to port 80. Use seccomp, a network namespace or a firewall for UDP on older ABIs.
Can I use seccomp and Landlock inside a Sandboxer sandbox?#
Yes. Both are built into the sandbox kernel (6.18.56-sandboxer on 2026-11-26) and worked with gcc from the image and no extra packages. They then protect the sandbox's own kernel, which is separate from the physical host's.
Related#
More guides
For running AI-written code we rank Sandboxer, Freestyle and E2B first: each gives code its own VM with an API or SDK and can pause with memory. Pick Daytona for Windows or GPUs, Modal or Northflank for GPUs at scale, E2B or Northflank to run in your own cloud, and Vercel Sandbox if your app lives on Vercel.
For coding agents we rank Sandboxer first: a full Ubuntu VM with Claude Code and Codex preinstalled, Docker, and stop-and-resume that keeps the agent's session in memory. Freestyle and Amp Orbs also keep memory across pauses. Pick E2B for prebuilt agent templates on open source, Docker Sandboxes for free local runs, and Codespaces if you live in GitHub.
The best Daytona alternatives depend on why you're switching. For a full Linux microVM on every sandbox with memory-saving stop and Docker, we rank Sandboxer first. E2B suits open source and self-hosting, Modal massive short-job fleets, Northflank bring-your-own-cloud with GPUs, and Vercel Sandbox apps on Vercel.
If you're leaving E2B for longer sessions or a fuller machine, we rank Sandboxer first, then Freestyle: both give each sandbox a full Linux VM that keeps memory across pauses, with Docker and no short session cap. Pick Daytona for Windows or GPUs, Northflank for bring-your-own-cloud, and stay on E2B if you need open source.