fix(worker): security audit of R0 — no core dumps, tkill/tgkill limited to SIGABRT on self, mmap without PROT_EXEC, Broken outcome for a broken child environment, frame vs canvas check, unsafe denied with local allows, sandbox tests and derivation on the release profile (syscall marker); wasm proof exports behind a feature; ci: release-images hardened (typed input via env, advisories gate, ephemeral builder, env secrets + logout, ref gate, pinned checkout)

This commit is contained in:
bchanot committed 2026-10-13 00:18:53 +02:00
1 parent 9d3e0294e2
commit 11813f5560
14 files changed
+293 -58

No files matched your search

+17 -4
View File
@@ -17,8 +17,12 @@ use crate::{exit_codes, webp_check};
pub enum ChildOutcome {
/// A 512 × 512 WebP whose container passed the parent's check.
Produced(Vec<u8>),
/// The child refused the input with one of its exit codes.
/// The child refused the input with one of its content exit codes (12 to 17).
Rejected { code: i32, name: &'static str },
/// The child could not even start properly (usage, non-empty environment, sandbox
/// failure, internal error): the confinement environment is broken, not the upload.
/// R1 alerts and stops on this outcome instead of rejecting the job.
Broken { code: i32, name: &'static str },
/// The child died from a signal (SIGSYS 31 = seccomp, SIGABRT 6 = allocation failure,
/// SIGXCPU 24 = CPU limit, SIGKILL 9 = the parent).
Signalled { signal: i32 },
@@ -30,7 +34,8 @@ pub enum ChildOutcome {
Failed(String),
}
/// A finished child run.
/// A finished child run. `stderr` is text the child controls (up to 4 KiB): never logged
/// raw by R1, control characters escaped and the field allowlist applied (LRN-044).
#[derive(Debug)]
pub struct ChildRun {
pub outcome: ChildOutcome,
@@ -124,7 +129,11 @@ impl Spawner {
}
std::thread::sleep(Duration::from_millis(20));
}
Err(error) => return failed(format!("wait: {error}")),
Err(error) => {
let _ = child.kill();
let _ = child.wait();
return failed(format!("wait: {error}"));
}
}
};
let _ = writer.join();
@@ -150,7 +159,11 @@ fn classify(status: ExitStatus, output: Vec<u8>) -> ChildOutcome {
Ok(_) => ChildOutcome::Produced(output),
Err(issue) => ChildOutcome::Failed(format!("output refused: {issue}")),
},
Some(code) => ChildOutcome::Rejected {
Some(code) if exit_codes::is_content_rejection(code) => ChildOutcome::Rejected {
code,
name: exit_codes::name(code),
},
Some(code) => ChildOutcome::Broken {
code,
name: exit_codes::name(code),
},