kContainerOS: A Container That Locks Itself Down
One static Rust binary under 100 kB is PID 1, a shell and the core utilities. Init confines itself before it starts your command, and the audit before 1.0 found three of its security claims false.
kContainerOS is a userland for Linux containers on ARM64 [1]. All of it is one static binary with no libc, no std and no crates, which talks to the kernel through raw system calls. The Docker image is that binary plus four small files in /etc, and comes to under 250 kB.
FROM kcontaineros
COPY my-server /usr/local/bin/my-server
CMD ["my-server"]It is not a distribution and it does not boot. The kernel comes from the container runtime. kContainerOS is the part of a base image that runs before and around your program.
This essay makes three claims about it and shows the evidence for each:
- Small enough to read. 4,761 lines of Rust in seven files, and nothing else.
- It locks itself down. Before init starts your command, it applies four kernel mechanisms to itself. The command inherits them and cannot undo them, whatever
docker runwas told. - Checked, and the checks were checked. An end-to-end audit found no way out, three false security claims and a test suite that missed most deliberate breakages. The findings are published with the code [2].
What a base image is for
A container that runs one static server needs very little from its image: something to be PID 1, and perhaps a shell for build steps. What it usually gets is a small distribution. Alpine, the usual minimal base, is 13.6 MB: busybox with 304 applets, a C library, a package manager and 16 installed packages [3].
Size is the visible cost. Two others matter more.
- Everything in the image is there for whoever takes over the process. The server never calls the shell,
wgetor the package manager. An attacker with code execution inside the server will. The Supply Chain Is the Attack Surface called every dependency a pre-authorized stranger, and the base image is the largest dependency most services have. - The image restricts nothing. What the process may do is decided by flags on
docker run, in another file, written by someone else, on another day. One--privilegedundoes all of it.
kContainerOS takes the position odek takes for agent runtimes and MLX Runner takes for inference: the job is small and well defined, so it can be written as one program. It then adds a second position. The image should carry its own restrictions, and they should hold against the person starting the container as well as the code inside it.
Measured on the same machine, Alpine 3.24.4 against kContainerOS 1.0.0 on Docker 29.9.3, linux/arm64 [3]:
| kContainerOS | Alpine 3.24 | |
|---|---|---|
| Image size | 246 kB | 13.6 MB |
| Userland | one 95 kB Rust binary | busybox, 919 kB |
| Utilities | 19, plus sh and init |
304 busybox applets |
| C library | none | musl, 723 kB |
| Package manager | none | apk |
| PID 1 by default | /sbin/init, then your command |
your command itself |
docker stop on sleep 300 |
0.11 s, exit 143 | 3.2 s, exit 137 |
| Architectures | arm64 | arm64, amd64 and six more |
The stop times are about PID 1, not speed. On Alpine the command is PID 1, and the kernel does not deliver SIGTERM to a PID 1 that has no handler for it. Docker waits, then sends SIGKILL. kContainerOS forwards the signal, so the command exits at once. docker run --init, which puts tini in front of the command, gives Alpine the same behaviour [4]. Starting a container takes the same time on both, because Docker dominates it.
Zero dependencies, literally
Cargo.toml has no [dependencies] section and Cargo.lock lists one package, the crate itself. The build target is aarch64-unknown-none, the bare-metal one, so there is no libc underneath either. Only core and alloc from the Rust distribution are linked.
Everything a userland normally borrows is written in the repository:
| Usually provided by | In kContainerOS |
|---|---|
| libc's system call wrappers | sys.rs: every call goes through one function, sc(), which is a single svc 0 instruction |
| C start-up code and the dynamic loader | _start in eight instructions of assembly, then a routine that relocates the binary and makes the relocated tables read-only |
malloc |
A size-class allocator over mmap, under 100 lines, single-threaded by design |
tini |
init.rs |
busybox sh |
sh.rs, a deliberate subset |
| coreutils | applets.rs, 19 utilities |
| libseccomp | A BPF program of 153 instructions, written out by hand in lock.rs |
| A Landlock binding | Three raw system calls and a 12-byte struct |
The whole thing:
| File | Role | Lines |
|---|---|---|
sh.rs |
Shell | 1,731 |
applets.rs |
Utilities | 1,024 |
lock.rs |
The lockdown | 543 |
sys.rs |
System calls | 449 |
util.rs |
Shared helpers | 394 |
main.rs |
Entry, relocation, dispatch, allocator | 330 |
init.rs |
PID 1 | 290 |
| Total | 4,761 |
The binary picks its role from argv[0], as busybox does: /sbin/init, /bin/sh and the utilities are symlinks to one file. The security-relevant part is lock.rs and init.rs, 833 lines together. Someone who knows Linux can read both in an afternoon, and that is the property the rest of this essay depends on.
A second image, kcontaineros:sealed, is init and nothing else. It is built without the shell and utility code, so there is none to reach by renaming the binary. Its init is about 20 kB.
The lockdown: before your command, and from the inside
Most container hardening is applied from outside: the runtime's seccomp profile, the capability flags, an AppArmor policy. All of it depends on how the container is started. kContainerOS applies its restrictions from inside, in init, before it starts the command.
flowchart TD
D["🐳 Runtime starts /sbin/init as PID 1"] --> S["1. Block every signal
no handlers are ever installed"]
S --> N["2. no_new_privs"]
N --> L{"3. Landlock rules
run or write, never both"}
L -->|"kernel has no Landlock"| W["⚠️ Warning printed
this one rule is not enforced"]
L -->|"rules cannot be set up"| X["❌ Exit 125
the command never starts"]
L -->|"applied"| F{"4. seccomp filter"}
W --> F
F -->|"cannot be installed"| X
F -->|"installed"| C["5. Empty every capability set
PID 1 made not dumpable"]
C --> K["6. fork + exec your command
it inherits steps 2 to 5"]
K --> P["7. Sleep in rt_sigtimedwait
forward signals, reap zombies"]
P --> E["8. Exit with the command's status"]Four properties make this worth doing in init. None of the mechanisms needs privilege, so they work for root and non-root alike. The kernel enforces them, not the binary. Every descendant inherits them. And none can be lifted again from inside. The mechanisms themselves are standard kernel features [5][6][7]; what is specific is where they are applied and how the rules are built.
No privilege gain. With no_new_privs, setuid binaries and file capabilities grant nothing.
No capabilities. Init empties the bounding, ambient and process sets. Root in the container then holds no capability-based privilege, even under --privileged, and --cap-add has no effect on the command. What is left to root is what owning a file allows.
Run or write, never both. This is the Landlock rule, and the most unusual one. Programs can be started only from the image's program directories: /bin, /sbin, /usr and anything named in KCOS_EXEC. Nothing can be created, removed or written in those, whatever the file permissions say. Every other top-level directory that exists when the container starts can be written, subject to ordinary permissions, and nothing in it can be started. So a binary dropped in /tmp or on a volume cannot be executed, and the tools in the image cannot be replaced.
Two details close the obvious ways round. A file with no path, created with memfd_create, is invisible to Landlock, so the seccomp filter refuses that call. And when init attaches a rule to a directory, it walks the path one component at a time without following symbolic links, so a link cannot make a rule land somewhere else.
Only the standard devices. Under --privileged, /dev holds every disk of the host. Landlock limits a program to null, zero, full, random, urandom, the terminals and /dev/shm. A device passed with --device has to be named in KCOS_DEV as well.
Root cannot write the kernel's files. Root keeps no capability, but it still owns the files in /proc and /sys. Under init, root cannot open them for writing.
A smaller kernel surface. The seccomp filter refuses 61 system calls outright: ptrace and the calls that reach into another process's memory, new namespaces, mounts, chroot, kernel modules, bpf, io_uring, perf, keyrings, and clock and hostname changes. It runs on top of Docker's own filter. Three decisions in it are worth reading:
- A system call number newer than the filter knows is answered "not implemented". Programs already cope with that answer on old kernels, and a call nobody has looked at stays closed until someone does.
clone3is answered "not implemented" too. Its flags sit behind a pointer the filter cannot follow, so libc falls back toclone, whose flags the filter can check for namespace creation.- A system call made through any architecture other than native ARM64 kills the process.
Fail closed. If the filter cannot be installed, init prints an error and exits with status 125. The command never runs. The one exception is a kernel without Landlock, where init warns and continues with everything else.
The test suite checks each of these against the strongest attacker Docker can hand over: root, --privileged, Docker's own filter switched off. It then runs the same attempts without init as a control, where they succeed. The control is the important half. A refusal proves nothing if the attempt would have failed anyway.
PID 1 in 290 lines
Init has three jobs: forward signals to the command, reap orphaned processes, and exit with the command's status. Three rules keep the code short.
It never allocates. Everything reachable from init uses the stack and fixed buffers. The audit looked at a running PID 1 and found no heap in its memory map [8].
It installs no signal handler. Init blocks every signal and consumes them synchronously with rt_sigtimedwait. With no handler, there is no handler code to race and no async-signal-safety to reason about.
It never polls. The main loop sleeps in that one call. The same audit measured an idle PID 1 for five seconds: no context switch and no CPU tick [8].
Init also runs nested, when it is not PID 1. There it becomes a subreaper and does by hand what the kernel does for a real PID 1: SIGTERM to whatever the command left behind, then SIGKILL after two seconds.
Correct or loud
The shell is not POSIX-complete, on purpose. It has commands, variables with ${NAME:-default}, pipes, && and ||, background jobs, redirections and eleven builtins. It has no if, no loops, no functions, no $(…), no globbing and no [.
The rule that makes this safe is in the project's contributor guide: correct or loud, never silently different. The shell checks a whole script before running its first line. Anything outside the subset is a syntax error, and nothing runs. Whether a script is valid never depends on the value of a variable. The utilities follow the same rule: an option a tool does not have is an error, not something ignored.
A shell that runs the first half of an entrypoint script and misreads the second half is worse than one that refuses the script. The audit found one hole in exactly this rule, described below.
Containing an agent's tools
Who Watches What Your Agent Is Doing? described the sandbox as the first layer of agent supervision: the place where a hijacked agent gets to try. That essay did not look at what the sandbox contains. A sandbox built on a general-purpose image hands the agent a shell, an interpreter and a package manager to try with.
An agent acts through a tool process, and text the model reads can steer it. So the tool process has to be treated as something an attacker may end up directing. Put a static tool server in the sealed image, and the usual next steps are refused by the kernel instead of by instructions the model is asked to follow [9]:
| What a hijacked agent might try | What happens |
|---|---|
| Fetch a program and run it | Nothing written at run time can be started: not from /tmp, not from a volume, not from a memory file |
| Become root, or use root | No capabilities and no_new_privs: there is nothing to escalate to |
| Replace its own tools | Nothing under init can write to a program directory |
| Go after the kernel | Namespaces, mounts, ptrace, bpf, io_uring and similar are refused |
| Use what is lying around | The sealed image has no shell, no interpreter and no package manager |
| Keep running after you say stop | docker stop reaches the tool server at once |
The image cannot decide the network, the memory or what is mounted. Those are set when the container starts:
docker run -i --rm --read-only --network none --ipc none \
--memory 512m --pids-limit 128 \
--tmpfs /work:uid=65534,gid=65534,mode=0700 \
my-agent-toolsRun that way, a tool server can write its working files to /work and nowhere else, cannot start anything it writes there, has no network and holds no privilege. The audit ran this recipe as one of 17 configurations and tried 44 routes to start a program written at run time. None started under init. In the control runs without init, between 13 and 24 did [10].
What this does not contain is just as specific. Without --network none, an agent can send anything it can read to anywhere it can reach. Every file you mount is readable. A tool that deletes files will delete them for a hijacked agent too. And if you copy in Python, Node or a shell, the agent can run any script through it: the run rule stops programs brought in at run time, not code fed to an interpreter you shipped.
This fits a fixed set of tools built as static binaries. It does not fit an agent that needs compilers and package managers. And it has not been tested with any agent framework.
The audit: who checked, and what that is worth
kContainerOS 0.2.0 was audited end to end on 22 November 2026, and version 1.0.0 carries the fixes [2]. The summary opens with a section called "Read this first", and so should this one.
The audit was designed and carried out by an AI model, Claude, which also wrote most of the code it audited. No independent party has reviewed the image. The design tries to make up for that in three ways [11]:
- Auditors that start from nothing. Each of the ten tracks went to an agent with no knowledge of how the code was written, told to trust neither the comments nor the README nor the test suite, and to count only what a real container does.
- Evidence that does not rest on judgement. The seccomp filter was read back from the kernel, not from the source, and interpreted for every system call number from 0 to 1100: 405 allowed, 61 refused, 635 "not implemented" [12]. The shell was compared with busybox
shon generated scripts. - A finding counts when someone else reproduces it. Every finding went to a second agent whose task was to refute it in fresh containers.
None of these is the same as a second party, and the audit says so. It cannot rule out a mistake every agent makes in the same way. It ran on one host, one kernel, one day.
The result. No way out of the container and no privilege gain past the lockdown were found. 64 findings were reported and 53 reproduced as defects:
| Severity | Meaning | Count |
|---|---|---|
| Critical | Escape, or privilege past the lockdown | 0 |
| High | A documented security claim was false | 3 |
| Medium | Integrity, availability, or misleading security documentation | 7 |
| Low | Functional | 30 |
| Info | 13 |
The three high findings, all fixed:
- A device that was not named could still be driven with
ioctl. Opening a device for neither reading nor writing asks Landlock for nothing, and the README said such a device could not be opened. The ruleset now handles the deviceioctlright, on Linux 6.10 and later. - Naming one device in a subdirectory of
/devmade the others in it readable. WithKCOS_DEV=/dev/net/tun, an unnamed device next to it could be read, a host disk included. rm -r DIR/could be sent elsewhere. With a trailing slash the kernel follows a symbolic link, so a directory swapped for a link during the call had the link's target emptied. It lost files in 30 of 300 rounds before the fix and in none of 600 after.
Among the medium findings was the hole in "correct or loud": a backslash-newline inside a word hid shell keywords from the syntax check, so a script the shell should have refused ran with another meaning.
The checks were checked too
Two findings were about the project's own assurances, and they matter as much as the defects.
The test suite missed most deliberate breakages. The auditor removed protections from the lockdown one at a time and ran the suite against each broken copy. Of the 13 mutants the track lists, 8 passed [8]. With /sys left writable for root, no check noticed. With files removable from program directories, the suite was fully green. A regression in either would have shipped.
The suite changed the machine it ran on. One control run set the clock of the Docker VM to the year 2001 for some seconds on every run, which broke a TLS connection in another track before anyone knew why.
One low finding belongs here as well. A process started under a locked-down ancestor skips the lockdown, and it learns that an ancestor did the work by making a prctl call the filter answers with a special error. Init asked the same question. An outer seccomp filter written by someone else could give the same answer, and init would then apply nothing. As PID 1, init no longer asks. It applies everything.
This is the argument of The Verifier Is the Target on our own code. A check is worth what its distance from the thing checked is worth, and a gate that has never been attacked has an unknown failure rate. Here the gate had been written carefully, by the same author as the code, and it let most of the attacks through.
The suite grew from 459 checks to 504. It now calls every system call on the filter's list, and attacks program directories by truncation, removal and linking, each with a control. Re-running the harnesses on the fixed image turned up one more defect of the same kind as the second high finding, which no track had reported. It is fixed too, and it is a fair measure of how much one pass misses.
What it does not do
No image can honestly claim more than this, and several of these are sharp.
- ARM64 only. The build stops with an error on any other architecture.
- Static binaries only. There is no libc and no dynamic loader. Rust on musl and busybox are tested. Go with
CGO_ENABLED=0and Zig should work but are not in the suite. - Not a full shell. Existing entrypoint scripts with
if, loops or$(…)stop with a syntax error. - Some runtimes will not run.
memfd_create,ptraceandio_uringare refused, with no switch to allow them. A JIT that needs a memory file needs another base image. - "Cannot run" means "cannot be started as a program". A process can still map bytes into its own memory as executable code and jump to them, as every dynamic loader and JIT does. That code stays inside the process it was loaded into, under every restriction above.
- Init is the enforcement. Set your own
ENTRYPOINTwithout/sbin/initfirst and everything on this page is gone.docker execalso starts outside init: a shell opened that way cannot gain privileges and is under the filter, but it keeps Docker's capabilities and is not held to the run-or-write rule. - Same-user processes can read each other's memory through
/proc/PID/memunless the host enables Yama. Run one service per container. - Kernel versions. The run-or-write rule needs Landlock, so Linux 5.19 or later. The device
ioctlrule needs 6.10. - It is not a defence against kernel bugs. The filter removes the interfaces most exploits start from. It cannot remove the kernel.
- Narrow testing. One host: Docker Desktop on macOS arm64, Linux 7.0.14. Not tested on a native Linux host with bind mounts, on Kubernetes, with user-namespace remapping, or under gVisor or Kata.
- It is new. The first commit is dated 21 November 2026. There is no distribution behind it, no security team and no history of updates. Alpine has all three.
The README lists more, each with the reason [3]. Choose kContainerOS when you ship a static binary and want nothing else in the image. Choose Alpine when you need packages, a full shell, dynamically linked programs or another architecture.
Quick start
There is no published image yet, so you build it. The build cross-compiles on any Docker host. Running and testing the image needs ARM64:
git clone https://github.com/BackendStack21/kcontaineros.git && cd kcontaineros
make build # docker build --platform linux/arm64 -t kcontaineros .
make test # the end-to-end suite, against the local Docker daemon
docker run -it --rm kcontaineros
# init only: no shell, no utilities, no writable directory
docker build --platform linux/arm64 --target sealed -t kcontaineros:sealed .The compiler image is pinned by digest and the toolchain by version, and the audit rebuilt the image twice from scratch and got byte-identical layers [13].
Put a static binary on top, in /usr/local/bin:
FROM kcontaineros:sealed
COPY agent-tools /usr/local/bin/agent-tools
CMD ["agent-tools"]Then check that the lockdown is active:
docker run --rm my-image cat /proc/self/status
# look for: NoNewPrivs: 1 Seccomp: 2 CapEff: 0000000000000000Run that on an image built on the full base, since the sealed one has no cat. The landing page has the same material with terminal sessions [14].
Takeaways
A container userland is a small program. PID 1, a shell for build steps and 19 utilities fit in 4,761 lines and 95 kB, with no library underneath. The lockdown and init, the part that has to be right, are 833 of those lines.
Restrictions belong in the image. The image is the artifact that gets reviewed, pinned and shipped. A lockdown that init applies to itself holds whatever flags the container was started with, and it holds for root.
Test the tests. The most useful result of the audit was not a defect in the image. It was learning that the suite would have stayed green while the lockdown was broken. A refusal needs a control, and a suite needs mutants.
Say who checked. This image was written mostly by an AI model and audited by one. The audit's design is published so a reader can decide what that is worth, and the list of what was not covered is as long as the list of what held. An independent review is still missing, and the code is small enough to make one practical.
References
[1] 21no.de. (2026). kContainerOS. GitHub. https://github.com/BackendStack21/kcontaineros
[2] 21no.de. (2026). Security audit: summary. GitHub. https://github.com/BackendStack21/kcontaineros/blob/main/AUDIT.md
[3] 21no.de. (2026). kContainerOS README. GitHub. https://github.com/BackendStack21/kcontaineros#readme
[4] Krallin, T. tini: A tiny but valid init for containers. GitHub. https://github.com/krallin/tini
[5] The Linux Kernel documentation. No New Privileges Flag. https://docs.kernel.org/userspace-api/no_new_privs.html
[6] The Linux Kernel documentation. Landlock: unprivileged access control. https://docs.kernel.org/userspace-api/landlock.html
[7] The Linux Kernel documentation. Seccomp BPF (SECure COMPuting with filters). https://docs.kernel.org/userspace-api/seccomp_filter.html
[8] 21no.de. (2026). Audit track: claims. GitHub. https://github.com/BackendStack21/kcontaineros/blob/main/audit/claims/RESULT.md
[9] 21no.de. (2026). kContainerOS README: Containing AI agents. GitHub. https://github.com/BackendStack21/kcontaineros#containing-ai-agents
[10] 21no.de. (2026). Audit track: escape-user. GitHub. https://github.com/BackendStack21/kcontaineros/blob/main/audit/escape-user/RESULT.md
[11] 21no.de. (2026). Security audit of kContainerOS 0.2.0. GitHub. https://github.com/BackendStack21/kcontaineros/blob/main/audit/README.md
[12] 21no.de. (2026). Audit track: seccomp. GitHub. https://github.com/BackendStack21/kcontaineros/blob/main/audit/seccomp/RESULT.md
[13] 21no.de. (2026). Audit track: supply. GitHub. https://github.com/BackendStack21/kcontaineros/blob/main/audit/supply/RESULT.md
[14] 21no.de. (2026). kContainerOS. https://kcos.21no.de/
Kyberneees, November 2026