Set up the backend#
In this tutorial you start what a target pulls from and reports to, on
your own host: an OCI registry, an OpenTelemetry Collector and the
example backend of tools/backend/, a ClickHouse that checks every
keepalive a target sends. You enroll the test target in the backend and
read its status there. The use-case guides,
Live patch a kernel and a JVM, Sandbox Vulnerable Apache and
Observe a target at runtime, start from the state this page leaves.
The test VM is configured for these services from its first boot. Its
signed config names oci://10.0.2.2:15444/shirudo/local-tree as the
upatch tree to follow and https://10.0.2.2:14319 as the collector,
and its timers look for a tree operation and send a keepalive every 10
seconds, where a target’s wait a minute. Until the services run, the
timers retry.
Before you begin#
A shell that may lock memory, which
shirudodoes as it starts:operator$ sudo prlimit --pid $$ --memlock=unlimited:unlimited
ulimit -lthen printsunlimited. Under a lower limitshirudostops withhardening: cannot lock process memory, andmake vmwithcannot fingerprint the bundle's own certificateorcannot read the version_id of the bundle's shirudo. The limit belongs to the shell: set it in each terminal you run the commands of this guide in.A host that meets the requirements of the Quickstart, with the test kernel staged and shirudo built as its first three sections do: in the root of your checkout, with
shirudoandshirudo-buildonPATHDocker on the operator host
Start the services and the target#
Start the registry, the collector, the backend and the test VM, and load the settings of the stack into your operator shell:
operator$ make stack-up && make vm VM_NAME=quickstart operator$ . build/test-vm/stack/env
The first line prints:
... OCI: oci://127.0.0.1:15444 (CA: /home/user/shirudo/build/test-vm/stack/ca.pem) OTLP: https://127.0.0.1:14319; ClickHouse with the backend: http://127.0.0.1:18124 Shell: . /home/user/shirudo/build/test-vm/stack/env ... [test-vm] booting bzImage with 4 CPUs and 4G memory [test-vm] VM ready: name=quickstart state=.../build/test-vm/vms/quickstart qemu_pid=... swtpm_pid=... ... [test-vm] console: make -C testing vm-console VM_NAME=quickstart [test-vm] ssh: make -C testing vm-ssh
make stack-upbuildstools/quote-check/shirudo-quote-check, the checker the backend verifies keepalives with, which shirudo-quote-check describes. It then runs three containers on the host’s loopback interface: the registry, the collector and a ClickHouse with the schema oftools/backend/sql/and the checker installed as itstpm_quote_checkfunction.make vmboots the test VM of the quickstart, which reaches the services at10.0.2.2and trusts the CA theOCI:line names. A VM that the quickstart booted before works as well: runmake stack-upalone. Run a local development stack describes eachmaketarget of this stack, and Set up sets the backend up on a host of your own.Open a root shell on the target, in which
shirudoruns the runtime binary:operator$ make -C testing vm-ssh VM_NAME=quickstart
Commands with the
target#prompt run in this shell.Look at the settings the
Shell:line names, which your shell read in the first step:operator$ cat build/test-vm/stack/env export PATH='/home/user/shirudo:/home/user/shirudo/tools/shirudo-build':"$PATH" KEYS='/tmp/shirudo-test-vm-private-1000/operator-keys/keys' export BPM_OCI_CA_FILE='/home/user/shirudo/build/test-vm/stack/ca.pem' TREE=oci://127.0.0.1:15444/shirudo/local-tree export CLICKHOUSE_CLIENT='docker exec -i shirudo-dev-clickhouse clickhouse-client'
make stack-upwrites the file, as amaketarget cannot set a variable in the shell that ran it. It putsshirudoandshirudo-buildof your checkout onPATHand names the key directory, the registry’s CA and the tree for the commands of the guides.shirudo bpmreadsBPM_OCI_CA_FILEto verify the registry, and the jobs oftools/backend/jobs/run the ClickHouse clientCLICKHOUSE_CLIENTnames. A shell you open later has none of them until it reads the file too. The tree does not exist yet: the first operation you append creates it.
Enroll the target#
Load the names of the target’s TPM keys into the backend:
operator$ make vm-enroll VM_NAME=quickstart $ cat build/test-vm/vms/quickstart/enroll.json {"source": "test-vm", "nodes": [{"ak_name": "000b384a13035ce74a05397c2df1837c26832060a048f199cebf270b40c6d1a29b35", "ek_name": "000b2bcc6ad1b9d260ae30ffb0a3f75dd65bf20d0870c7346aeab39abd295ddda2d0", "node_id": "quickstart"}]} $ CLICKHOUSE_CLIENT='docker exec -i shirudo-dev-clickhouse clickhouse-client' tools/backend/jobs/enroll-put build/test-vm/vms/quickstart/enroll.json enroll-put: 000b384a13035ce74a05397c2df1837c26832060a048f199cebf270b40c6d1a29b35 (ek_name 000b2bcc6ad1b9d260ae30ffb0a3f75dd65bf20d0870c7346aeab39abd295ddda2d0, node_id quickstart): enrolled enroll-put: loaded bindings: 1 $ CLICKHOUSE_CLIENT='docker exec -i shirudo-dev-clickhouse clickhouse-client' tools/put-shirudo-build --note 'test-vm build' 59400f7e494aaa7d25dd4e6205689571ceda217bb77d07ceba6708ed0a372441 put-shirudo-build: 59400f7e494aaa7d25dd4e6205689571ceda217bb77d07ceba6708ed0a372441: allowed
The backend trusts a keepalive only when the attestation key that signed its quote is enrolled.
make vmrecorded the names of the attestation and endorsement keys when it created the VM’s TPM, as the builder of a real target does, andmake vm-enrollloads that record with Enroll keys from a builder. It also tells the backend which build of shirudo to expect. Your names and build differ. Attest a target enrolls a key from the target itself, through credential activation.Read the target’s status in the backend:
operator$ docker exec -i shirudo-dev-clickhouse clickhouse-client --query "SYSTEM REFRESH VIEW shirudo.node_status_mv; SYSTEM WAIT VIEW shirudo.node_status_mv" operator$ docker exec -i shirudo-dev-clickhouse clickhouse-client --query "SELECT node_id, status, trust, loaded FROM shirudo.node_status FORMAT PrettyCompactMonoBlock" ┌─node_id────┬─status──┬─trust────┬─loaded─┐ 1. │ quickstart │ healthy │ enrolled │ 0 │ └────────────┴─────────┴──────────┴────────┘
The backend works
node_statusout once a minute; the first command has it do so at once. The row comes from the keepalives the target sends: each is the target’s status with a TPM quote over it, andenrolledsays that the quote verified against the key you loaded.Read the checks behind that status:
operator$ docker exec -i shirudo-dev-clickhouse clickhouse-client --query "SELECT arrayJoin(log) FROM shirudo.node_status" 1 signed: pass, enrolled, 0 rejected in the last hour 2 fresh: pass, last record 2 s ago 3 reported: pass, verdict ok, cond 0x1555, flags 0, tamper +0, build 59400f7e 4 chain: no tree 5 head: no tree 6 set: no tree 7 peers: no tree
Checks 4 to 7 compare what the target applied with the upatch tree, and the backend knows no tree yet. The guides append to the tree and read these lines again. Node status describes each check.
Watch the target#
Start xtop in a second terminal:
operator$ make xtop
xtop is a terminal view of the same tables: the nodes with their status, the shields the backend knows as available and the ones each node runs. It needs
bunon the host. Leave it running while you follow a guide.
Stop the services#
Remove the VM, and the containers with their data, when you are done with the guides:
operator$ make vm-stop VM_NAME=quickstart operator$ make vm-clean VM_NAME=quickstart operator$ make stack-down
Stopping the VM ends the target shell. The VM’s disk and TPM state, the registry, the tree in it, the backend’s tables and the CA are gone. A VM that is left running trusts the removed CA, so a stack you start later needs a fresh one.
Next steps#
Live patch a kernel and a JVM blocks a kernel vulnerability and guards a JVM with upatches the target pulls from the tree.
Sandbox Vulnerable Apache puts an application in a sandbox.
Observe a target at runtime collects what runs, connects and reads on the target.
Backend explains the backend and its tables.