fix(sandbox): add platform-neutral strict child inspection
ci/woodpecker/push/woodpecker Pipeline was successful
CI / schema instance validation + consumers (push) Canceled after 0s
CI / runtime contract (macos-latest) (push) Canceled after 0s
CI / runtime contract (windows-latest) (push) Canceled after 0s
CI / release candidate artifact (macos-latest) (push) Canceled after 0s
CI / release candidate artifact (ubuntu-latest) (push) Canceled after 0s
CI / fmt + clippy + test (Linux x86_64) (push) Canceled after 0s

The CLI referenced Linux-only marker_present/verify_active directly, so
macOS and Windows builds failed with E0425. Add StrictChildState and
inspect_strict_child() to marqdo-sandbox: Linux performs the full identity
verification, while every other platform rejects even a forged
MARQDO_STRICT_ACTIVE marker. The Linux-only functions are no longer
re-exported from the crate root, so future callers cannot bypass the
platform boundary.

This is step 1 of the CI/security RFC (B01).
This commit is contained in:
cflmy committed 2026-11-21 16:36:49 +08:00
1 parent 32d8fe1f7a
commit f4a404bae9
3 files changed
+95 -28

No files matched your search

+3 -6
View File
@@ -30,9 +30,6 @@ use std::time::{Duration, Instant};
use crate::{SandboxError, StrictHostCommand};
/// Environment variable that marks a re-executed strict child.
pub const ACTIVE_ENV: &str = "MARQDO_STRICT_ACTIVE";
/// Path of the program inside the sandbox.
const SANDBOX_PROGRAM: &str = "/run/marqdo-program";
@@ -158,7 +155,7 @@ fn common_args() -> Vec<OsString> {
/// Verify that this process really is the strict child created by [`launch`].
pub fn verify_active() -> Result<(), String> {
if std::env::var(ACTIVE_ENV).ok().as_deref() != Some("1") {
if std::env::var(crate::STRICT_ACTIVE_ENV).ok().as_deref() != Some("1") {
return Err("strict active marker is absent".to_string());
}
// `--as-pid-1` makes the supervised program PID 1 in its own PID namespace.
@@ -204,7 +201,7 @@ pub fn verify_active() -> Result<(), String> {
/// Whether the current process claims to be a strict child. The marker alone
/// is not trusted; callers must use [`verify_active`].
pub fn marker_present() -> bool {
std::env::var(ACTIVE_ENV).ok().as_deref() == Some("1")
std::env::var(crate::STRICT_ACTIVE_ENV).ok().as_deref() == Some("1")
}
/// Result of one supervised strict execution.
@@ -335,7 +332,7 @@ fn run_with(
command.program.as_os_str().to_os_string(),
OsString::from(SANDBOX_PROGRAM),
OsString::from("--setenv"),
OsString::from(ACTIVE_ENV),
OsString::from(crate::STRICT_ACTIVE_ENV),
OsString::from("1"),
OsString::from("--chdir"),
OsString::from("/project"),