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
+12
-10
@@ -65,9 +65,9 @@ runs.
|
||||
| 4 | Analysis/Trace/Tool protocol | **Implemented; consumers PASS locally** | schemas + `tests/consumers/*.py`, `analysis_trace`/`tool_protocol` PASS; `check_never_spawns_a_foreign_kernel` PASS |
|
||||
| 5 | Foreign pinned environment | **Done (ADR-0020)** | provider tests PASS; env binds interpreter; version drift rejected |
|
||||
| 6 | ABI session/broker hardening | **Partial** | `fs.read` bridge + budgets + handle tests PASS; Windows ABI unsupported; broader services still `capability.unavailable` |
|
||||
| 7 | Linux strict probe | **Done as fail-closed evidence** | `docs/security-gate.md`; userns/bwrap EPERM, cgroup ro, sudo blocked |
|
||||
| 8 | Linux strict pure (L1) | **BLOCKED** | no namespace creation on this host; no adapter implemented or verified |
|
||||
| 9 | Linux strict extensions (L2) | **BLOCKED** | depends on L1 |
|
||||
| 7 | Linux strict probe | **Done** | runtime Bubblewrap probe; unavailable host reports the real reason |
|
||||
| 8 | Linux strict pure (L1) | **DONE (VM-verified)** | ADR-0021; 7/7 adversarial tests + CLI matrix PASS in disposable Ubuntu VM |
|
||||
| 9 | Linux strict extensions (L2) | **NOT IMPLEMENTED** | strict rejects Worker/Foreign/native ABI; future ADR needed |
|
||||
| 10 | Native platform matrix | **Partial** | Linux PASS; macOS/Windows source fixes, remote lanes absent |
|
||||
| 11 | Independent ecosystem consumers | **Partial** | Analysis/Trace Python consumers PASS; three Tool fixtures not added |
|
||||
| 12 | RC/docs/artifacts | **Candidate build only** | release docs, checksummed artifact, clean-install smoke; NOT released |
|
||||
@@ -97,10 +97,11 @@ runs.
|
||||
|
||||
1. **No remote CI evidence for this commit.** The repository remote is Gitee;
|
||||
no GitHub workflow was executed. Windows/macOS fixes are UNVERIFIED there.
|
||||
2. **G-C is not passed.** `strict` remains `Unavailable`; the host cannot
|
||||
create namespaces and root cgroup2 is read-only. See
|
||||
[`security-gate.md`](security-gate.md). No release may claim Linux strict
|
||||
isolation.
|
||||
2. **G-C is VM-verified but not CI-signed.** Strict L1 passes the full
|
||||
adversarial matrix in a disposable Ubuntu 26.04 VM (ADR-0021,
|
||||
[`security-gate.md`](security-gate.md)), and is enabled only when the
|
||||
runtime Bubblewrap probe succeeds. No remote security-lane URL exists yet,
|
||||
and strict L2 (Worker/Foreign) is not implemented.
|
||||
3. Windows Native/Worker ABI is explicitly unsupported (no `cc` toolchain in
|
||||
the lane); it is not counted as a pass.
|
||||
4. `fs.write`, `net.request`, `process`, `clock`, `random` are not executed
|
||||
@@ -112,13 +113,14 @@ runs.
|
||||
Python consumers exist.
|
||||
7. No release tag/binary publication. A candidate archive and checksums are
|
||||
produced locally; the release decision is **DO NOT RELEASE** until the
|
||||
native CI matrix and G-C conditions in the plan are satisfied.
|
||||
native CI matrix and a security-lane CI URL exist.
|
||||
|
||||
## 5. Evidence files
|
||||
|
||||
- [`evidence/2026-11-20-local-gate.md`](evidence/2026-11-20-local-gate.md) —
|
||||
exact local commands, Windows autocrlf reproduction, clean-install smoke and
|
||||
the environment limits that block G-C.
|
||||
exact local commands, Windows autocrlf reproduction and clean-install smoke.
|
||||
- [`security-gate.md`](security-gate.md) — the full G-C VM evidence, escape
|
||||
matrix and strict L1/L2 limits.
|
||||
|
||||
## 6. Reproduce
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# ADR-0019: Strict-mode availability gate
|
||||
|
||||
Status: **Accepted**
|
||||
Status: **Accepted; Linux availability superseded by ADR-0021**
|
||||
Date: 2026-11-20
|
||||
Relates to: ADR-0004 (strict mode refuses without isolation), blueprint §9
|
||||
|
||||
@@ -18,6 +18,15 @@ rules only; it does not by itself satisfy the network/process/resource and
|
||||
child-tree requirements in `docs/CORE_STABILIZATION_AND_ECOSYSTEM_GATE.md`
|
||||
§13.
|
||||
|
||||
## Superseding note (2026-11-20)
|
||||
|
||||
The fail-closed principle and the per-platform, test-gated availability rule in
|
||||
this ADR remain in force. A concrete Linux adapter has since passed the
|
||||
security matrix in a disposable Ubuntu VM and is specified by **ADR-0021**:
|
||||
strict becomes `Available` only when the Bubblewrap probe succeeds at runtime.
|
||||
This ADR remains authoritative for every other platform and for the rule that
|
||||
availability must never be assumed.
|
||||
|
||||
## Decision
|
||||
|
||||
### 1. Strict stays unavailable until the gate passes
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# ADR-0021: Linux strict isolation via Bubblewrap, namespaces and rlimits
|
||||
|
||||
Status: **Accepted**
|
||||
Date: 2026-11-20
|
||||
Relates to: ADR-0004, ADR-0019, `spec/security.md`, stable-release plan §10
|
||||
Security evidence: `docs/evidence/2026-11-20-strict-gc.md`
|
||||
|
||||
## Context
|
||||
|
||||
ADR-0019 kept strict mode `Unavailable` everywhere because no adapter had been
|
||||
executed against the full escape/resource matrix, and the first development
|
||||
host could not create any namespace. A disposable Ubuntu 26.04 VM with a real
|
||||
kernel, writable cgroup2, passwordless sudo for test setup and the packaged
|
||||
Bubblewrap AppArmor profile became available. It can create user, mount, PID,
|
||||
network, UTS and IPC namespaces as an ordinary user through `bwrap`.
|
||||
|
||||
## Decision
|
||||
|
||||
### 1. Dynamic, probe-gated availability
|
||||
|
||||
`PlatformCapabilities::detect()` on Linux runs a real Bubblewrap smoke test
|
||||
(`--unshare-all --as-pid-1`, read-only runtime bind, private `/proc` and
|
||||
`/dev`). Strict is `Available { mechanism: "bubblewrap ..." }` only when that
|
||||
probe succeeds; otherwise it stays `Unavailable` with the real reason. There is
|
||||
still no fallback to `project`.
|
||||
|
||||
### 2. L1 scope: pure language and native Math only
|
||||
|
||||
Strict accepts `run`/`call` of documents using the interpreter, console and
|
||||
native Math. It rejects `--allow-read`, `--allow-write`, `--allow-foreign`,
|
||||
`--allow-plugin`, `--plugin`, `--trust-native-plugin`, `--kernel` and
|
||||
`--trace-file` with exit 2 before any sandbox starts. Native ABI, worker
|
||||
plugins and Foreign kernels are therefore not reachable in strict mode in this
|
||||
release; L2 inheritance is future work.
|
||||
|
||||
### 3. Construction
|
||||
|
||||
The trusted supervisor is this process; the restricted child is the same
|
||||
`marqdo` executable re-executed under Bubblewrap:
|
||||
|
||||
* `--unshare-all --as-pid-1 --die-with-parent --new-session` — user, mount,
|
||||
PID, network, UTS, IPC and cgroup namespaces; the child is PID 1;
|
||||
* read-only binds of `/usr`, `/bin`, `/sbin`, `/lib`, `/lib64` and
|
||||
`/etc/ld.so.cache`, and of the project tree at `/project`;
|
||||
* a read-only bind of the program at `/run/marqdo-program`; no host `/root`,
|
||||
`$HOME`, `/etc` or other project directories are visible;
|
||||
* private `/proc`, minimal `/dev`, tmpfs `/tmp`;
|
||||
* `--clearenv`, `no_new_privs`, `--cap-drop ALL`;
|
||||
* hard rlimits: CPU, address space (512 MiB), file size, open files (64),
|
||||
processes (64), stack (8 MiB), core (0);
|
||||
* a supervisor deadline that kills the process group, and bounded capture of
|
||||
stdout/stderr.
|
||||
|
||||
The document argument is rewritten to `/project/...`; only the document token
|
||||
changes, all other arguments are preserved.
|
||||
|
||||
### 4. Child self-verification
|
||||
|
||||
The child accepts `MARQDO_STRICT_ACTIVE=1` only if it can verify all of:
|
||||
`getpid() == 1`, `NoNewPrivs: 1`, empty `CapEff`, a non-initial uid map, and no
|
||||
non-loopback network interface. A forged marker outside the sandbox fails
|
||||
before project code runs.
|
||||
|
||||
### 5. Threat model and non-goals
|
||||
|
||||
This protects against untrusted Marqdo documents that use the language,
|
||||
interpreter, Math, console, or attempt direct syscalls. It does not sandbox
|
||||
native plugins (rejected), Foreign kernels (rejected), or a malicious kernel.
|
||||
Bubblewrap is the construction mechanism, not a certificate; the runtime probe
|
||||
and self-verification are part of the contract.
|
||||
|
||||
Known limits: rlimits are used instead of cgroup-v2 accounting (the VM has
|
||||
writable cgroups, but the released adapter does not yet claim cgroup
|
||||
enforcement); filesystem TOCTOU is limited by read-only mounts but not proven
|
||||
against a racing host user; the project tree is exposed read-only in full;
|
||||
network is isolated by a network namespace rather than a seccomp allowlist. No
|
||||
worker/Foreign L2 claim is made.
|
||||
|
||||
## Evidence
|
||||
|
||||
Executed in a disposable Ubuntu 26.04 VM (kernel 7.0.0, `container: none`,
|
||||
Bubblewrap 0.11.1, AppArmor `bwrap-userns-restrict` profile, ordinary user
|
||||
`dev`):
|
||||
|
||||
* 7/7 adversarial tests: identity, host reads, writes, `/proc`/privileges,
|
||||
network, fd/process limits, memory/CPU/output limits;
|
||||
* CLI: `run`, `call`, absolute paths, multi-module, default `index.mq.md` and
|
||||
`--json` all succeed under strict; Foreign/ABI/plugin/kernel/trace flags are
|
||||
rejected with exit 2;
|
||||
* forged `MARQDO_STRICT_ACTIVE=1` outside the sandbox exits 1;
|
||||
* removing `/usr/bin/bwrap` makes strict `Unavailable` and the run exits 1 with
|
||||
no project execution.
|
||||
|
||||
## Consequences
|
||||
|
||||
* Linux strict is available **only where the probe succeeds**; this container
|
||||
still reports unavailable.
|
||||
* `worker_processes` remains true for crash isolation, but that is not part of
|
||||
the strict claim.
|
||||
* A future L2 ADR must extend the same supervisor to worker/Foreign processes,
|
||||
with its own escape tests, before those may run under strict.
|
||||
* A remote self-hosted security-lane URL is still required before a release
|
||||
calls G-C CI-verified; the local VM evidence is recorded separately.
|
||||
@@ -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.
|
||||
+113
-67
@@ -1,83 +1,129 @@
|
||||
# Linux strict-isolation security gate (G-C) — evidence report
|
||||
# Linux strict-isolation security gate (G-C) — evidence
|
||||
|
||||
Status: **G-C NOT PASSED. `strict` remains `Unavailable` and fails closed.**
|
||||
Snapshot: workspace `0.1.0`, 2026-11-20. No release tag.
|
||||
Status: **PASSED in a disposable Ubuntu VM; Linux strict is enabled only when
|
||||
the runtime probe succeeds.** No remote security-lane CI URL exists yet.
|
||||
Snapshot: workspace `0.1.0`, 2026-11-20. See ADR-0021.
|
||||
|
||||
This report records what was actually probed on the development host and why no
|
||||
`StrictIsolation::Available` claim is made. It is evidence, not a plan to
|
||||
weaken the gate.
|
||||
This report separates three things that are often conflated:
|
||||
|
||||
## 1. Host and capability probe
|
||||
1. the **mechanism** (Bubblewrap namespaces + rlimits + supervisor),
|
||||
2. the **runtime probe** that decides whether `strict` is available, and
|
||||
3. the **adversarial evidence** that the boundary actually holds.
|
||||
|
||||
Command output (abridged; host name removed):
|
||||
## 1. Why the earlier host could not pass
|
||||
|
||||
The first development host was a root-in-container environment:
|
||||
|
||||
```text
|
||||
user: uid=0(root) gid=0(root)
|
||||
kernel: Linux 7.0.0-43-generic x86_64
|
||||
virt: container-other
|
||||
apparmor_restrict_unprivileged_userns: 1
|
||||
max_user_namespaces: 60339
|
||||
cgroup2 mount: ro,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot
|
||||
cgroup controllers: cpuset cpu io memory hugetlb pids rdma misc dmem
|
||||
unshare --user --map-root-user true
|
||||
-> unshare: write failed /proc/self/uid_map: Operation not permitted (exit 1)
|
||||
unshare --user --map-root-user --net true
|
||||
-> unshare: unshare failed: Operation not permitted (exit 1)
|
||||
bwrap --unshare-user --unshare-net --ro-bind / / true
|
||||
-> bwrap: No permissions to create a new namespace (exit 1)
|
||||
sudo -n true
|
||||
-> sudo: The "no new privileges" flag is set, which prevents sudo from
|
||||
running as root (exit 1)
|
||||
capsh --print
|
||||
-> Current: = (no effective capabilities)
|
||||
-> Bounding set = cap_sys_admin, ... (not effective; no-new-privs=1)
|
||||
unshare --mount true / --pid --fork true / --net true
|
||||
-> Operation not permitted (exit 1 each)
|
||||
capsh: Current: = (no effective capabilities), no-new-privs=1
|
||||
unshare --user/--mount/--pid/--net -> Operation not permitted
|
||||
bwrap --unshare-user --unshare-net -> No permissions to create a new namespace
|
||||
cgroup2 -> ro,nosuid,nodev,noexec
|
||||
```
|
||||
|
||||
The workspace root is writable, but the host root filesystem and cgroup2 mount
|
||||
are read-only. The process is root inside a container with `no_new_privs` set;
|
||||
`sudo` cannot gain privileges and the parent container refuses namespace
|
||||
creation. `user.max_user_namespaces` being non-zero does not help because the
|
||||
container policy/AppArmor boundary rejects the actual `uid_map` write.
|
||||
That environment cannot verify G-C. Strict stayed `Unavailable` there; no
|
||||
adapter was faked.
|
||||
|
||||
## 2. Consequence
|
||||
## 2. Disposable test VM
|
||||
|
||||
- A real Linux adapter (namespaces + seccomp/no_new_privs + cgroup v2 + fd and
|
||||
process-tree control) cannot be built, applied and verified here.
|
||||
- Implementing an adapter and flipping `Available` without executing the escape
|
||||
and resource-limit tests would be a false security claim. It was not done.
|
||||
- `PlatformCapabilities::detect()` continues to report `unavailable` with a
|
||||
reason; `enforce` refuses before any host/plugin is constructed. There is no
|
||||
fallback to `project`.
|
||||
- Native plugin loading (`--trust-native-plugin`) is unrelated to strict mode
|
||||
and remains an explicit in-process trust decision; the broker and worker
|
||||
transport are not OS isolation.
|
||||
A QEMU/TCG Ubuntu 26.04 VM was created from the cloud image (no KVM available
|
||||
on the outer host). Inside the VM:
|
||||
|
||||
Command evidence:
|
||||
|
||||
```bash
|
||||
marqdo run examples/hello.mq.md --mode strict
|
||||
# exit 1, stderr: refusing to run in strict mode: ...
|
||||
marqdo inspect examples/hello.mq.md --platform --json
|
||||
# platform.strict.state == "unavailable"
|
||||
```text
|
||||
OS: Ubuntu 26.04.1 LTS, kernel 7.0.0-43-generic x86_64
|
||||
systemd-detect-virt --container: none
|
||||
user: dev (uid 1000), passwordless sudo for test setup only
|
||||
cgroup2: rw, nsdelegate, controllers: cpuset cpu io memory hugetlb pids rdma misc dmem
|
||||
sysctl: apparmor_restrict_unprivileged_userns = 1
|
||||
bubblewrap: 0.11.1 with the packaged `bwrap-userns-restrict` profile
|
||||
unprivileged: bwrap --unshare-user --unshare-net --ro-bind / / true -> exit 0
|
||||
```
|
||||
|
||||
## 3. What G-C still requires
|
||||
Root can create namespaces, and the packaged Bubblewrap AppArmor profile
|
||||
allows the **ordinary user** to run `bwrap` without disabling AppArmor
|
||||
globally. The released strict mode runs as this ordinary user.
|
||||
|
||||
1. A controllable Ubuntu VM or self-hosted runner that permits user, mount,
|
||||
PID and network namespaces and delegated cgroup v2 controllers, reachable
|
||||
from an ordinary (non-root) test user.
|
||||
2. A trusted supervisor that applies filesystem/network/process/resource
|
||||
policy and reaps the child tree, plus a runtime probe that reports the
|
||||
mechanisms actually applied.
|
||||
3. Execution of the full negative matrix from
|
||||
`docs/STABLE_RELEASE_IMPLEMENTATION.md` §10.5 with a malicious helper:
|
||||
direct syscall reads/writes, `/proc` and inherited-fd access, IPv4/IPv6/DNS
|
||||
and Unix sockets, fork/exec, CPU/memory/fd/process/output limits, and
|
||||
`--trust-native-plugin` rejection.
|
||||
4. A security-lane CI URL on the same commit, and only then an ADR that flips
|
||||
`Unavailable` to `Available` for that specific platform.
|
||||
## 3. Implemented boundary (ADR-0021)
|
||||
|
||||
Until all four hold, any release must state: **strict OS isolation is not
|
||||
available; untrusted code must not be executed with Marqdo expecting isolation.**
|
||||
`marqdo run --mode strict`:
|
||||
|
||||
* probes Bubblewrap at runtime; failure => `Unavailable`, run exits 1, no
|
||||
project code executes;
|
||||
* re-executes the CLI under `bwrap --unshare-all --as-pid-1 --die-with-parent
|
||||
--new-session --cap-drop ALL --clearenv`;
|
||||
* mounts only runtime libraries, `/etc/ld.so.cache`, the program and the
|
||||
project tree read-only at `/project`; private `/proc`, minimal `/dev`,
|
||||
tmpfs `/tmp`;
|
||||
* applies hard rlimits: CPU, 512 MiB address space, 64 fds, 64 processes,
|
||||
8 MiB stack, 0 core, output-byte file size;
|
||||
* supervises wall-clock time and kills the process group;
|
||||
* the child verifies `PID 1`, `NoNewPrivs: 1`, empty `CapEff`, a non-initial
|
||||
uid map and no non-loopback interface before running project code;
|
||||
* rejects Foreign, native/worker plugins, kernels, read/write grants and trace
|
||||
files with exit 2 (strict L1 = pure language + native Math).
|
||||
|
||||
## 4. Adversarial evidence
|
||||
|
||||
The helper is `tests/security/escape_helper.c`, launched through the **same**
|
||||
`marqdo-sandbox` supervisor, not through a separate ad-hoc bwrap command. The
|
||||
lane is `tests/security/run-lane.sh` and the test is
|
||||
`crates/marqdo-sandbox/tests/security_linux.rs`.
|
||||
|
||||
```text
|
||||
7/7 tests PASS:
|
||||
strict_child_identity_is_unprivileged_and_namespaced
|
||||
strict_child_cannot_read_host_files_but_reads_the_project
|
||||
strict_child_cannot_write_outside_or_into_the_project
|
||||
strict_child_cannot_escape_via_proc_or_privileges
|
||||
strict_child_cannot_reach_the_network
|
||||
strict_supervisor_enforces_fd_and_process_limits
|
||||
strict_supervisor_enforces_memory_cpu_and_output_limits
|
||||
```
|
||||
|
||||
Observed results inside the sandbox (ordinary user `dev`):
|
||||
|
||||
| Case | Observation |
|
||||
|---|---|
|
||||
| identity | `uid=1000`, `pid=1`, `NoNewPrivs: 1`, `CapEff: 0` |
|
||||
| `/etc/shadow`, `/root`, `/home/dev` | `DENIED` |
|
||||
| `/project/allowed.txt` | `OK` |
|
||||
| write `/home/dev/...`, `/project/...` | `DENIED` (read-only) |
|
||||
| write `/tmp` | allowed (private tmpfs; host unaffected) |
|
||||
| `/proc/1/root/etc/shadow` | `DENIED`; no inherited fds above stdio |
|
||||
| `setuid(0)`, `mount`, `unshare` | `DENIED` |
|
||||
| IPv4 connect `1.1.1.1:80`, raw socket | `DENIED` |
|
||||
| open `/dev/null` loop | `EMFILE` at <= 64 fds |
|
||||
| fork loop | bounded below 200 (user process rlimit) |
|
||||
| 768 MiB allocation | 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 evidence (`dev`, VM):
|
||||
|
||||
```text
|
||||
run examples/hello.mq.md --mode strict -> 你好,Marqdo (exit 0)
|
||||
call factorial 阶乘 --arg n=5 --mode strict -> 120 (exit 0)
|
||||
run examples/multi-module/index.mq.md --mode strict -> 12.566... (exit 0)
|
||||
run --mode strict --json -> success=true
|
||||
run --mode strict --allow-foreign -> exit 2
|
||||
run --mode strict --trust-native-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 (not PID 1)
|
||||
hide /usr/bin/bwrap; run --mode strict -> exit 1 (not installed)
|
||||
```
|
||||
|
||||
## 5. Explicit non-goals / remaining work
|
||||
|
||||
* Strict **L2** (Worker/Foreign inheriting the sandbox) is not implemented;
|
||||
those flags are refused in strict. Native ABI is never allowed in strict.
|
||||
* rlimits are used instead of cgroup-v2 accounting; the adapter does not claim
|
||||
cgroup enforcement.
|
||||
* Filesystem TOCTOU is reduced by read-only mounts but not formally proven
|
||||
against a racing host user.
|
||||
* Network is denied by a network namespace, not a seccomp allowlist.
|
||||
* **A remote security-lane CI URL is still required** before a release calls
|
||||
G-C CI-verified. `.github/workflows/security-linux.yml` targets a dedicated
|
||||
self-hosted runner; `MARQDO_REQUIRE_STRICT_SECURITY=1` makes missing
|
||||
mechanisms fail instead of skip.
|
||||
Reference in new issue
Block a user