Reject sandbox tests when Bubblewrap never starts
Why: Home and sibling isolation tests could pass after a Bubblewrap startup failure, hiding an untested security boundary. Evidence: Isolated fake-Bubblewrap replay changed both target tests from PASS to FAIL; SELF receipt /tmp/dependency-task1-fake-green-20261014-01a1345f.json. Native positive replay remains NOT_RUN. Impact: Test assertions only; production execution behavior is unchanged. Refs: Backend PR #196; Documents design 1790cf8
This commit is contained in:
@@ -137,13 +137,13 @@ func TestSandboxHomeHidden(t *testing.T) {
|
||||
t.Skipf("cannot create home fixture: %v", err)
|
||||
}
|
||||
defer os.Remove(secret)
|
||||
out, state := sandboxRun(t, "cat \"$HOME/.agent-ext16-marker\" 2>err.txt; cat err.txt; exit 7", 30*time.Second)
|
||||
out, state := sandboxRun(t, "cat \"$HOME/.agent-ext16-marker\" 2>err.txt; cat err.txt; echo SANDBOX_SCRIPT_RAN; exit 7", 30*time.Second)
|
||||
if state != "exit=7" || !strings.Contains(out, "SANDBOX_SCRIPT_RAN") {
|
||||
t.Fatalf("sandbox script did not run: state=%s out=%q", state, out)
|
||||
}
|
||||
if strings.Contains(out, "topsecret") {
|
||||
t.Fatalf("sandbox read real home secret (state=%s out=%q)", state, out)
|
||||
}
|
||||
if state == "exit=0" || state == "exit=7" && strings.Contains(out, "topsecret") {
|
||||
t.Fatalf("unexpected success: state=%s out=%q", state, out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSandboxSiblingSessionUnreadable(t *testing.T) {
|
||||
@@ -164,7 +164,7 @@ func TestSandboxSiblingSessionUnreadable(t *testing.T) {
|
||||
defer cancel()
|
||||
var buf bytes.Buffer
|
||||
spec := ExecSpec{
|
||||
Bin: "/bin/bash", Args: []string{"-c", "cat '" + marker + "'"}, Dir: a,
|
||||
Bin: "/bin/bash", Args: []string{"-c", "cat '" + marker + "' 2>&1; echo SANDBOX_SCRIPT_RAN; exit 7"}, Dir: a,
|
||||
Env: []string{"PATH=/usr/bin:/bin", "HOME=/home/agent"},
|
||||
}
|
||||
proc, err := sandboxBackend{}.Start(ctx, spec, &buf)
|
||||
@@ -172,7 +172,11 @@ func TestSandboxSiblingSessionUnreadable(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
werr := proc.Wait()
|
||||
if werr == nil || buf.String() == "others-data" {
|
||||
exit, ok := werr.(*exec.ExitError)
|
||||
if !ok || exit.ExitCode() != 7 || !strings.Contains(buf.String(), "SANDBOX_SCRIPT_RAN") {
|
||||
t.Fatalf("sandbox script did not run: wait=%v out=%q", werr, buf.String())
|
||||
}
|
||||
if strings.Contains(buf.String(), "others-data") {
|
||||
t.Fatalf("sibling session readable inside sandbox: wait=%v out=%q", werr, buf.String())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user