eBPF-based security platform
backend: let the operator enroll a node's key
John Fastabend7fc622825dd3
diff --git a/Documentation/contribute/testing/test-coverage.rst b/Documentation/contribute/testing/test-coverage.rstindex 00bd1e47..97eb0d3b 100644--- a/Documentation/contribute/testing/test-coverage.rst+++ b/Documentation/contribute/testing/test-coverage.rst@@ -869,8 +869,9 @@ Backend testsThe SQL tests of :src:`tools/backend/test/` cover the backend's schemaagainst a ClickHouse container (:ref:`testing-backend`): the quote-check of every record and the reasons a record is refused, each status-check and the history it reads, ``node_vulns`` and its inputs, the+check of every record and the reasons a record is refused, a key's+trust from ``untrusted`` to ``enrolled``, each status check and the+history it reads, ``node_vulns`` and its inputs, theretention script and the views that keep boot baselines, the treeingest job on a single publication and on a walk over sealed segments,and the SBOM scan job on a store that holds an image in every state.diff --git a/Documentation/operate/integrations/backend.rst b/Documentation/operate/integrations/backend.rstindex f8cd6779..18b6445d 100644--- a/Documentation/operate/integrations/backend.rst+++ b/Documentation/operate/integrations/backend.rst@@ -50,8 +50,10 @@ What it doesoperator package, :doc:`/reference/cli/quote-check` and:doc:`/reference/cli/bpm` describe them. A pass of the quote check saysthat the body is what one key signed, not that the key lives in a-genuine TPM, so every node reads ``untrusted``, nor that the body is-true: root on a target can have its TPM quote a body of its own, so+genuine TPM, so every node reads ``untrusted`` until you enroll its key+(:doc:`backend/maintain`) and insert ``enrolled`` for its ``ak_name``+into ``shirudo.nodes``. Neither says that the body is true: root on a+target can have its TPM quote a body of its own, so``healthy`` is the target's own account until ``shirudo attest verify``confirms it (R17 of :doc:`/security/threat-model`).diff --git a/Documentation/operate/integrations/backend/maintain.rst b/Documentation/operate/integrations/backend/maintain.rstindex 13755dd8..c0026f01 100644--- a/Documentation/operate/integrations/backend/maintain.rst+++ b/Documentation/operate/integrations/backend/maintain.rst@@ -30,12 +30,27 @@ Check 3 fails a node whose ``version_id`` is not listed:INSERT INTO shirudo.expected_builds (version_id, note) VALUES ('<version_id>', 'shirudo 2026.11');-Node trust-----------+Enroll a node+-------------++Every node starts ``untrusted``: a keepalive proves that one key signed+each record, not what hardware holds the key. Once you know the key+lives in a TPM, from credential activation (``shirudo attest verify+--expect-credential`` passed) or from the records of the builder that+created the TPM's keys, raise it:++.. code-block:: sql++ INSERT INTO shirudo.nodes (ak_name, trust) VALUES ('<ak_name>', 'enrolled');-Every node is ``untrusted``: a keepalive proves that one key signed each-record, not what hardware holds the key. Nothing in the backend raises-``trust``.+The row may come before the node's first record, as it does when a+builder hands you the name before the node boots. It changes nothing+but ``trust``, and no row lowers it again: a key that is no longer+trusted, such as one whose TPM was replaced, shows up under a new+``ak_name``, which starts ``untrusted``. ``enrolled`` says who signed,+not that what they signed is true: a node's root can have its TPM quote+a body of its own, so only ``shirudo attest verify`` confirms its+state.Rename a node-------------diff --git a/Documentation/operate/integrations/backend/status.rst b/Documentation/operate/integrations/backend/status.rstindex 60645c39..fed448e2 100644--- a/Documentation/operate/integrations/backend/status.rst+++ b/Documentation/operate/integrations/backend/status.rst@@ -71,7 +71,7 @@ A UI reads ``node_status`` as often as it likes:* - ``status``- ``stale``, ``unhealthy`` or ``healthy``, see below.* - ``trust``- - The node's ``trust`` from ``shirudo.nodes``, ``untrusted`` for every node. It is never part of ``status``: a healthy node is one whose records are consistent and match the tree, a trusted one would be one whose key is known to live in a TPM. Show both.+ - The node's ``trust`` from ``shirudo.nodes``: ``untrusted``, or ``enrolled`` once the operator has recorded its key as a TPM's (:doc:`maintain`). It is never part of ``status``: a healthy node is one whose records are consistent and match the tree, an enrolled one is one whose key is known to live in a TPM. Show both.* - ``failed_check``- The first check that failed: 2 for ``stale``, 3 to 7 for ``unhealthy``, 0 for ``healthy``.* - ``log``diff --git a/Documentation/operate/integrations/backend/tables/reference.rst b/Documentation/operate/integrations/backend/tables/reference.rstindex ed41b364..ce00f153 100644--- a/Documentation/operate/integrations/backend/tables/reference.rst+++ b/Documentation/operate/integrations/backend/tables/reference.rst@@ -49,14 +49,16 @@ shirudo.nodes- To relabel, insert argMinState('<name>', toDateTime64(0, 3)) for theak_name. Epoch 0 wins argMin. Leave ak_public and first_seen out sothey don't change.- - trust only ever rises, and nothing sets it above untrusted today. It is- shown but never part of status.+ - trust only ever rises. The operator inserts (ak_name, 'enrolled') once+ credential activation or a builder's records show the key is a TPM's,+ before or after the node's first record. It is shown but never part+ of status.:ak_name: Node identity.:ak_public: Public area of the key.:node_id: Label: the host name the key claimed first, unless relabeled.:first_seen: First accepted record.- :trust: Defaults to untrusted.+ :trust: untrusted by default, enrolled once the operator records the key.shirudo.expected_builds-----------------------diff --git a/Documentation/reference/cli/quote-check.rst b/Documentation/reference/cli/quote-check.rstindex 6472c927..ca6cb8e2 100644--- a/Documentation/reference/cli/quote-check.rst+++ b/Documentation/reference/cli/quote-check.rst@@ -160,8 +160,10 @@ with the row from the node, so its attributes are what the nodedeclares, and a software P-256 key can carry the same bits (U1 of:doc:`/security/threat-model`). That a key is a TPM's comes only fromcredential activation, :doc:`attest-challenge` and ``shirudo attest---challenge``, and from pinning its name in :doc:`attest-verify`; a-backend treats every node as ``untrusted`` until it has done that (R17).+--challenge``, or from the records of the builder that created it, and+from pinning its name in :doc:`attest-verify`; a backend treats every+node as ``untrusted`` until the operator records it as ``enrolled``+(R17).Output------diff --git a/tools/backend/sql/20-reference.sql b/tools/backend/sql/20-reference.sqlindex 9624993d..98ffe1ea 100644--- a/tools/backend/sql/20-reference.sql+++ b/tools/backend/sql/20-reference.sql@@ -9,15 +9,17 @@-- claimed; to relabel a node, insert argMinState('<name>',-- toDateTime64(0, 3)) for its ak_name, which is why a row that leaves-- ak_public and first_seen out must not change them. trust only ever--- rises: a keepalive never sets it, so a node stays untrusted until--- something else says more.+-- rises: a keepalive never sets it, so a node stays untrusted until the+-- operator inserts enrolled for its ak_name, once credential activation+-- or a builder's records have shown that the key lives in a TPM. The+-- row may come before the node's first record.CREATE TABLE IF NOT EXISTS shirudo.nodes(ak_name String,ak_public SimpleAggregateFunction(max, String),node_id AggregateFunction(argMin, String, DateTime64(3)),first_seen SimpleAggregateFunction(min, Nullable(DateTime64(3))),- trust SimpleAggregateFunction(max, Enum8('untrusted' = 0)) DEFAULT 'untrusted'+ trust SimpleAggregateFunction(max, Enum8('untrusted' = 0, 'enrolled' = 1)) DEFAULT 'untrusted')ENGINE = AggregatingMergeTreeORDER BY ak_name;diff --git a/tools/backend/sql/40-status.sql b/tools/backend/sql/40-status.sqlindex fa597651..d2685818 100644--- a/tools/backend/sql/40-status.sql+++ b/tools/backend/sql/40-status.sql@@ -262,7 +262,7 @@ CREATE TABLE IF NOT EXISTS shirudo.node_statusak_name String,host_name String,status Enum8('healthy' = 1, 'unhealthy' = 2, 'stale' = 3),- trust Enum8('untrusted' = 0),+ trust Enum8('untrusted' = 0, 'enrolled' = 1),failed_check UInt8,log Array(String),last_seen DateTime64(3),diff --git a/tools/backend/sql/50-vulns.sql b/tools/backend/sql/50-vulns.sqlindex 71f52a2f..f0dd1cdd 100644--- a/tools/backend/sql/50-vulns.sql+++ b/tools/backend/sql/50-vulns.sql@@ -93,7 +93,7 @@ CREATE TABLE IF NOT EXISTS shirudo.node_vulnsak_name String,host_name String,status Enum8('healthy' = 1, 'unhealthy' = 2, 'stale' = 3),- trust Enum8('untrusted' = 0),+ trust Enum8('untrusted' = 0, 'enrolled' = 1),image_id String,image_version String,binding Enum8('verified' = 1, 'declared' = 2, 'root_mismatch' = 3, 'no_sbom' = 4, 'no_image' = 5),diff --git a/tools/backend/test/schema.expected b/tools/backend/test/schema.expectedindex ecc4cb39..647a6460 100644--- a/tools/backend/test/schema.expected+++ b/tools/backend/test/schema.expected@@ -44,12 +44,12 @@ ak_name Stringak_public SimpleAggregateFunction(max, String)node_id AggregateFunction(argMin, String, DateTime64(3))first_seen SimpleAggregateFunction(min, Nullable(DateTime64(3)))-trust SimpleAggregateFunction(max, Enum8(\'untrusted\' = 0))+trust SimpleAggregateFunction(max, Enum8(\'untrusted\' = 0, \'enrolled\' = 1))node_id Stringak_name Stringhost_name Stringstatus Enum8(\'healthy\' = 1, \'unhealthy\' = 2, \'stale\' = 3)-trust Enum8(\'untrusted\' = 0)+trust Enum8(\'untrusted\' = 0, \'enrolled\' = 1)failed_check UInt8log Array(String)last_seen DateTime64(3)@@ -63,7 +63,7 @@ node_id Stringak_name Stringhost_name Stringstatus Enum8(\'healthy\' = 1, \'unhealthy\' = 2, \'stale\' = 3)-trust Enum8(\'untrusted\' = 0)+trust Enum8(\'untrusted\' = 0, \'enrolled\' = 1)image_id Stringimage_version Stringbinding Enum8(\'verified\' = 1, \'declared\' = 2, \'root_mismatch\' = 3, \'no_sbom\' = 4, \'no_image\' = 5)diff --git a/tools/backend/test/trust-enrolled.expected b/tools/backend/test/trust-enrolled.expectednew file mode 100644index 00000000..e8adcf8a--- /dev/null+++ b/tools/backend/test/trust-enrolled.expected@@ -0,0 +1,13 @@+an enrollment row changes only trust+000baa QUtB edge-01 0 enrolled+000bbb QUtC core-01 0 enrolled+000bcc 1 enrolled+000bdd QUtD lab-01 0 untrusted+latest carries trust+000baa edge-01 enrolled+000bbb core-01 enrolled+000bdd lab-01 untrusted+node_status carries trust beside status+000baa unhealthy enrolled 3 1 signed: pass, enrolled, 0 rejected in the last hour+000bbb unhealthy enrolled 3 1 signed: pass, enrolled, 0 rejected in the last hour+000bdd unhealthy untrusted 3 1 signed: pass, untrusted, 0 rejected in the last hourdiff --git a/tools/backend/test/trust-enrolled.sql b/tools/backend/test/trust-enrolled.sqlnew file mode 100644index 00000000..c6ac96a4--- /dev/null+++ b/tools/backend/test/trust-enrolled.sql@@ -0,0 +1,34 @@+-- SPDX-License-Identifier: BSD-2-Clause+-- Copyright (c) 2026 Authors of shirudo+--+-- The operator raises a key to enrolled with one row in shirudo.nodes:+-- before the node's first record, as from a builder's records, or after+-- it, as after credential activation. The row changes neither the+-- node's name nor when it was first seen, a later row cannot lower it,+-- and latest and node_status carry it without it touching status. A key+-- enrolled but never seen is in no view of the nodes' records, and one+-- never enrolled stays untrusted.++INSERT INTO shirudo.nodes (ak_name, trust) VALUES ('000baa', 'enrolled');+INSERT INTO shirudo.nodes (ak_name, trust) VALUES ('000bcc', 'enrolled');++INSERT INTO shirudo.checked (host_name, quote, body, ok, ak_name, ak_public, reset_count, clock) VALUES+('edge-01', 'q1', '{"schema":"shirudo.keepalive/1","boot_id":"9a6f14ea-0cc2-45e1-8e23-7b887120cf54","version_id":"d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f","config_root":null,"kernel_release":"7.4.2","image_id":null,"image_version":null,"image_root":null,"verdict":"init-pending","cond":5465,"flags":8,"tamper":null,"tree_id":null,"generation":null,"base_seq":null,"last_seq":null,"base_root":null,"projection_root":null,"mask":null,"set_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","count":0,"not_ok":0}', 1, '000baa', 'QUtB', 2, 500),+('core-01', 'q2', '{"schema":"shirudo.keepalive/1","boot_id":"9a6f14ea-0cc2-45e1-8e23-7b887120cf54","version_id":"d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f","config_root":null,"kernel_release":"7.4.2","image_id":null,"image_version":null,"image_root":null,"verdict":"init-pending","cond":5465,"flags":8,"tamper":null,"tree_id":null,"generation":null,"base_seq":null,"last_seq":null,"base_root":null,"projection_root":null,"mask":null,"set_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","count":0,"not_ok":0}', 1, '000bbb', 'QUtC', 2, 500),+('lab-01', 'q3', '{"schema":"shirudo.keepalive/1","boot_id":"9a6f14ea-0cc2-45e1-8e23-7b887120cf54","version_id":"d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f","config_root":null,"kernel_release":"7.4.2","image_id":null,"image_version":null,"image_root":null,"verdict":"init-pending","cond":5465,"flags":8,"tamper":null,"tree_id":null,"generation":null,"base_seq":null,"last_seq":null,"base_root":null,"projection_root":null,"mask":null,"set_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","count":0,"not_ok":0}', 1, '000bdd', 'QUtD', 2, 500);++INSERT INTO shirudo.nodes (ak_name, trust) VALUES ('000bbb', 'enrolled');+INSERT INTO shirudo.nodes (ak_name, trust) VALUES ('000baa', 'untrusted');++SELECT 'an enrollment row changes only trust';+SELECT ak_name, max(ak_public), argMinMerge(node_id), isNull(min(first_seen)), max(trust)+FROM shirudo.nodes GROUP BY ak_name ORDER BY ak_name;++SELECT 'latest carries trust';+SELECT ak_name, node_id, trust FROM shirudo.latest ORDER BY ak_name;++SYSTEM REFRESH VIEW shirudo.node_status_mv;+SYSTEM WAIT VIEW shirudo.node_status_mv;++SELECT 'node_status carries trust beside status';+SELECT ak_name, status, trust, failed_check, log[1] FROM shirudo.node_status ORDER BY ak_name;