eBPF-based security platform
attest: take a config history past json_parse()'s bounds as malformed
Daniel Borkmannc5390ebd8857
diff --git a/testing/functional/tpm/t4004-config-attest.sh b/testing/functional/tpm/t4004-config-attest.shindex 430eb5ab..d65a3a05 100755--- a/testing/functional/tpm/t4004-config-attest.sh+++ b/testing/functional/tpm/t4004-config-attest.sh@@ -160,6 +160,14 @@ for document in "$WORK"/bad-*.json; do'done+test_expect_success 'a config string longer than its field is a malformed document' '+ status=0 &&+ verify "$WORK/bad-trailing-root.json" >/dev/null \+ 2>"$WORK/trailing-root-err" || status=$? &&+ test "$status" -eq 2 &&+ grep -q "is not a shirudo evidence document" "$WORK/trailing-root-err"+'+test_expect_success 'an inconsistent config history names the check it fails' '! verify "$WORK/bad-reordered.json" >"$WORK/reordered-report" 2>/dev/null &&grep -qx " FAIL config: the events are one boot event followed by updates in sequence" \diff --git a/util/attest.c b/util/attest.cindex 885c2b33..59624d94 100644--- a/util/attest.c+++ b/util/attest.c@@ -918,6 +918,9 @@ static int evidence_parse_config(struct verify *v, const char *evidence,ret = config_evidence_parse(evidence, len, &v->config);if (ret == -EKEYREJECTED)say(&v->rep, false, "config: the events are one boot event followed by updates in sequence");+ /* What json_parse() refuses past a bound is a malformed document. */+ if (ret == -E2BIG || ret == -ENOSPC)+ ret = -EINVAL;return ret;}