feat(sandbox): implement probe-gated Linux strict isolation (ADR-0021)

Strict mode now re-executes the CLI inside a Bubblewrap supervisor with
user/mount/PID/net/UTS/IPC namespaces, no-new-privs, all capabilities dropped,
a read-only /project, private /proc and /dev, rlimits, output capture and
wall-clock process-group cleanup. The child verifies PID 1, NoNewPrivs, empty
CapEff, an unshared uid map and loopback-only networking before project code.

- PlatformCapabilities::detect runs a real bwrap probe; no probe, no strict
- strict L1 supports pure Marqdo + Math; Foreign/ABI/worker/kernel/grants/trace
  are rejected with exit 2 before sandboxing
- forged MARQDO_STRICT_ACTIVE is rejected; missing bwrap fails closed
- add adversarial helper, 7-test escape/resource matrix, seeded security lane
  script and self-hosted security workflow
- executed G-C lane as uid 1000 in a disposable Ubuntu 26.04 VM: 7/7 PASS
  plus positive CLI and refusal matrix; evidence in docs/evidence
- ADR-0021, spec/security.md, STATUS/COMPATIBILITY/README/CHANGELOG updated;
  ADR-0019 remains for non-Linux/fail-closed rules
This commit is contained in:
cflmy committed 2026-11-20 15:01:49 +08:00
1 parent 9b001a33a5
commit b6fc18233d
22 files changed
+1886 -132

No files matched your search

+15 -7
View File
@@ -17,8 +17,11 @@ plugin ABI v2 are not claimed to work here.
> Foreign providers are implemented and covered by tests on Linux. The
> Windows AST and macOS plugin CI failures are fixed in source, but the native
> Windows/macOS lanes have not been re-run from this checkout. **`strict` OS
> isolation is not available**: it fails closed on every platform (G-C not
> passed), and the broker/worker are not a sandbox. See
> isolation is available on Linux only when the runtime Bubblewrap probe
> passes**; it was verified against the full escape/resource matrix in a
> disposable Ubuntu VM (ADR-0021). macOS/Windows fail closed, strict L2
> (Worker/Foreign) is not implemented, and the broker/worker are not a
> sandbox. See
> [`docs/STATUS.md`](docs/STATUS.md), [`COMPATIBILITY.md`](COMPATIBILITY.md)
> and [`docs/security-gate.md`](docs/security-gate.md). The single next-phase
> plan is [`docs/STABLE_RELEASE_IMPLEMENTATION.md`](docs/STABLE_RELEASE_IMPLEMENTATION.md).
@@ -90,8 +93,10 @@ executes anything.
`run`/`call`/`check` never fetch or rewrite the lock.
* **P4 security core** — capability-checked host operations, project-relative
FS globs with traversal rejection, budgets, effect trace, `pure`/`project`
modes, and **`strict` mode fails closed** because no verified OS isolation
adapter exists.
modes, and **Linux `strict` mode** using Bubblewrap namespaces, no-new-privs,
capability dropping, rlimits, a wall-clock supervisor and child
self-verification (ADR-0021). It is probe-gated and verified in a disposable
Ubuntu VM; unsupported hosts fail closed.
* **P5 Math/Foreign** — native `Formula` value from `$$...$$`; `math.parse/
eval/substitute` over a documented exact-rational subset; one-shot Python/
Node kernels via `foreign.run/call` with typed wire protocol, timeout and
@@ -117,9 +122,12 @@ cargo clippy --workspace --all-targets -- -D warnings
## Deliberate limits (do not assume)
* **Strict sandbox is not implemented.** `--mode strict` exits 1; there is no
verified OS isolation. `project` mode is cooperative and in-process. Worker
plugins provide crash/address-space isolation, not an OS sandbox.
* **Strict is Linux-only and L1-only.** `--mode strict` enables the
Bubblewrap supervisor only when its runtime probe passes; otherwise it exits
1. It supports pure Marqdo + Math and rejects Foreign, plugins, kernels,
external grants and trace files (exit 2). Worker plugins provide
crash/address-space isolation, not an OS sandbox, and are not allowed in
strict.
* **Native plugins run in-process** and require an explicit unsafe trust flag.
A plugin can crash or read the host; a C ABI is not a sandbox.
* **Package management is path + pinned-Git only.** There is no registry,