Repository navigation
Release 0.7.0
Cordon 0.7.0
Cordon is a Crystal shard that runs shell commands inside a platform-native sandbox with a configurable access policy. It works on macOS (via sandbox-exec / Seatbelt), Linux (via bwrap / Bubblewrap) and, new in this release as a preview, Windows 11 (via Microsoft's MXC wxc-exec.exe), presenting all three as a single clean API.
Changes
- Windows 11 support (preview) - A new runner,
Cordon::Mxc, sandboxes commands with Windows' process security environment (PSEC) through Microsoft's MXC tool.Cordon.runselects it automatically on Windows.- The policy is attached to the process itself, as on macOS and Linux: no host ACLs are changed, no extra user accounts are created, and no administrator rights are needed to run a command. MXC's ACL-based fallback is deliberately disabled, so hosts without PSEC report the runner as unavailable rather than being modified.
- Requires Windows 11 with PSEC, observed on 25H2 build 26200.9457 and later. Windows Server 2025 lacks PSEC and is not supported (#42).
- Each run gets its own sandbox identity, so concurrent runs cannot use each other's grants.
- Filesystem grants, network blocking, the environment (
env,unset_env) andworking_dirare supported.tmpfs_pathshas no Windows equivalent yet and raisesPolicyError(#37).
- Installing and checking MXC -
scripts/check-windows.ps1 -Installdownloads the MXC version Cordon is tested against, verifies its hash and Microsoft signature, installs it per user (no administrator rights) or, with-AllUsers, for all users, then checks the sandbox works on the machine. Without-Installit only checks. Preset::System::WINDOWS- Grants the one folder Windows PowerShell needs to autoload cmdlets,%ProgramFiles%\WindowsPowerShell\Modules.C:\Windowsitself, includingcmd.exeandpowershell.exe, is usable without a grant.- CLI on Windows -
cordon run,check,confirmandinspectwork on Windows, andcordon inspect --platform windowsprints the MXC config from any platform. The release build ofcordon.exeis statically linked, so it ships as a single file; a dynamically linked build with its DLLs beside it is also produced for machines whose security software blocks the static one. cordon runreports policy errors as messages - On every platform, a policy the runner cannot express (such astmpfs_pathson Windows) now prints an error and exits1instead of crashing with a stack trace.Cordon.relaunchlooks up its runner only when relaunching - On every platform, the default runner is now resolved after the depth check, so the relaunched copy no longer looks for the sandbox tool from inside the sandbox, where it may be unreadable. On Windows, where a process cannot replace itself,relaunchwaits for the sandboxed copy and exits with its exit code; relaunched programs should be statically linked.Preset::Python.for_executableon Windows - Takes the folder holdingpython.exeas the install root. The macOS/Linux rule of walking up two folders would have granted the parent of the install, and forC:\Python312the whole drive.cordon inspect --platform macosfrom Windows - Paths are passed through as written instead of being resolved against the Windows filesystem.
Known issues
Policy#envandPolicy#unset_envare honoured on Linux and Windows but silently ignored by the macOS runner, which inherits the parent environment instead. See #24.- Windows: MXC is an early preview, and Microsoft says its profiles should not yet be treated as security boundaries. Cordon pins the MXC version it is tested against (#41).
- Windows: a batch file (
.bat,.cmd) can only be run withshell: true, because its arguments cannot be quoted safely. - Windows: tested on Windows 11 Enterprise (an ARM VM, and GitHub's Windows 11 ARM runner), with
cordon.exerunning under x64 emulation. x64 hardware and other editions such as Windows 11 Pro are not yet tested. - Windows: only an x64
cordon.exeis built; ARM machines run it under emulation (#39). - Windows:
cordon.exeis unsigned. Windows Defender scans it briefly on first run, and some endpoint security products flag the statically linked executable as suspicious and delete it; ESET reported it asWin64/Spy.Agent_AGen.DX, a false positive (#40). - Windows: everything under
C:\Windowsis readable and executable in the sandbox without a grant (#38). - Windows: PowerShell 7, Git Bash, toolchains installed per user, and junctions or symlinks inside granted paths are not yet validated (#34, #35, #36).
For architecture, design decisions, and debugging workflows see DEVELOPMENT.md.