Light Sandbox
Confines the agent's shell commands to the working folder. A confined command:
- can write only the working folder (and each configured repository), a per-conversation temp directory (
$TMPDIR, also mounted on/tmp) and a shared package cache; - cannot read credentials and private data:
~/.ssh,~/.gnupg, cloud CLI configs (~/.aws,~/.config/gcloud,~/.kube, …), token files (~/.netrc,~/.git-credentials,~/.npmrc,~/.config/gh, …), browser profiles, shell history, agent sockets under$XDG_RUNTIME_DIR, container engine sockets (Docker, Podman, containerd, libvirt, LXD), and Codumentor's own home ($CODUMENTOR_HOME) and install; - cannot change files that run outside the sandbox later —
.git/hooks/,.git/config,.claude/settings.json,.codumentor/,.vscode/tasks.json,.vscode/settings.json,.envrc,.idea/workspace.xml. A command that creates one of them gets it moved to$CODUMENTOR_HOME/sandbox/tmp/<conversation>/quarantined/and is told so.git init/git clonekeep working: an inert new.git/configand git's.sample hooks are left in place; a config that sets a key git would execute (core.hooksPath,core.fsmonitor,core.sshCommand, filters,!aliases,credential.helper,include.path, …) is moved out; - has no network, cannot see or signal the Codumentor server process, and starts with a scrubbed environment (no API keys; package-manager caches redirected into the sandbox cache).
Reads elsewhere (your ~/.gitconfig, toolchains under ~, system files) work
as usual — except under the Windows AppContainer backend, which reads nothing
in your profile beyond the working folder, the toolchains on PATH and
read_extra (see Windows). File tools (read_file, write_file, …) are not affected by this
plugin.
The Office editors' document workers (doc_editor, xlsx_editor,
pptx_editor) run under the same sandbox on Linux and Windows, with
Codumentor's own code readable to them, and protected paths are checked
after each of their commands. Other plugins get the same through
Helper Processes.
Shipped in the Community edition, enabled by default. It cannot be combined
with Workspace Isolation: a configuration enabling
both refuses to start.
Platforms
| OS | Mechanism | Status |
|---|---|---|
| Linux | bubblewrap (bwrap), no overlay | available |
| Linux | Landlock (kernel ≥ 5.13), when bwrap cannot run | available (fewer guarantees below 6.12) |
| macOS | Seatbelt (/usr/bin/sandbox-exec, no sudo) | available |
| Windows | AppContainer at low integrity, in a job object (windows-appcontainer) | available (active; DPAPI listed as a known gap) |
| Windows | low-integrity token in a job object (windows-lowil), when the AppContainer cannot start | available (partial: network and credential stores open) |
On Linux install your distribution's bubblewrap package. On Ubuntu 24.04+
the apparmor package already lets /usr/bin/bwrap create user namespaces.
macOS
macOS needs nothing installed: sandbox-exec ships with the OS. Commands
may write the working folder and $TMPDIR only; secrets, Codumentor's data,
the keychain, the pasteboard, AppleEvents, defaults write and launchd
jobs are all refused, and there is no network unless a call asks for
network: true. Even then this Mac's own services (localhost, and the
Mac's LAN address) stay unreachable, and a server started inside the sandbox
cannot listen on loopback, so test suites that start a local server need
sandbox: false.
Other processes are out of reach too: a command cannot signal or inspect
processes outside its own sandbox, or read their launch arguments and
environment (KERN_PROCARGS2), so API keys in the server's environment stay
hidden.
Other differences from Linux: ps, top and pgrep do not work in the
sandbox; /tmp is not writable ($TMPDIR is); tools that start their own
sandbox need it turned off (swift build --disable-sandbox, Chrome
--no-sandbox); Office workers still run host-direct.
Landlock fallback
With backend: auto (the default) the probe tries bubblewrap first; where it
is missing or blocked (containers, hardened distributions, AppArmor without
the bwrap profile) it uses Landlock, which needs no privileges and no user
namespaces. backend: landlock pins it. sandbox status then shows a
backend_fallback row naming why bwrap was skipped. Landlock differs from
bwrap in places, and the status says exactly what it verified (active on
Linux ≥ 6.12 x86-64/arm64, partial below):
- Writes outside the folder,
$TMPDIRand the cache are blocked. Protected paths (.git/hooks, …) cannot be made read-only: a command's change to one is moved to quarantine after the command instead. - Reads of the deny-list are blocked. Landlock does not cover connecting to a unix socket by path, and the session bus, the systemd user manager (
systemd-run --user), the ssh/gpg agents ordocker.sockwould let a command leave the sandbox. So commands also get a seccomp filter that refuses to create unix-domain sockets (stream and seqpacketsocketpairs and pipes keep working; a datagramsocketpairis refused, since it could send to any datagram socket by path, such as/dev/log; a program that needs a named unix socket — a local PostgreSQL socket,sshControlMaster,tmux— fails). The probe'slocal_ipc_socketrow verifies it; where the filter is unavailable (other CPU architectures) that row is open and the sandbox reportsunavailable. 32-bit (x32/i386) programs cannot create sockets at all. - Network: an offline command gets no sockets at all (the same seccomp filter refuses every
socket()), so the network stays off on every kernel: TCP, UDP and DNS, MPTCP, netlink, vsock, and127.0.0.1too. Landlock's own TCP rules (Linux 6.7, ABI 4) are a second layer.network: truecommands share this machine's network, loopback included. - Server process: its environment and memory are unreadable at every ABI; signals are blocked from Linux 6.12 (ABI 6), below that
processis reported as not enforced. Abstract unix sockets are out of reach on any ABI (no unix socket can be created). - Narrower reads: only the system trees (
/usr,/etc,/opt,/var,/proc, …), your home (minus the deny-list, as it was when the command started) and the writable roots are readable./tmpis the host's and not usable — commands get$TMPDIR;/dev/shmis hidden, so Pythonmultiprocessinglocks fail. - No PID namespace: a command's background leftovers are killed with it, but one that starts its own session (
setsid) survives it.
Commands start through a small launcher process (one per server) that is
itself confined; each command applies its own exact rules before it runs.
Windows
With backend: auto the probe tries the AppContainer backend
(windows-appcontainer) first and falls back to the low-integrity one
(windows-lowil); either can be pinned. Both run confined commands in
PowerShell and share the token and job object described under *Low
integrity* below.
AppContainer (windows-appcontainer)
Each command also runs inside a Windows AppContainer (one per Codumentor
home, created without admin rights). A container reads only what is
explicitly opened to it, so:
- Reads are an allow-list. Your profile is unreadable —
~/.ssh,~/.gitconfig,AppData, browser profiles, other projects, yourHKCUkeys — except the working folder, the conversation's temp, the sandbox cache, the toolchains onPATH(a Python under%LOCALAPPDATA%gets a read grant) and Codumentor's runtime. Add more withread_extra. - Credential Manager is empty to confined commands (Git Credential Manager's forge tokens included). DPAPI still decrypts a blob of yours that a command can read (
dpapi_decrypt, a known gap); the blobs applications keep live in the profile and registry, which it cannot read. - The network is off and the shell tool offers
network: true: the command then gets the internet and the local network, but never this machine's loopback (Codumentor's API, local databases), with or without network. Processes inside the same command still reach each other over loopback. - The policy is ACL entries for the container, not labels (a low label is set only where an earlier
windows-lowilrun left one), recorded in$CODUMENTOR_HOME/sandbox/grants.json; secrets and protected paths inside the folder get their inheritance broken so the container cannot read or write them.codumentor sandbox resetrestores every recorded entry and deletes the container profile.
Limits:
- Toolchains under
Program Fileswith their own ACL (Node, Chocolatey, …) cannot be opened without admin rights. They are administrator actions. One startup line lists them all, the header chip shows their count, and its popover's Run as administrator opens them behind one UAC prompt on the server's desktop.codumentor sandbox setupdoes the same from a terminal, and--printshows theicaclscommands. APATHfolder that holds no program (PowerToys\DSCModules) is not a read root at all. A folder you never need confined can be dismissed. - Working folder under
C:\Users: PowerShell's location shows asWork:\(the same files), relativecdworks,cdto an absolute profile path (cd $env:TEMP) is refused.git init/git cloneinto a new directory there fail ("failed to stat 'C:/Users'"); work in an existing repository is fine. OpeningC:\Usersis an administrator action too,icacls C:\Users /grant *S-1-15-2-1:(RA)(not yet verified).
Routes (besides GET status, whose admin_setup holds only counts):
GET setup, POST setup/run ({"ids": [...]}, omitted: all undismissed;
waits for the prompt) and POST setup/dismiss ({"ids": [...],). All three need
"dismissed": true}admin:*.
- Python: confined commands get a small
sitecustomizesotempfile, pip and pytest work;python -Iskips it, sopython -m venvwith pip hangs — usepython -m venv --without-piporuv venv. HOMEis a sandbox folder with only your gituser.name/user.email;APPDATAis under it.
If the AppContainer gets in the way, backend: windows-lowil runs commands
at low integrity only.
Low integrity (windows-lowil)
Commands run with a copy of your login token lowered to low integrity and
stripped of privileges, inside a job object that ends with the command (its
leftovers are killed) and refuses clipboard and desktop access. No admin
rights are needed. The policy becomes Windows integrity labels: the working
folder, the conversation's temp and the sandbox cache are labelled low (so
commands can write them), the deny-list is labelled so low processes cannot
read it, and protected paths are labelled so they cannot be written. The
first start walks the working folder once to label it (about 5 seconds per
100,000 files); later starts only re-check. codumentor sandbox reset
removes every label the sandbox set.
Its status is partial, by design:
- Network is not blocked. Integrity levels do not cover it, and Windows has no per-process outbound block without elevation. So the shell tool has no
networkswitch here, and network-looking commands keep asking as they would without a sandbox. - Windows' own credential stores are open. DPAPI and Credential Manager (where Git Credential Manager keeps forge tokens) are per-user, and a low-integrity process of the same user can read and write them, so the sandbox does not count as keeping secrets in and the permission layer does not relax anything on that account.
- Git Bash cannot run confined. msys programs (Git Bash, its
sh,ssh,grep) cannot start at low integrity, so confined commands run in PowerShell (PowerShell 7 when installed, else Windows PowerShell 5.1), orcmdwhentools.shell_interpreter: cmd; msys directories are left off theirPATH.gititself works, but a commit in a repository with hooks fails (git runs hooks with msyssh): use--no-verifyor run it outside the sandbox. WSL refuses low-integrity callers.
Writes outside the folder (also through a junction), reads of the deny-list
and of Codumentor's data, writes to protected paths and reading the server's
memory are verified blocked. A file moved into the folder from elsewhere keeps
its own label and stays read-only to commands until it is copied instead.
What happens when it cannot run
At startup the plugin probes the host: it spawns small canaries that try
to write outside the folder, read a planted secret, read another process's
environment and connect to a loopback port, and only what is verifiably
blocked counts. The startup log prints one line with the result.
| State | Shell commands | Where you see it |
|---|---|---|
active | confined as above | Sandbox: active (bwrap, offline) |
partial | confined; the unverified guarantees are listed | Sandbox: partial … not enforced: … |
unavailable | run unconfined, decided as with no sandbox: your allow/deny rules and approvals mode apply, nothing is treated as contained, and every approval dialog shows a "not sandboxed" badge with the reason | Sandbox: NOT AVAILABLE — <reason>. Fix: <fix> |
disabled | run unconfined, permission rules as usual | Sandbox: off (config) |
If the sandbox fails after startup (e.g. bubblewrap was removed), the failing
command reports the error and the next turn runs unconfined as above.
The chat header's sandbox chip is green when the state is active and the
network is blocked (amber otherwise, red when unavailable). Its popover lists
the probe rows; a declared gap (residual: true in the status JSON, e.g.
dpapi_decrypt on Windows) is shown as a "known limit" with a plain-language
note, not as a failed check. The popover also says what the assistant can ask
for: network access for one command (where the network is blocked) and a run
outside the sandbox (unless allow_unsandboxed: false), each behind your
approval.
Network and unsandboxed commands
When the sandbox blocks the network, the shell tool gains two parameters:
network: trueruns the command still confined, but with network access. On Windows (AppContainer) it gets the internet and the local network, never this machine's loopback. On Linux the command gets its own user-mode network (pasta or slirp4netns, see below): the internet and DNS work, but services that listen only on this machine's loopback (Codumentor's own API, local databases) and abstract unix sockets (D-Bus) stay out of reach. Without either helper installed it shares this machine's network, loopback included;sandbox statusshows that as an opennetwork_loopbackcheck. It asks first in every mode butbypassPermissions, and the dialog says "with network access". To stop being asked, save a rule with thenetworkqualifier, for exampleShell(npm install:) [network]. A rule without the qualifier never grants network; a qualified rule also covers the same command offline. A qualified deny* rule refuses only networked calls. "Allow all in this conversation" and Auto mode do not grant network;bypassPermissions("Always allow") does, without asking.sandbox: falseruns the command outside the sandbox (forbrew install,git config --global,ssh). It asks every time, in every mode (bypassPermissionsincluded), with a "runs outside the sandbox" badge, and cannot be remembered: no rule covers it and the dialog offers no "allow all". Deny rules still refuse it.
When an offline command fails with a network error (Could not resolve host,
ENOTFOUND, …), the result tells the agent to retry with network: true.
Each conversation's private /tmp ($CODUMENTOR_HOME/sandbox/tmp/<id>/) is
removed when the conversation is deleted, and after 7 days without use.
The agent is told which state applies in its tool environment note
(Sandbox: light, network off — … or Sandbox: none (<reason>)).
Configuration
plugins:
- module: codumentor.plugins.light_sandbox
class: LightSandboxPlugin
args:
enabled: true # false: sandbox off, plain host execution
backend: auto # auto | bwrap | landlock | seatbelt | windows-appcontainer | windows-lowil
allow_unsandboxed: true # offer the shell tool's `sandbox: false` escape
read_deny_extra: [] # more paths nobody may read (~, $VAR, %VAR% expanded)
read_deny_remove: [] # drop a default deny entry (exact match; warns at startup)
protected_extra: [] # more read-only paths, relative to the working folder
protected_remove: [] # drop a default protected path
read_extra: [] # Windows AppContainer: more readable directories
env: {} # added to every command's environment
seccomp: default # Linux: default | off | log | enforce
allow_nested_sandboxes: false # Linux bwrap only; targeted seccomp relaxation
network_helper: auto # Linux: auto | pasta | slirp4netns | none
network_helper_path: null # the helper binary, when not on PATH
- enabled (default
true). - backend (default
auto): pin a mechanism.autoon Linux is bubblewrap, else Landlock; on Windows the AppContainer, else low integrity; on macOS Seatbelt.bwrap,landlock,seatbelt,windows-appcontainerandwindows-lowilpin one. - allow_unsandboxed (default
true): whether the shell tool'ssandbox: falseescape is offered at all.falseremoves the parameter and refuses a call that sends it anyway. - read_deny_extra / read_deny_remove: adjust the read deny-list. Removing a default must name it exactly and logs a warning at startup.
- protected_extra / protected_remove: adjust the read-only carve-outs.
- read_extra (Windows
windows-appcontaineronly): more directories confined commands may read (~,%VAR%expanded), each granted read to the container. An entry that would open the profile as a whole — the profile itself or a parent of it, a drive root,AppDataor one of its three roots — is refused with a startup warning. - env: extra environment variables for confined commands; they win over the cache redirects.
- seccomp: the syscall filter, same values as Workspace Isolation's
sandbox.seccomp. If a requested filter cannot load, the sandbox reportsunavailablerather than running unfiltered. Even inlogmode it refusesAF_VSOCKsockets (vsock ignores network namespaces and reaches the hypervisor on a VM); withoffthe probe'snetwork_vsockrow is open on a VM andnetworkis not reported as enforced. - allow_nested_sandboxes (default
false, actual YAML boolean): Linux bwrap only, same targeted namespace/legacy-mount profile as Workspace Isolation; see security trade-off. Keeps other seccomp rules, read-only/hidden mounts, PID and network policy; does not grant host root or the host network. More kernel attack surface; ancestor filters and host policy can still block nesting. Restart and start a new session. No effect on Landlock or Windows, no overlay filesystem added. - network_helper (default
auto): the user-mode network thatnetwork: truecommands get on Linux.autotriespasta(packagepasst), thenslirp4netns, and the startup probe keeps the first that sets up and keeps a host-loopback listener out of reach.none(or no helper installed, or none working) means networked commands share this machine's network, loopback included. Install the distribution's package: on Ubuntu, AppArmor lets only the packaged/usr/bin/pasta//usr/bin/slirp4netns(which ship a profile) enter the sandbox's namespaces. - network_helper_path: the helper binary when it is not on
PATH; needsnetwork_helper: pastaorslirp4netns.
Changes take effect after a restart.
Commands
codumentor sandbox status— re-run the probe and print each check;--jsonprints the same JSON as the status route.codumentor sandbox test— run the wider escape matrix (writes via symlink/hardlink, secret reads, Codumentor home, protected paths, server process, loopback, DNS, UDP, MPTCP, netlink and vsock, abstract unix sockets, datagram sockets, a secret created after startup, agent and container-engine sockets) against a scratch folder, then thenetworked_*rows with network on (host loopback and abstract sockets blocked, DNS and a public address reachable); exits 1 if anything escaped. Without a network helper the networked loopback rows readresidual(known, not a failure); under Landlock the rows it cannot enforce readnot enforced(and/tmpunsupported), with the reason — reported, not counted as failures. On Windows the rows are PowerShell (writes, a junction out of the folder, secret and Codumentor-home reads, protected paths, the server's memory, anHKCUregistry key, WSL); underwindows-lowilthe network and credential-store rows readnot enforced, underwindows-appcontaineronlydpapi_decryptdoes, and it adds the profile-read, Credential-Manager and networked (public address reachable, host loopback not) rows. Attach its output to bug reports.codumentor sandbox reset— Windows: remove the integrity labels and the AppContainer's ACL entries the sandbox set (recorded in$CODUMENTOR_HOME/sandbox/labels.jsonandgrants.json, whichever backend set them), and delete the AppContainer profile. Stop Codumentor first; it sets them again on its next command.
HTTP
GET /ui/plugins/light_sandbox/status (?refresh=true re-probes):
{
"enabled": true,
"probed": true,
"state": "active",
"backend": "bwrap",
"containment": {"writes": true, "secret_reads": true, "network": true, "process": true},
"reason": "",
"fix": "",
"checks": [{"name": "write_outside", "ok": true, "detail": "blocked"}],
"network_default": "off",
"network_helper": "pasta",
"allow_unsandboxed": true,
"summary": "Sandbox: active (bwrap, offline) — commands may write only the working folder",
"working_folder": "/home/me/project",
"workspace_isolation_in_edition": false
}
workspace_isolation_in_edition says whether this build contains the
per-conversation workspace sandbox. When it is false (the Community
edition), the chip's popover adds one line naming per-conversation
workspaces as what Enterprise adds, linking to the editions guide
(src/codumentor/enterprise_pointers.py).
containment.network: true means the network is blocked (for ordinary,
offline commands). network_helper names the helper network: true commands
use, or null when they share this machine's network; the network_loopback
check says the same as blocked/open. The route is not mounted when the plugin
is absent.
Notes
- Background shells run confined too, and are stopped with their conversation (they cannot be kept alive across a server restart).
- A private registry token in
~/.npmrc/~/.pypircis unreadable on purpose; bind the token as a user secret instead. - Design:
doc/core-dev/design/light-sandbox.md.