Skip to content

Release 0.10.0

Choose a tag to compare

@nogginly nogginly released this 23 Oct 04:40
· 3 commits to main since this release
Immutable release. Only release title and notes can be modified.
0baa54a

Cordon 0.10.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

  • Preset::Crystal - Lets the crystal compiler build, run and spec programs inside the cordon, on macOS and Linux. It grants a cache directory and a temp directory read-write and points CRYSTAL_CACHE_DIR and TMPDIR at them. On macOS it also grants the developer tools and sets PATH and SDKROOT, so cc, ld and the SDK are found without xcrun, whose cache sits in the temporary folder every application shares. On Linux it grants /etc/alternatives and /usr/libexec/gcc where present, through which Debian-family systems reach cc and GCC's collect2. It grants neither the compiler, nor /bin/sh, nor the network: merge Preset::Brew and Preset::System, and grant network yourself if a command needs it.
  • with_temp_dir and build - Preset::Crystal.with_temp_dir(cache_dir:) creates a private temp directory (mode 0700, under Dir.tempdir), yields the preset and deletes the directory when the block ends, however it ends. Preset::Crystal.build(cache_dir:, temp_dir:) takes a directory you manage yourself. Merge the preset last, and change its directories only through these arguments: setting CRYSTAL_CACHE_DIR or TMPDIR in another policy moves the variable but not the grant. On macOS, pass your own PATH as path_env: if your policy sets one.
  • The compiler cache is the caller's choice - The compiler links a cached object file whenever new code compiles to identical bitcode, so a command that can write to a cache can plant code a later build links. cache_dir therefore has no default. Give each sandboxed use a cache of its own, or opt in to the one your own builds use with Preset::Crystal.shared_cache_dir, which finds it the way the compiler does, and accept that the sandbox can write code your next unsandboxed build may link.
  • CLI: --crystal-cache DIR - cordon run and cordon inspect merge the Crystal preset with DIR as its cache, or the shared cache when DIR is shared, in a fresh temp directory per invocation: cordon run --add brew --add system --crystal-cache ~/.cache/cordon/crystal -- crystal spec.
  • CLI: a warning when --env or --unset-env overrides a preset's variable - The preset's grant for the old value stays, and the new value gets none. cordon now says so on standard error rather than leaving the command to fail, or to reach a directory you meant to withdraw.

Known issues

  • Preset::Crystal grants no network, so shards install and shards update need --allow-network (or allow_network in the policy). Without it, git fails 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; since HOME is not passed through, shards keeps its cache in the project's .shards directory rather than ~/.cache/shards.
  • Preset::Crystal is 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: build raises UnsupportedPlatformError.
  • Linux: Preset::System does not grant /etc/alternatives, so on Debian-family systems tools reached through it, such as awk, editor and pager, 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 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.