shirudo Under Attack: Forged Signatures, Tampering, Replay and Key Pinning
A shirudo target runs only the BPF its operator signed, and records every change in its TPM. In this tutorial you attack those promises from root on the target and from the network, and watch each attempt fail. Then you pin the key that attestation relies on, and see what that proves and what it leaves open.
The target VM runs under QEMU's software emulation (iximiuz playgrounds have no nested KVM). Preparing the lab takes about 8 minutes.
Prepare the lab
The lab started preparing itself when the playground booted. Follow it with
tail -f ~/lab-setup.log and press Ctrl+C once it prints [test-vm] VM ready.
If the log stops with an error instead, run systemctl status shirudo-lab-setup
and re-run shirudo-lab all (or shirudo-lab target if only the boot failed).
In every terminal:
t '<command>'runs one command on the target as root (shirudothere is the trusted runtime binary). It runs in/workspace/shirudoon the target, which is~/shirudohere, and the target's/mnt/shirudo-outis~/shirudo/build/test-vm/vms/quickstart/result.- Operator commands run from
~/shirudo. Every block below starts withcd ~/shirudo, so any terminal works.shirudois onPATHand the signing key is in$KEYS.
1. A genuine upatch
Sign the reference upatch with the operator's key, and sign its unload directive, so there is something real to attack:
cd ~/shirudo
shirudo build testing/fixtures/basic.bpf.c --keys-dir "$KEYS" --vmlinux vendor/linux/vmlinux.h -o basic.upatch
PAYLOAD=$(shirudo upatch info --json basic.upatch | jq -r .payload_sha256)
shirudo build --unload basic --payload-sha256 "$PAYLOAD" --keys-dir "$KEYS" -o basic.unload.upatch
basic.upatch is a signed loader: when a target loads it, the kernel checks
its signature against the .bpf keyring, which shirudo sealed at boot.
2. Forge a signature
An attacker can sign BPF too, with a key of their own. It is a perfectly valid ML-DSA-87 signature, just not from a key in the target's keyring:
cd ~/shirudo
mkdir -p build/lab && shirudo genkey --keys-dir build/lab/attacker-keys
shirudo build testing/fixtures/basic.bpf.c --keys-dir build/lab/attacker-keys \
--vmlinux vendor/linux/vmlinux.h --name evil -o build/lab/evil.upatch
t 'shirudo upatch load build/lab/evil.upatch' 2>&1 | tee ~/forged.txt
The kernel refuses it, with Required key not available. No userspace check
could be bypassed here: the .bpf keyring only ever holds the certificates from
the signed config image, and init seals it at every boot, so even root cannot
add the attacker's certificate.
3. Tamper with a signed upatch
What if the attacker modifies a genuine artifact in transit? Flip one byte in the
signed data section of basic.upatch:
cd ~/shirudo
cp basic.upatch build/lab/tampered.upatch
python3 -c "import sys; p=sys.argv[1]; b=bytearray(open(p,'rb').read()); b[-16] ^= 0xff; open(p,'wb').write(b)" build/lab/tampered.upatch
cmp -l basic.upatch build/lab/tampered.upatch
t 'shirudo upatch load build/lab/tampered.upatch' 2>&1 | tee ~/tampered.txt
shirudo's parser refuses it in userspace, before the kernel runs: the header no
longer agrees with the signed section (report category parser_rejected).
These consistency checks verify no signature; they only catch an artifact that
contradicts itself. Change a byte elsewhere in the signed data and make the
header consistent again, and the kernel's signature check at BPF_PROG_LOAD
refuses it instead. Either way, nothing was loaded.
4. Unload the wrong thing
First load the genuine upatch. The kernel accepts its signature, and the load is measured into the TPM register:
cd ~/shirudo
t 'shirudo upatch load basic.upatch' 2>&1 | tee ~/loaded.txt
Unloading is privileged too: it takes a signed unload directive, bound to the
SHA-256 of the payload it removes, not just to the name basic. Suppose the
attacker holds a directive signed for a different build of basic: an old one,
or one captured on its way to another target. Make one with the operator key;
an all-zero digest stands in for the other build:
cd ~/shirudo
shirudo build --unload basic --payload-sha256 $(printf '0%.0s' {1..64}) --keys-dir "$KEYS" -o build/lab/wrong.unload.upatch
t 'shirudo upatch unload build/lab/wrong.unload.upatch' 2>&1 | tee ~/mismatch.txt
t 'shirudo upatch list' | tee ~/still-loaded.txt
The signature is valid, but the loaded payload is not the one the directive
names: payload_mismatch. basic stays loaded.
This guards against wrong and stale directives, not against the key holder: whoever holds the signing key can sign a correct directive for any upatch whose payload digest they know, and the digest is no secret (ADV-F in the threat model).
Now unload it with the right directive, and look at the tamper counters:
cd ~/shirudo
t 'shirudo upatch unload basic.unload.upatch' 2>&1 | tee ~/unloaded.txt
t "shirudo status | sed -n '/^Tamper attempts/,/^Loaded/p'"
None of your three attacks moved a counter. The kernel's own signature errors
and shirudo's userspace refusals (parser_rejected, payload_mismatch) are
refused without one: as the
tamper counters page
puts it, "A zero counter does not mean nobody tried." Any counts you see come
from other refused calls since boot.
5. Replay old evidence
Attestation answers a question with a nonce: fresh random bytes the TPM signs into its quote. Take evidence for one nonce and verify it:
cd ~/shirudo
EV=build/test-vm/vms/quickstart/result/ev.json
OWN=build/test-vm/host-bundle-bpf-next-verity/fixtures/own.der
NONCE=$(openssl rand -hex 32)
t "shirudo attest --nonce=$NONCE --output=/mnt/shirudo-out/ev.json"
shirudo attest verify --evidence="$EV" --nonce="$NONCE" --ak-name="$(jq -r .ak.name "$EV")" \
--cert="$KEYS/cert.der" --cert="$OWN" --allow-runtime-events 2>&1 | tee ~/fresh.txt
The target booted with two trusted signers: your operator key
($KEYS/cert.der) and the test bundle's fixture signer (own.der). --cert
lists every signer you expect, and the target's boot record must cover exactly
that set.
Now play a compromised target that replays this evidence to the next question:
cd ~/shirudo
EV=build/test-vm/vms/quickstart/result/ev.json
OWN=build/test-vm/host-bundle-bpf-next-verity/fixtures/own.der
shirudo attest verify --evidence="$EV" --nonce="$(openssl rand -hex 32)" --ak-name="$(jq -r .ak.name "$EV")" \
--cert="$KEYS/cert.der" --cert="$OWN" --allow-runtime-events 2>&1 | tee ~/replay.txt
6. Pin the attestation key
There is one gap left: above, the attestation key's name came from the evidence itself. Any TPM could have produced evidence that checks out against its own key. Pin the key once, with a credential challenge: a random credential encrypted to the endorsement key (EK) the evidence presents, which that TPM releases only to the attestation key with that exact name:
cd ~/shirudo
OWN=build/test-vm/host-bundle-bpf-next-verity/fixtures/own.der
RESULT=$(realpath build/test-vm/vms/quickstart/result)
NONCE1=$(openssl rand -hex 32)
t "shirudo attest --nonce=$NONCE1 --output=/mnt/shirudo-out/first.json"
AK=$(jq -r .ak.name "$RESULT/first.json"); EK=$(jq -r .ek.name "$RESULT/first.json")
CRED=$(shirudo attest challenge --evidence="$RESULT/first.json" --ak-name="$AK" --trust-presented-ek \
--output="$RESULT/challenge.json" | tee /dev/stderr | sed -n 's/^credential: //p')
NONCE2=$(openssl rand -hex 32)
t "shirudo attest --nonce=$NONCE2 --challenge=/mnt/shirudo-out/challenge.json --output=/mnt/shirudo-out/enrolled.json"
shirudo attest verify --evidence="$RESULT/enrolled.json" --nonce="$NONCE2" --ak-name="$AK" --ek-name="$EK" \
--expect-credential="$CRED" --cert="$KEYS/cert.der" --cert="$OWN" --allow-runtime-events 2>&1 | tee ~/enrolled.txt
The target returned the credential, so the attestation key sits in the same TPM as the endorsement key it presented.
That does not prove the EK belongs to a real TPM. The lab's software TPM
(swtpm) has no manufacturer EK certificate, only one from a throwaway test CA,
so --trust-presented-ek skips issuer validation. Never use it in production:
whoever controls the target could present the keys of a software TPM, answer
the challenge there and sign any evidence. Use --ek-ca=<bundle> (the TPM
vendors' CA certificates) or an --ek-name you recorded out of band, for
example at provisioning. See
Attest a target.
--allow-runtime-events above accepted the loads and unloads after boot
without checking them. From now on, verify every report against your record
of the key and against the register value you predict yourself. The register
holds every event since this target booted: the genuine basic load and unload
from section 4 (the refused attempts were never measured). List exactly those,
in order; if you loaded and unloaded basic more than once, add each event:
cd ~/shirudo
OWN=build/test-vm/host-bundle-bpf-next-verity/fixtures/own.der
RESULT=$(realpath build/test-vm/vms/quickstart/result)
AK=$(jq -r .ak.name "$RESULT/first.json")
PAYLOAD=$(shirudo upatch info --json basic.upatch | jq -r .payload_sha256)
shirudo attest predict --cert="$KEYS/cert.der" --cert="$OWN" \
--event=load:basic="$PAYLOAD" --event=unload:basic="$PAYLOAD" 2>&1 | tee ~/predict.txt
CHAIN=$(sed -n 's/^register_after_events: //p' ~/predict.txt)
NONCE3=$(openssl rand -hex 32); echo "$NONCE3" > ~/nonce3.txt
t "shirudo attest --nonce=$NONCE3 --output=/mnt/shirudo-out/ev.json"
shirudo attest verify --evidence="$RESULT/ev.json" --nonce="$NONCE3" --ak-name="$AK" \
--expect-chain="$CHAIN" 2>&1 | tee ~/pinned.txt
OK state: register equals the expected value: the predicted register covers
the boot record of your two signers and both events. A load you did not
predict would fail this check.
And if the target booted with a signer you don't know about (here you "forget"
own.der), the boot record no longer matches:
cd ~/shirudo
RESULT=$(realpath build/test-vm/vms/quickstart/result)
AK=$(jq -r .ak.name "$RESULT/first.json"); NONCE3=$(cat ~/nonce3.txt)
shirudo attest verify --evidence="$RESULT/ev.json" --nonce="$NONCE3" --ak-name="$AK" \
--cert="$KEYS/cert.der" --allow-runtime-events 2>&1 | tee ~/wrongcert.txt
A production target also checks its config image root with
--expect-config-root; the lab skips it.
What's next
- Security model and threat model
- Tamper counters: what each counter means
- Attest a target: the enrollment and prediction steps of this section
- Attest targets: EK certificates, config roots and PCR policies
Learn by doing, not just by reading or watching
Sign up for a free account to start a VM playground right on this page, track your progress, and get notified about new learning materials.

