Repository navigation
Release 0.10.1
Cordon 0.10.1
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, as a preview, Windows 11 (via Microsoft's MXC wxc-exec.exe), presenting all three as a single clean API.
Changes
Preset::Crystal: a shards cache - The preset now also grantsshardsa cache directory and pointsSHARDS_CACHE_PATHat it, so a sandboxedshards installno longer leaves a.shardsdirectory in the project.buildandwith_temp_dirtake an optionalshards_cache_dir:. By default the cache is ashardsdirectory inside the preset's temp directory: safe, but every run clones its dependencies again. Pass a directory of your own to keep it between runs.- The shared shards cache is riskier than the compiler's - The shards cache holds a git mirror of each dependency, and
shardsrunsgitinside those mirrors. A sandboxed command that can write there can plant a git hook that runs outside the sandbox the next time you install that dependency in any project, lock file or not.Preset::Crystal.shared_shards_cache_dirreturns the cache your ownshardsuses, found the wayshardsfinds it, for callers who accept that. Prefer a cache of your own. - CLI:
--shards-cache DIR-cordon runandcordon inspecttake the shards cache with--crystal-cache, or the shared one whenDIRisshared:cordon run --add brew --add system --crystal-cache ~/.cache/cordon/crystal --shards-cache ~/.cache/cordon/shards --allow-network -- shards install. Without--crystal-cacheit is an error. - macOS: toolchain lookups on every build -
Preset::Crystalnow asksxcode-selectandxcrunfor the developer tools each time it builds a policy, rather than once per process, so a toolchain switched withxcode-select -sor replaced by an update applies to the next run. The lookups take tens of milliseconds.
Known issues
Preset::Crystalgrants no network, soshards installandshards updateneed--allow-network(orallow_networkin the policy). Without it,gitfails to clone because its HTTPS helper cannot read/etc/ssl/openssl.cnf, which the macOS runner grants only with network access. With it they work, verified on macOS.Preset::Crystalis verified on macOS with the Command Line Tools and on Ubuntu; Xcode.app installs and other Linux distributions are not yet tested. Windows is unsupported:buildraisesUnsupportedPlatformError.- Linux:
Preset::Systemdoes not grant/etc/alternatives, so on Debian-family systems tools reached through it, such asawk,editorandpager, are not found inside the sandbox. - macOS: a sandboxed process can create semaphores under
/CRYSTAL/. Semaphore names are shared across the machine, so it could take the name another Crystal program needs for its next thread, or exhaust the system's semaphore limit. Both are denial of service, not escape; Cordon does not limit a sandboxed process's resources in any case. - macOS: killing a spawned command ends that process only; processes it started keep running, still sandboxed, and can hold the caller's pipes open. Linux and Windows end the whole process tree (#47).
- Windows: MXC 1.0.0 no longer carries the "early preview, not a security boundary" warning of earlier releases, but PSEC is new and may change between Windows updates. Cordon pins the MXC version it is tested against; re-run
cordon confirmafter Windows updates (#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 25H2, on ARM (a VM and GitHub's Windows 11 ARM runner, with
cordon.exeunder x64 emulation) and on an x64 laptop, wherecordon.exeruns natively. Other editions such as Windows 11 Pro are not yet tested. - Windows: the process security environment arrives with recent Windows 11 25H2 updates. A laptop on build 26200.8893 lacked it and gained it on 26200.9448; if
check-windows.ps1reports it unavailable, install the latest updates and check again. - Windows: only an x64
cordon.exeis built; ARM machines run it under emulation (#39). - Windows:
cordon.exeis unsigned, and some endpoint security products flag the statically linked executable as suspicious (#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.