eBPF-based security platform
status: report a frozen keyring that is gone as tampered
Daniel Borkmann5a69550491fe
diff --git a/Documentation/operations.rst b/Documentation/operations.rstindex 0430495d..fcaa918c 100644--- a/Documentation/operations.rst+++ b/Documentation/operations.rst@@ -95,9 +95,8 @@ Conditions* - ``KeyringSealed``- ``WARN`` while staging or before ``init``; ``ALERT`` whenthe live keyring is not the one ``init`` froze into the- identity map (a swapped keyring: every load refuses- ``tampered``). The detail names the kind of keyring,- ``bpf`` or ``user``.+ identity map or is gone (every load refuses ``tampered``).+ The detail names the kind of keyring, ``bpf`` or ``user``.* - ``ChainIntact``- ``ALERT`` when replaying this boot's eventlog does notreproduce the live register: something extended it thatdiff --git a/testing/t0050-conditions.sh b/testing/t0050-conditions.shindex 19befd55..8fc461db 100755--- a/testing/t0050-conditions.sh+++ b/testing/t0050-conditions.sh@@ -4,7 +4,7 @@## t0050 -- util/conditions.c: the KeyringSealed condition names the kind# of keyring the anchor is in, and a keyring other than the one init-# froze makes the status tampered.+# froze, or none where it froze one, makes the status tampered.cd "$(dirname "$0")". ./test-lib.sh@@ -41,4 +41,26 @@ test_expect_success 'a swapped keyring is tampered' 'echo "$out" | grep -qx "KeyringSealed ALERT pin serial=100 != live serial=101 (swapped?)"'+test_expect_success 'a frozen user keyring that is gone is tampered' '+ out=$(./$H 1 user -1 200 match) &&+ echo "$out" | grep -qx "status=tampered" &&+ echo "$out" | grep -qx "reason=the keyring init froze is gone" &&+ echo "$out" | grep -qx "KeyringSealed ALERT pin serial=200, the user keyring is gone (removed?)"+'++test_expect_success 'a frozen bpf keyring that is gone is tampered' '+ out=$(./$H 1 bpf -1 100 match) &&+ echo "$out" | grep -qx "status=tampered" &&+ echo "$out" | grep -qx "KeyringSealed ALERT pin serial=100, the bpf keyring is gone (removed?)"+'++test_expect_success 'with the LSM off a gone keyring is still tampered' '+ ./$H 0 user -1 200 none | grep -qx "status=tampered"+'++test_expect_success 'a register mismatch is the reason given first' '+ ./$H 1 user -1 200 mismatch |+ grep -qx "reason=live register != eventlog replay"+'+test_donediff --git a/util/conditions.c b/util/conditions.cindex 3a9e5fba..bba2f360 100644--- a/util/conditions.c+++ b/util/conditions.c@@ -33,7 +33,13 @@ size_t conditions(const struct shirudo_conditions_input *in,"bpf" : "user";c[n].type = "KeyringSealed";- if (!in->keyring_present) {+ if (!in->keyring_present && in->ksp_seen) {+ c[n].status = "ALERT";+ snprintf(c[n].detail, sizeof(c[n].detail),+ "pin serial=%lld, the %s keyring is gone "+ "(removed?)",+ (__s64)in->keyring_serial_pinned, kind);+ } else if (!in->keyring_present) {c[n].status = "WARN";snprintf(c[n].detail, sizeof(c[n].detail),"shirudo keyring absent (not init'd?)");@@ -114,7 +120,8 @@ const char *status_verdict(const struct shirudo_conditions_input *in)if (!in->parsed)return "unparseable";if ((in->cm_seen && !in->chain_matches) ||- (in->ksm_seen && !in->keyring_serial_matches))+ (in->ksm_seen && !in->keyring_serial_matches) ||+ (in->ksp_seen && !in->keyring_present))return "tampered";if (!in->lsm_attached)return "lsm-off";@@ -139,6 +146,8 @@ void status_reason(const struct shirudo_conditions_input *in,} else if (strcmp(v, "tampered") == 0) {if (in->cm_seen && !in->chain_matches)snprintf(buf, cap, "live register != eventlog replay");+ else if (!in->keyring_present)+ snprintf(buf, cap, "the keyring init froze is gone");elsesnprintf(buf, cap, "keyring serial swap detected");} else if (strcmp(v, "lsm-off") == 0) {