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:
1 parent
9b001a33a5
commit
b6fc18233d
22 files changed
+1886
-132
No files matched your search
@@ -71,5 +71,7 @@ tool install/run/remove exit 0
|
||||
true non-root run could not be performed on this host.
|
||||
- `unshare` (user/mount/PID/net) and `bwrap` fail with `EPERM`; cgroup2 is
|
||||
mounted read-only.
|
||||
- Therefore G-C (strict OS isolation) is **not passed**; strict remains
|
||||
fail-closed. `docs/security-gate.md` records the full probe.
|
||||
- Therefore G-C could not be evaluated on that container host. It was later
|
||||
executed in a disposable Ubuntu 26.04 VM; see
|
||||
[`2026-11-20-strict-gc.md`](2026-11-20-strict-gc.md) and
|
||||
`docs/security-gate.md`.
|
||||
@@ -0,0 +1,114 @@
|
||||
== adversarial helper matrix ==
|
||||
Compiling proc-macro2 v1.0.107
|
||||
Compiling quote v1.0.47
|
||||
Compiling unicode-ident v1.0.27
|
||||
Compiling serde_core v1.0.229
|
||||
Compiling serde v1.0.229
|
||||
Compiling libc v0.2.191
|
||||
Compiling syn v3.0.10
|
||||
Compiling serde_derive v1.0.229
|
||||
Compiling marqdo-sandbox v0.1.0 (/home/dev/marqdo-src/crates/marqdo-sandbox)
|
||||
Finished `test` profile [unoptimized + debuginfo] target(s) in 1m 17s
|
||||
Running tests/security_linux.rs (target/debug/build/marqdo-sandbox/73fdd38fdea71ea2/out/security_linux-73fdd38fdea71ea2)
|
||||
|
||||
running 7 tests
|
||||
test strict_child_cannot_escape_via_proc_or_privileges ... ok
|
||||
test strict_child_cannot_reach_the_network ... ok
|
||||
test strict_child_cannot_read_host_files_but_reads_the_project ... ok
|
||||
test strict_child_cannot_write_outside_or_into_the_project ... ok
|
||||
test strict_child_identity_is_unprivileged_and_namespaced ... ok
|
||||
test strict_supervisor_enforces_fd_and_process_limits ... ok
|
||||
test strict_supervisor_enforces_memory_cpu_and_output_limits ... ok
|
||||
|
||||
test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 17.88s
|
||||
|
||||
== build CLI ==
|
||||
Compiling proc-macro2 v1.0.107
|
||||
Compiling quote v1.0.47
|
||||
Compiling unicode-ident v1.0.27
|
||||
Compiling autocfg v1.5.1
|
||||
Compiling version_check v0.9.5
|
||||
Compiling typenum v1.20.1
|
||||
Compiling generic-array v0.14.7
|
||||
Compiling num-traits v0.2.19
|
||||
Compiling itoa v1.0.19
|
||||
Compiling zmij v1.0.23
|
||||
Compiling serde_json v1.0.154
|
||||
Compiling siphasher v1.0.4
|
||||
Compiling syn v3.0.10
|
||||
Compiling memchr v2.8.3
|
||||
Compiling num-integer v0.1.47
|
||||
Compiling crypto-common v0.1.7
|
||||
Compiling block-buffer v0.10.4
|
||||
Compiling equivalent v1.0.3
|
||||
Compiling hashbrown v0.17.1
|
||||
Compiling cfg-if v1.0.5
|
||||
Compiling digest v0.10.7
|
||||
Compiling phf_shared v0.14.0
|
||||
Compiling unsafe-libyaml v0.2.11
|
||||
Compiling indexmap v2.14.2
|
||||
Compiling cpufeatures v0.2.17
|
||||
Compiling fastrand v2.5.0
|
||||
Compiling ryu v1.0.23
|
||||
Compiling phf_generator v0.14.0
|
||||
Compiling sha2 v0.10.9
|
||||
Compiling thiserror v2.0.21
|
||||
Compiling phf_codegen v0.14.0
|
||||
Compiling hex v0.4.3
|
||||
Compiling same-file v1.0.6
|
||||
Compiling entities v1.0.1
|
||||
Compiling tinyvec v1.13.3
|
||||
Compiling comrak v1.0.0
|
||||
Compiling walkdir v2.5.0
|
||||
Compiling unicode-normalization v0.1.26
|
||||
Compiling fearless_simd v1.2.0
|
||||
Compiling utf8parse v0.2.2
|
||||
Compiling anstyle-parse v1.0.0
|
||||
Compiling phf v0.14.0
|
||||
Compiling caseless v0.2.2
|
||||
Compiling libloading v0.8.9
|
||||
Compiling anstyle-query v1.1.5
|
||||
Compiling is_terminal_polyfill v1.70.2
|
||||
Compiling rustc-hash v2.1.3
|
||||
Compiling typed-arena v2.0.2
|
||||
Compiling anstyle v1.0.14
|
||||
Compiling finl_unicode v1.5.1
|
||||
Compiling smallvec v1.16.6
|
||||
Compiling colorchoice v1.0.5
|
||||
Compiling anstream v1.0.0
|
||||
Compiling strsim v0.11.1
|
||||
Compiling serde_derive v1.0.229
|
||||
Compiling thiserror-impl v2.0.21
|
||||
Compiling fearless_simd_macros v0.1.0
|
||||
Compiling heck v0.5.0
|
||||
Compiling clap_lex v1.1.2
|
||||
Compiling glob v0.3.4
|
||||
Compiling clap_builder v4.6.7
|
||||
Compiling clap_derive v4.6.9
|
||||
Compiling serde v1.0.229
|
||||
Compiling semver v1.0.28
|
||||
Compiling clap v4.6.9
|
||||
Compiling marqdo-span v0.1.0 (/home/dev/marqdo-src/crates/marqdo-span)
|
||||
Compiling num-bigint v0.4.8
|
||||
Compiling serde_yaml v0.9.34+deprecated
|
||||
Compiling marqdo-value v0.1.0 (/home/dev/marqdo-src/crates/marqdo-value)
|
||||
Compiling marqdo-expression v0.1.0 (/home/dev/marqdo-src/crates/marqdo-expression)
|
||||
Compiling num-rational v0.4.2
|
||||
Compiling marqdo-math v0.1.0 (/home/dev/marqdo-src/crates/marqdo-math)
|
||||
Compiling marqdo-foreign v0.1.0 (/home/dev/marqdo-src/crates/marqdo-foreign)
|
||||
Compiling marqdo-plugin-abi v0.1.0 (/home/dev/marqdo-src/crates/marqdo-plugin-abi)
|
||||
Compiling marqdo-ir v0.1.0 (/home/dev/marqdo-src/crates/marqdo-ir)
|
||||
Compiling marqdo-sandbox v0.1.0 (/home/dev/marqdo-src/crates/marqdo-sandbox)
|
||||
Compiling memchr-n v0.1.10
|
||||
Compiling marqdo-host v0.1.0 (/home/dev/marqdo-src/crates/marqdo-host)
|
||||
Compiling marqdo-package v0.1.0 (/home/dev/marqdo-src/crates/marqdo-package)
|
||||
Compiling marqdo-runtime v0.1.0 (/home/dev/marqdo-src/crates/marqdo-runtime)
|
||||
Compiling marqdo-markdown v0.1.0 (/home/dev/marqdo-src/crates/marqdo-markdown)
|
||||
Compiling marqdo-frontend v0.1.0 (/home/dev/marqdo-src/crates/marqdo-frontend)
|
||||
Compiling marqdo-cli v0.1.0 (/home/dev/marqdo-src/crates/cli)
|
||||
Finished `dev` profile [unoptimized + debuginfo] target(s) in 6m 29s
|
||||
strict mechanism: bubblewrap 0.11.1 (user/mount/PID/net/UTS/IPC namespaces + no-new-privs + rlimits)
|
||||
== positive CLI contract ==
|
||||
== external-execution surfaces are refused ==
|
||||
== forged active marker is rejected ==
|
||||
G-C security lane: PASS
|
||||
@@ -0,0 +1,105 @@
|
||||
# G-C strict-isolation evidence — disposable Ubuntu VM (2026-11-20)
|
||||
|
||||
Status: **security lane PASS** (`G-C security lane: PASS`), run as ordinary user
|
||||
`dev` (uid 1000) in a disposable Ubuntu 26.04 VM. No remote CI URL yet.
|
||||
|
||||
Full captured log: [`2026-11-20-strict-gc.log`](2026-11-20-strict-gc.log).
|
||||
Implementation: ADR-0021, `crates/marqdo-sandbox/src/linux.rs`,
|
||||
`crates/marqdo-sandbox/tests/security_linux.rs`,
|
||||
`tests/security/escape_helper.c`, `tests/security/run-lane.sh`.
|
||||
|
||||
## Environment
|
||||
|
||||
```text
|
||||
OS: Ubuntu 26.04.1 LTS, kernel 7.0.0-43-generic x86_64
|
||||
virt: systemd-detect-virt --container -> none (QEMU/TCG guest)
|
||||
user: dev (uid 1000), passwordless sudo for test setup only
|
||||
bwrap: 0.11.1, packaged bwrap-userns-restrict AppArmor profile
|
||||
cgroup2: rw,nsdelegate (controllers visible)
|
||||
sysctl: kernel.apparmor_restrict_unprivileged_userns = 1
|
||||
```
|
||||
|
||||
`bwrap --unshare-user --unshare-net --ro-bind / / true` succeeds as `dev`
|
||||
without disabling AppArmor globally. Root may create namespaces too, but every
|
||||
security assertion runs through the ordinary-user launcher; the helper reports
|
||||
`uid=1000`, never root.
|
||||
|
||||
## Lane command (inside VM)
|
||||
|
||||
```bash
|
||||
cd /home/dev/marqdo-src
|
||||
export PATH=$HOME/.cargo/bin:$PATH
|
||||
./tests/security/run-lane.sh
|
||||
```
|
||||
|
||||
The script sets `MARQDO_REQUIRE_STRICT_SECURITY=1`, so a missing mechanism or
|
||||
helper is a failure, not a skip.
|
||||
|
||||
## Result
|
||||
|
||||
```text
|
||||
== adversarial helper matrix ==
|
||||
running 7 tests
|
||||
test strict_child_cannot_escape_via_proc_or_privileges ... ok
|
||||
test strict_child_cannot_reach_the_network ... ok
|
||||
test strict_child_cannot_read_host_files_but_reads_the_project ... ok
|
||||
test strict_child_cannot_write_outside_or_into_the_project ... ok
|
||||
test strict_child_identity_is_unprivileged_and_namespaced ... ok
|
||||
test strict_supervisor_enforces_fd_and_process_limits ... ok
|
||||
test strict_supervisor_enforces_memory_cpu_and_output_limits ... ok
|
||||
test result: ok. 7 passed; 0 failed; 0 ignored
|
||||
|
||||
strict mechanism: bubblewrap 0.11.1 (user/mount/PID/net/UTS/IPC namespaces + no-new-privs + rlimits)
|
||||
== positive CLI contract ==
|
||||
== external-execution surfaces are refused ==
|
||||
== forged active marker is rejected ==
|
||||
G-C security lane: PASS
|
||||
```
|
||||
|
||||
## Case-level observations
|
||||
|
||||
| Attack/surface | Observed inside sandbox |
|
||||
|---|---|
|
||||
| identity | `uid=1000`, `pid=1`, `NoNewPrivs: 1`, `CapEff: 0` |
|
||||
| `/etc/shadow`, `/root`, `$HOME` | `DENIED` |
|
||||
| `/project/allowed.txt` | `OK` |
|
||||
| write outside project / into `/project` | `DENIED`; no host file created |
|
||||
| write `/tmp` | allowed in private tmpfs, host unaffected |
|
||||
| `/proc/1/root/etc/shadow` | `DENIED` |
|
||||
| inherited fds above stdio | none |
|
||||
| `setuid(0)`, `mount`, nested `unshare` | `DENIED` |
|
||||
| IPv4 connect / raw socket | `DENIED` |
|
||||
| fd loop | `EMFILE` <= 64 |
|
||||
| fork loop | bounded below 200 |
|
||||
| 768 MiB touch | denied/killed by 512 MiB `RLIMIT_AS` |
|
||||
| infinite CPU loop | stopped by wall-clock/CPU budget |
|
||||
| 4 MiB stdout | stopped at the 64 KiB output limit |
|
||||
|
||||
## CLI behavior in the VM
|
||||
|
||||
```text
|
||||
run examples/hello.mq.md --mode strict -> 你好,Marqdo (exit 0)
|
||||
call examples/factorial.mq.md 数学.阶乘 --arg n=5 --mode strict -> 120
|
||||
run examples/multi-module/index.mq.md --mode strict -> 12.566370614359172
|
||||
run --mode strict --json -> success: true
|
||||
run --mode strict --allow-foreign -> exit 2
|
||||
run --mode strict --trust-native-plugin --plugin ... -> exit 2
|
||||
run --mode strict --kernel ... -> exit 2
|
||||
run --mode strict --trace-file ... -> exit 2
|
||||
MARQDO_STRICT_ACTIVE=1 run --mode strict -> exit 1 (pid is not 1)
|
||||
hide /usr/bin/bwrap; run --mode strict -> exit 1 (not installed)
|
||||
restore bwrap; run --mode strict -> success
|
||||
```
|
||||
|
||||
## Residual risks and non-claims
|
||||
|
||||
* Strict L2 (Worker/Foreign inherit the sandbox) is not implemented; those
|
||||
flags are rejected. Native ABI is never allowed in strict.
|
||||
* rlimits are used instead of cgroup-v2 accounting; no cgroup enforcement is
|
||||
claimed.
|
||||
* Filesystem TOCTOU is reduced by read-only mounts but not formally proven
|
||||
against a racing host user.
|
||||
* Network is denied by the network namespace, not a seccomp syscall allowlist.
|
||||
* A remote self-hosted security-lane CI run is still required for a CI-signed
|
||||
G-C. `.github/workflows/security-linux.yml` defines that lane and must not be
|
||||
replaced by GitHub-hosted runner success.
|
||||
Reference in new issue
Block a user