Native SSH Access with Pomerium
Pomerium can be used as a native SSH reverse proxy, adding OAuth authentication and flexible Pomerium policy enforcement to standard SSH connections, without the need for tunnels, or custom clients or servers.

Native SSH Reverse Tunneling with Pomerium
Use Pomerium's native SSH support to publish a local service through a standard reverse SSH tunnel, with OpenID Connect (OIDC) authentication and continuous authorization on every request. Reach services behind Network Address Translation (NAT) without firewall holes or custom agents, and control both who can use the service and who can open the tunnel. Application traffic stays on infrastructure you control.

Secure Machine-to-Machine Access with mTLS and Pomerium
Run a GitHub Actions-compatible continuous integration (CI) job on a private runner and protect its internal API call with mutual TLS (mTLS) and Pomerium. Build separate server and client trust chains, authorize one machine certificate by fingerprint, then revoke, restore, and rotate its credentials through live policy changes.

Harden Access to OpenClaw with Pomerium
Put OpenClaw, a self-hosted AI assistant with shell and file access, behind a web route and an SSH route, both gated by the same identity and Pomerium's context-aware policy. OpenClaw runs in trusted-proxy mode, trusting signed identity headers instead of its own login, while Pomerium's native SSH proxy signs short-lived certificates for shell access.