Skip to content

Release 0.9.0

Choose a tag to compare

@nogginly nogginly released this 22 Oct 04:54
· 4 commits to main since this release
Immutable release. Only release title and notes can be modified.
de1b70a

Cordon 0.9.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, as a preview, Windows 11 (via Microsoft's MXC wxc-exec.exe), presenting all three as a single clean API.

Changes

  • Breaking, macOS: the sandbox no longer inherits your environment - A sandboxed command on macOS used to see every variable of the process that started it. It now starts with a small passthrough set (PATH, TERM, LANG, LC_ALL, LANGUAGE, TZ and PWD), plus whatever Policy#env sets (#24). If a command relied on another variable, such as HOME, TMPDIR or a tool's own setting, add it to env. TMPDIR in particular is better pointed at a directory of the sandbox's own, granted read-write, than at the per-user temporary folder every application shares.
  • macOS: Policy#env and Policy#unset_env are honoured - They were silently ignored before. unset_env also removes passthrough variables, as on Linux and Windows.
  • macOS: Policy#working_dir is honoured - The command used to start in the caller's directory whatever working_dir said; the directory was only granted. It now starts in working_dir, as on Linux and Windows, with PWD naming it. A relative command such as ./tool is now found relative to working_dir.
  • Breaking, macOS: working_dir no longer grants access - When no path list covered working_dir, macOS quietly granted it read-write; Linux and Windows never did. Add the directory to read_write_paths or read_only_paths if the command needs it.
  • CLI: --env KEY=VALUE and --unset-env KEY - cordon run and cordon inspect can now set and remove variables inside the sandbox, overriding the policy file. Both repeat, and the last flag for a name wins. Policy files never expand $NAME, so this is where a value built from your own environment goes: --env PATH="/opt/tools/bin:$PATH".
  • macOS: the notification-center rule in BASELINE takes effect - It matched the shared-memory name with literal, which matches only file paths, so it never applied and tools such as ld and dsymutil logged a denial each time they started. It now uses ipc-posix-name, and those reads are allowed as intended.
  • macOS: Cordon.relaunch works - Its depth counter travels in Policy#env, so on macOS the relaunched program never saw it, tried to relaunch again, and failed.
  • Runner implementers: Launch#env and Launch#chdir - A Launch can now carry the complete environment its launcher starts with, and the directory it starts in; run, spawn and exec apply both. The protected execute takes the Launch rather than its argv. Code that only calls Cordon is unaffected.

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).
  • 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 confirm after Windows updates (#41).
  • Windows: a batch file (.bat, .cmd) can only be run with shell: 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.exe under x64 emulation) and on an x64 laptop, where cordon.exe runs 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.ps1 reports it unavailable, install the latest updates and check again.
  • Windows: only an x64 cordon.exe is built; ARM machines run it under emulation (#39).
  • Windows: cordon.exe is unsigned, and some endpoint security products flag the statically linked executable as suspicious (#40).
  • Windows: everything under C:\Windows is 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.