carlos / platform Public

host: the isolation witness diagnoses a grant that does not reach a running unit (#328)

Run 20261025T173335-926c1c: root wrote app B's grant (the slice read
back 10.0.5.20/32) but B reached the address only after a restart. B ran
through the probe's parent write (allowResolvers), which no earlier
witness did. The failure path now logs discriminators, leaving every
assertion as it was: a third app started after the parent writes and
granted while running; app A revoked on the live branch after the
parent write; a further parent write; a write on B's own unit; then
the restart probe.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev df526b30ec7b2c5d6a435cbe76ee148bb8acab8c parent 1e4d850
1 file changed, +85 −2
  • internal/host/egress_startpaths_rootrunner_linux_test.go +85 −2
diff --git a/internal/host/egress_startpaths_rootrunner_linux_test.go b/internal/host/egress_startpaths_rootrunner_linux_test.go
index 0a6df832b..fafc83028 100644
--- a/internal/host/egress_startpaths_rootrunner_linux_test.go
+++ b/internal/host/egress_startpaths_rootrunner_linux_test.go
@@ -637,9 +637,11 @@ func (w *egressUnderClaimsWitness) check(t *testing.T, egress func(host string)
// carlos-egr1.
func TestRootEgressIsolation(t *testing.T) {
other := egressOtherHost{host: "shop-b.example.com", app: "shop-b"}
+ // A third app, started only by egressGrantNotLiveDiag.
+ third := egressOtherHost{host: "shop-c.example.com", app: "shop-c"}
b := newEgressPreClaimBoxWith(t, egressBoxOptions{
netns: egressNetnsNames{ns: "carlos-egr2", hostLink: "carlos-egr2", nsLink: "carlos-egr2n"},
- others: []egressOtherHost{other},
+ others: []egressOtherHost{other, third},
probe: true,
})
ctx := t.Context()
@@ -743,7 +745,7 @@ func TestRootEgressIsolation(t *testing.T) {
t.Fatal("POST /egress (app B):", err)
}
if !egressWithin(t, time.Now().Add(egressLiveBound), bc, true, target) {
- egressFirewallDiag(t, otherUnit, otherSlice, bc, target)
+ egressGrantNotLiveDiag(t, b, other, third, a, bc, target)
t.Fatal("app B, granted, cannot reach 10.0.5.20: its refusal above may not have been the fence")
}
if got := egressShow(t, otherSlice, "IPAddressAllow"); got != "10.0.5.20/32" {
@@ -907,3 +909,84 @@ func egressCoveringPrefixes(t *testing.T, list string) []string {
slices.Sort(out)
return out
}
+
+// egressGrantNotLiveDiag runs when app B's grant, written by the
+// production asserter while B runs, did not reach B (run
+// 20261025T173335-926c1c: the slice read back 10.0.5.20/32, B reached it
+// only after a restart). It changes no assertion: each step logs one
+// "discriminator:" verdict, so one run tells which condition keeps a
+// slice write from a running unit, and whether the live revoke branch
+// (a parent allow, no restart) is affected too. In order:
+//
+// 1. B's GET /egress report;
+// 2. app C, started now (after both probe runs, so no parent write
+// while it ran; its slice empty at start under the parent's resolver
+// allow), then granted through POST /egress: is that grant live?
+// 3. app A, which ran through the probe's second parent write, revoked
+// through POST /egress (parent allow present: the live branch, no
+// restart): does it close within 2 s?
+// 4. the probe's parent write again (Server.RunProbe): does that open B?
+// 5. a write on B's own unit (set-property IPAddressAllow=, its own list
+// stays empty): does that open B?
+// 6. egressFirewallDiag: B's properties, then a restart and a probe.
+func egressGrantNotLiveDiag(t *testing.T, b *egressBox, other, third egressOtherHost, a, bc *http.Client, target string) {
+ t.Helper()
+ ctx := t.Context()
+ otherUnit := instancectl.UnitName(instancectl.RoleRun, other.host)
+ otherSlice := instancectl.SliceName(other.host)
+ verdict := func(question string, live bool) { t.Logf("discriminator: %s: %v", question, live) }
+
+ t.Logf("discriminator: B's GET /egress after its grant: %+v", egressHostReport(t, b, other.host))
+
+ thirdUnit := instancectl.UnitName(instancectl.RoleRun, third.host)
+ if _, err := b.client.Start(ctx, third.host, instancectl.RoleRun, cgroup.TierDefault.MemoryMax); err != nil {
+ t.Logf("discriminator: POST /start (app C): %v\n%s", err, egressJournal(thirdUnit))
+ } else {
+ cc := egressTenantClient(filepath.Join(provision.InstanceRunDir(third.host), "run.sock"))
+ egressServing(t, thirdUnit, cc)
+ t.Logf("discriminator: app C before its grant reaches 10.0.5.20: %v", egressReach(t, cc, target))
+ if err := b.reg.SetPolicy(third.host, "10.0.5.20", "", egressExpiry()); err != nil {
+ t.Fatal(err)
+ }
+ if err := b.client.Egress(ctx, third.host); err != nil {
+ t.Logf("discriminator: POST /egress (app C): %v", err)
+ }
+ verdict("app C, started after the probe's parent writes, granted while running, reaches 10.0.5.20 within 2 s",
+ egressWithin(t, time.Now().Add(egressLiveBound), cc, true, target))
+ t.Logf("discriminator: app C's slice: %q, report %+v", egressShow(t, instancectl.SliceName(third.host), "IPAddressAllow"), egressHostReport(t, b, third.host))
+ }
+
+ before := b.runInvocation(t)
+ if err := b.reg.SetPolicy(b.host, "", "", ""); err != nil {
+ t.Fatal(err)
+ }
+ if err := b.client.Egress(ctx, b.host); err != nil {
+ t.Logf("discriminator: POST /egress (app A revoke): %v", err)
+ }
+ verdict("app A, running through the probe's parent write, revoked with a parent allow (live branch), closed within 2 s",
+ egressWithin(t, time.Now().Add(egressLiveBound), a, false, target))
+ t.Logf("discriminator: app A's invocation %s -> %s, slice %q, report %+v", before, b.runInvocation(t), b.allow(t), b.report(t))
+
+ b.srv.RunProbe(ctx)
+ verdict("app B opened by a further parent write (RunProbe) within 2 s", egressWithin(t, time.Now().Add(egressLiveBound), bc, true, target))
+
+ dropIns := filepath.Join("/run/systemd/system.control", otherUnit+".d")
+ if _, err := os.Lstat(dropIns); errors.Is(err, fs.ErrNotExist) {
+ t.Cleanup(func() {
+ if err := os.RemoveAll(dropIns); err != nil {
+ t.Error(err)
+ }
+ if out, err := egressCtl("daemon-reload"); err != nil {
+ t.Errorf("daemon-reload: %v: %s", err, out)
+ }
+ })
+ if out, err := egressCtl("set-property", "--runtime", otherUnit, "IPAddressAllow="); err != nil {
+ t.Logf("discriminator: set-property %s: %v: %s", otherUnit, err, out)
+ }
+ verdict("app B opened by a write on its own unit within 2 s", egressWithin(t, time.Now().Add(egressLiveBound), bc, true, target))
+ } else {
+ t.Logf("discriminator: %s already has drop-ins (%v); step 5 skipped", otherUnit, err)
+ }
+
+ egressFirewallDiag(t, otherUnit, otherSlice, bc, target)
+}