Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:1ay1 Agentty Sandbox Containment

From Leeroopedia
Knowledge Sources
Domains Security, Operating_Systems
Last Updated 2026-10-28 12:00 GMT

Overview

Operating-system-level containment that restricts a child process's filesystem access, network reach, syscall surface, and resource consumption through kernel-enforced mechanisms (landlock, seccomp, cgroup2), compiled from a declarative policy.

Description

A sandbox must confine an agent-spawned subprocess (shell command, build step) so it cannot exfiltrate credentials, damage the filesystem, or consume unbounded resources. The mechanisms are kernel-level:

  • Landlock (Linux ABI 1+) restricts filesystem paths the process can read/write — enforced in the kernel, not bypassable from userspace.
  • seccomp BPF filters syscalls the process may invoke, with a notify broker for decisions that need host mediation.
  • cgroup2 caps CPU, memory, and PID usage, and provides atomic group-kill (no descendant can escape via setsid).
  • Mount namespaces isolate the filesystem view, binding only approved roots read-only.

A Posture is the declarative policy: filesystem scope (Toolchain/Minimal/HostReadable), network mode (Shared/Allowlist/Airgapped), syscall filter, resource caps, masked paths. The posture is compiled into the kernel mechanisms at spawn time. A Report describes which walls were built and their strength.

Usage

Use this principle when:

  • Running model-chosen shell commands that must not escape the workspace
  • Credentials and secrets live on the host and must be masked from the sandboxed process
  • You need kernel-enforced containment, not a userspace proxy that can be talked into bypassing

Theoretical Basis

compile:Posture→(landlock_rules,seccomp_bpf,cgroup_limits)

spawn:Posture×command→(pid,pidfd,supervisor_fd)

# Abstract algorithm (NOT real implementation)
def spawn_contained(posture, command):
    # 1. Compile posture into kernel rules
    rules = compile(posture)  # landlock, seccomp, cgroup
    # 2. Fork into new mount namespace
    pid = fork()
    if pid == 0:
        apply_landlock(rules.fs)        # restrict filesystem paths
        apply_seccomp(rules.syscalls)    # filter syscalls
        apply_cgroup(rules.resources)    # cap CPU/mem/PIDs
        mask_paths(posture.masked)       # hide credentials
        exec(command)                    # run under containment
    # Parent: poll supervisor_fd for brokered syscalls
    return pid, supervisor_fd, kill_tree_callback

Related Pages

Implemented By

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment