Repository navigation
Release 0.8.1
Cordon 0.8.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
- macOS: programs built with Crystal 1.22 run in the sandbox - From Crystal 1.22, every thread of a Crystal program on macOS creates a named semaphore, the main thread included, at startup. The sandbox denied this, and because of a Crystal bug (crystal-lang/crystal#17685) the program then hung at full CPU instead of reporting an error. This affected the
crystalcompiler,shards, and any app built with Crystal 1.22 that usesCordon.relaunch. The macOS baseline now lets a sandboxed process create and remove semaphores whose names start with/CRYSTAL/, and nothing more: opening another program's semaphore stays denied. Linux and Windows were not affected. - Tested with Crystal 1.22 - CI now builds and runs the specs with Crystal 1.22 and 1.21 on every platform, and with 1.20 on Linux. The Windows release builds use Crystal 1.22.
Known issues
- 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).
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 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.