Files
marqdo-cli/docs/evidence/2026-11-20-strict-gc.md
T
cflmy b6fc18233d 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
2026-11-20 15:01:49 +08:00

4.3 KiB

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

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)

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

== 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

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.