Workpen
Workpen runs one untrusted command in a project directory. By default the child cannot read secret files, cannot read your home directory, cannot use the network, and cannot write outside that directory. The parent is trusted. This is not a VM.
Install
Library:
= { = "0.7", = ["gc", "nono"] }
CLI:
cargo binstall fetches the GitHub release archive. 0.8.0 ships Linux and macOS, on x86_64 and arm64. The file inside each archive is workpen.
Git pin:
= { = "https://github.com/workpen/workpen", = "v0.8.0", = ["gc", "nono"] } <!-- x-release-please-version -->
MSRV is 1.95.
CLI
After cargo install workpen-cli --locked, paste this in a terminal:
&& &&
.env is dest-deny. notes.txt is a hardlink of .env, so dest-deny
too. workpen run on .env refuses and does not print the secret.
notes.md is ordinary: why prints allowed, run prints
hello notes. From this repo, bash examples/dest-deny.sh is the
same commands.
workpen run checks dest-deny before it starts the child. By default
the network is off. $HOME is not a workspace and not an extra root.
--extra-root is an explicit extra directory with read-write access,
so a write outside the workspace is possible only when you pass that
flag. PathGuard still refuses / and $HOME as either root.
agent.lock in the workspace adds dest-deny globs on top of the
built-in list. One glob per line. A line that starts with # is a
comment. Blank lines are skipped. A missing file means the built-in
denies only. A file that is only comments does not turn those denies
off.
# extra dest-deny globs, one per line
# secrets/**
Unix --tty gives the child a PTY. Windows --tty refuses. A
spawn-only run is examples/run-echo.sh. On
Linux, if the kernel cannot hide secret names, workpen run does not
start the child.
On Windows, why and run treat CON, PRN, AUX, COM1 through
COM9, LPT1 through LPT9, CONIN$, and CONOUT$ as devices,
including \\.\ and \\?\ forms and a path whose last name is one of
those. A trailing colon still counts (CON:, CON::). NUL stays
allowed, the same way /dev/null does on Unix.
explain reports allowed for that null device. NUL.txt stays an
ordinary file.
--timeout 1s stops the command when that time is up, including
startup on macOS. The process exits 124. Units are s, m, h,
and d.
Commands: why, run, policy, gc, init, doctor. workpen --help prints usage. workpen doctor reports whether this machine can jail a child and does not start one.
workpen gc --max-age 7d looks under .workpen-worktrees. A registered worktree from git worktree add that lives outside that directory is left alone. --dry-run prints what it would remove and does not delete. It does not clean target/.
Library hosts that still want those registered worktrees set GcConfig.age_gc_registered. The same run skips the primary checkout, a locked worktree, and a directory a process is using, and it reads status again before delete. Dry-run uses that same probe. Untracked directories outside leftover_dir are not candidates. workpen gc does not turn the flag on.
Library
use Path;
use ;
let policy = default;
assert!;
Kernel jail (feature nono): process_jail then run_child. PathGuard
refuses / and $HOME as the workspace or extra-root. Leftover
worktree GC is feature gc.
Crate rustdoc is canonical: workpen::threat_model. The same contract
in one page is docs/threat-model.md.
Limits
- On Linux, if the kernel cannot hide secret names,
workpen rundoes not start the child. Libraryrun_childstill starts the child (RemountSkipped) unless you opt intowith_require_dest_hide. - Nested Linux post-create (
mkdir x && touch x/.env) is a launch snapshot. Workspace-root missing dest-deny names are occupied when remount applies. - Windows WFP without admin is skipped (
WfpSkipped). AppContainer with no network capabilities is the unelevated net deny.read-onlyandstrictreuse one AppContainer per process.workspacedoes not create one. The workspace jail denies.ssh,.aws,.gnupg,.azure,.config\gh,.docker, and.kubewith the restricted SID and restores them when the jail drops.strictandread-onlycan read the workspace (read_onlycannot write it),SystemRoot,System32, andProgramFiles.spawn_reexeckeeps network open for a host that re-execs into one long-lived jail. Gitusr\bintools run. The jail grants the restricted SID on that install's MSYS shared directory. MSYS creates the per-user section in that directory without a security descriptor, so the directory gets an inheritable allow for the user andS-1-5-12. For an MSYS program the jail patches named-pipe creation so the signal pipe includes that SID. The job blocks clipboard use. A session with no window station does not enforce that limit. The child still inherits the parent console when the parent has one.
Contributing
See CONTRIBUTING.md. DCO sign-off required. Security: SECURITY.md.
License
MIT OR Apache-2.0.