Skip to content

Release 0.10.1

Choose a tag to compare

@nogginly nogginly released this 23 Oct 21:20
· 2 commits to main since this release
Immutable release. Only release title and notes can be modified.
e30cb56

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 grants shards a cache directory and points SHARDS_CACHE_PATH at it, so a sandboxed shards install no longer leaves a .shards directory in the project. build and with_temp_dir take an optional shards_cache_dir:. By default the cache is a shards directory 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 shards runs git inside 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_dir returns the cache your own shards uses, found the way shards finds it, for callers who accept that. Prefer a cache of your own.
  • CLI: --shards-cache DIR - cordon run and cordon inspect take the shards cache with --crystal-cache, or the shared one when DIR is shared: cordon run --add brew --add system --crystal-cache ~/.cache/cordon/crystal --shards-cache ~/.cache/cordon/shards --allow-network -- shards install. Without --crystal-cache it is an error.
  • macOS: toolchain lookups on every build - Preset::Crystal now asks xcode-select and xcrun for the developer tools each time it builds a policy, rather than once per process, so a toolchain switched with xcode-select -s or replaced by an update applies to the next run. The lookups take tens of milliseconds.

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.
  • 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.