Skip to content

Commit ab848fe

Browse files
committed
validate-bundle: report which vantage sources a bundle carries
A bundle missing proc/self/status degrades the analysis silently: the identity reports as unknown, and a bundle carrying none of the container markers reports "Container: none", which is also the answer for a host that is not containerized. Nothing distinguished a source that answered from one the bundle never held. The tool now lists the five vantage sources with what each absence costs. Presence is checked on the field rather than the file, since a status file stripped of its Uid: line degrades exactly as a missing one does. Container detection reads four sources and concludes from all of them, so that line asks whether any of them was captured. None of this moves an inferred range, so a missing source is reported rather than failed and the exit status is unchanged.
1 parent 9aec195 commit ab848fe

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

docs/reproducibility.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ kernel's real symbol addresses. `validate-bundle` runs the matching `kasld` bina
6868
over that bundle offline and checks every inferred range against the captured
6969
ground truth. It exits non-zero if any range excludes the truth. No root needed.
7070

71+
It also lists which vantage sources the bundle carries — the collecting
72+
process's identity, its MAC label, the active LSM list, the group database, and
73+
the container markers. Those do not affect an inferred range, so a missing one
74+
is reported rather than failed; it is reported at all because its absence is
75+
silent in the analysis, where an unread source and an empty answer both present
76+
as "unknown".
77+
7178
`--kallsyms` can only record the ground truth when kallsyms is readable
7279
(`kptr_restrict=0`, or root). Without it the bundle carries no truth and the
7380
checks report `N/A` rather than `PASS` — still not a failure, just nothing to

extra/validate-bundle

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,66 @@ else
392392
fi
393393
echo
394394

395+
# ---------------------------------------------------------------------------
396+
# Vantage completeness.
397+
#
398+
# Not a soundness check, and deliberately not counted: a missing vantage source
399+
# does not move an inferred range. It is reported because its absence is SILENT
400+
# in the analysis -- kasld says "unknown", or in the container line "none", and
401+
# a reader has no way to tell a source that answered from one the bundle never
402+
# carried. Which is the same question the bundle exists to settle for the
403+
# layout, asked about the observer.
404+
#
405+
# Presence of the FIELD, not just the file: a status file stripped of its Uid:
406+
# line degrades exactly as a missing one does, and a bundle assembled by hand
407+
# (or scrubbed harder than extra/collect scrubs) is where that happens.
408+
# ---------------------------------------------------------------------------
409+
SR=$BUNDLE/sysroot
410+
411+
vant_have() { printf ' %-13s %s%s%s\n' "$1" "$GREEN" "$2" "$RESET"; }
412+
vant_miss() { printf ' %-13s %s(absent) %s%s\n' "$1" "$YELLOW" "$2" "$RESET"; }
413+
414+
printf '%sVantage sources:%s\n' "$BOLD" "$RESET"
415+
416+
if [ -s "$SR/proc/self/status" ] && grep -q '^Uid:' "$SR/proc/self/status"; then
417+
vu=$(awk '$1 == "Uid:" { print $2 }' "$SR/proc/self/status")
418+
vg=$(awk '$1 == "Gid:" { print $2 }' "$SR/proc/self/status")
419+
ng=$(awk '$1 == "Groups:" { print NF - 1 }' "$SR/proc/self/status")
420+
vant_have identity "uid=${vu:-?} gid=${vg:-?}, ${ng:-0} group(s)"
421+
else
422+
vant_miss identity "— the report cannot name the uid, gid or groups it ran as"
423+
fi
424+
425+
if [ -s "$SR/proc/self/attr/current" ]; then
426+
vant_have "mac label" "$(tr -d '\0\n' < "$SR/proc/self/attr/current")"
427+
else
428+
vant_miss "mac label" "— no security context row"
429+
fi
430+
431+
if [ -s "$SR/sys/kernel/security/lsm" ]; then
432+
vant_have "lsm list" "$(tr -d '\0\n' < "$SR/sys/kernel/security/lsm")"
433+
else
434+
vant_miss "lsm list" "— LSM reports as unknown, which is not 'no LSM'"
435+
fi
436+
437+
if [ -s "$SR/etc/group" ]; then
438+
vant_have "group names" "$(grep -c ':' "$SR/etc/group") entries"
439+
else
440+
vant_miss "group names" "— gids report by number unless kasld gates on them"
441+
fi
442+
443+
# Container detection reads four sources and concludes from ALL of them; a
444+
# bundle carrying none of them reports "Container: none", which is the answer
445+
# for a host that is not containerized. Absence is the misleading case here,
446+
# so the line is about the SET, not any one file.
447+
if [ -e "$SR/.dockerenv" ] || [ -e "$SR/run/.containerenv" ] ||
448+
[ -s "$SR/proc/self/cgroup" ] || [ -s "$SR/proc/1/cgroup" ]; then
449+
vant_have container "detectable from the captured markers/cgroups"
450+
else
451+
vant_miss container "— reports 'none', indistinguishable from not captured"
452+
fi
453+
echo
454+
395455
# ---------------------------------------------------------------------------
396456
# Pull engine-resolved ranges from JSON.
397457
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)