external/anthropic-cybersecurity-skills/skills/validating-tpm-measured-boot-attestation/SKILL.md
Verify TPM PCRs and measured-boot and remote-attestation integrity.
npx skillsauth add seikaikyo/dash-skills validating-tpm-measured-boot-attestationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Legal Notice: Perform TPM operations only on systems you own or are authorized to assess. Some operations (clearing the TPM, taking ownership, defining NV indices) are destructive or can lock the device. This skill is for defensive integrity verification and authorized assessment.
A Trusted Platform Module (TPM 2.0) is a hardware root of trust that supports measured boot: each stage of the boot chain hashes ("measures") the next stage and extends that measurement into a Platform Configuration Register (PCR) before handing off control. PCRs cannot be set arbitrarily — they can only be extended (new = hash(old || measurement)), so the final PCR value is a tamper-evident summary of everything that executed. The TCG firmware profile assigns specific meanings: UEFI firmware code/config measure into PCR 0–7 (PCR 7 specifically captures Secure Boot policy), bootloaders measure the kernel into PCR 8–9, and Linux IMA measures executables into PCR 10.
Two complementary verifications matter. Local validation reads current PCRs (tpm2_pcrread) and replays the TPM event log (tpm2_eventlog on /sys/kernel/security/tpm0/binary_bios_measurements) to confirm the recorded measurements reproduce the live PCR values — proving the log is authentic and revealing exactly what changed if a value drifts from baseline. Remote attestation has the TPM produce a signed quote (tpm2_quote) over selected PCRs using an Attestation Key (AK), with a fresh nonce to prevent replay; a verifier then independently checks the signature and PCR digest (tpm2_checkquote) and compares against a golden/expected value. This lets a server cryptographically establish that a remote machine booted approved firmware and kernel before granting access, sealing secrets, or admitting it to a Zero Trust network.
This skill provides the full tpm2-tools workflow for enrolling an AK, capturing and verifying quotes, replaying event logs, sealing/unsealing data to a PCR policy, and building a golden-value baseline for fleet attestation.
sudo apt install tpm2-tools tpm2-abrmd # Debian/Ubuntu
sudo dnf install tpm2-tools tpm2-abrmd # Fedora/RHEL
/dev/tpm0 / /dev/tpmrm0) and the kernel measurement log at /sys/kernel/security/tpm0/binary_bios_measurements.| Technique ID | Technique Name | Relevance | |--------------|----------------|-----------| | T1542 | Pre-OS Boot | Measured boot detects pre-OS tampering this technique relies on. | | T1542.001 | Pre-OS Boot: System Firmware | PCR 0–7 drift reveals unauthorized firmware modification. | | T1542.003 | Pre-OS Boot: Bootkit | Bootloader/kernel measurements (PCR 8–10) expose bootkit changes. | | T1014 | Rootkit | IMA measurements (PCR 10) and quote verification surface concealed tampering. | | T1601.001 | Modify System Image: Patch System Image | Attestation against golden values flags unauthorized image patches. |
tpm2_getcap properties-fixed | grep -i manufacturer
tpm2_getcap pcrs # list supported PCR banks (sha1, sha256, ...)
PCR 7 = Secure Boot policy; PCR 0–7 = firmware; PCR 8–9 = bootloader/kernel; PCR 10 = IMA.
tpm2_pcrread sha256 # all sha256 PCRs
tpm2_pcrread sha256:0,1,2,3,4,5,6,7 # firmware + Secure Boot policy
tpm2_pcrread sha256:7 # Secure Boot policy only
Confirm the recorded log reproduces the current PCR values (authenticity check).
tpm2_eventlog /sys/kernel/security/tpm0/binary_bios_measurements > eventlog.yaml
# The YAML includes a "pcrs" section with the calculated values — compare to step 2.
# Any mismatch means the event log and the live PCRs disagree (tampering or stale log).
The AK signs quotes; its public part is shared with the verifier out-of-band.
tpm2_createprimary -C e -g sha256 -G rsa -c primary.ctx
tpm2_create -C primary.ctx -G rsa -u ak.pub -r ak.priv \
-a 'fixedtpm|fixedparent|sensitivedataorigin|userwithauth|restricted|sign'
tpm2_load -C primary.ctx -u ak.pub -r ak.priv -c ak.ctx
tpm2_readpublic -c ak.ctx -o ak.pem -f pem # export AK public key for the verifier
The verifier supplies a fresh random nonce to defeat replay.
NONCE=$(openssl rand -hex 20)
tpm2_quote -c ak.ctx -l sha256:0,1,2,3,4,5,6,7,8,9 \
-q "$NONCE" -m quote.msg -s quote.sig -o quote.pcrs -g sha256
# Send quote.msg, quote.sig, quote.pcrs (and the nonce) to the verifier.
Independently validate the signature, nonce, and PCR digest with the AK public key.
tpm2_checkquote -u ak.pem -m quote.msg -s quote.sig -f quote.pcrs \
-q "$NONCE" -g sha256
# Exit 0 + matching PCR digest == authentic, fresh, untampered quote.
Compare attested PCRs to known-good values captured from a trusted reference build.
# Capture golden values on a trusted reference machine:
tpm2_pcrread sha256:0,7 > golden_pcrs.txt
# On each attested host, diff the quote's PCR section against golden_pcrs.txt.
diff <(grep -A8 'sha256' quote.pcrs) golden_pcrs.txt
Bind a secret so the TPM only releases it when PCRs match the trusted state.
tpm2_createpolicy --policy-pcr -l sha256:7 -L pcr7.policy -f pcr7.dat
echo -n "diskkey" | tpm2_create -C primary.ctx -L pcr7.policy \
-i - -u sealed.pub -r sealed.priv
tpm2_load -C primary.ctx -u sealed.pub -r sealed.priv -c sealed.ctx
# Unseal succeeds only while PCR 7 matches the sealed policy:
tpm2_unseal -c sealed.ctx -p pcr:sha256:7
If IMA is enabled, the runtime measurement list extends PCR 10.
tpm2_pcrread sha256:10
head -20 /sys/kernel/security/ima/ascii_runtime_measurements
agent.py reads PCRs, replays the event log, optionally produces+verifies a quote, and diffs a baseline.
sudo python scripts/agent.py --pcrs 0,1,2,3,4,5,6,7 --baseline golden_pcrs.json --output attest.json
| Tool | Purpose | Source | |------|---------|--------| | tpm2-tools | CLI for all TPM 2.0 operations | https://github.com/tpm2-software/tpm2-tools | | tpm2-tss | TSS2 stack the tools build on | https://github.com/tpm2-software/tpm2-tss | | Keylime | Scalable remote attestation framework | https://github.com/keylime/keylime | | TCG PC Client Platform Firmware Profile | PCR usage specification | https://trustedcomputinggroup.org/ | | Linux IMA docs | Integrity Measurement Architecture | https://sourceforge.net/p/linux-ima/wiki/Home/ | | RFC 9683 | Remote integrity verification of TPM devices | https://datatracker.ietf.org/doc/html/rfc9683 |
tpm2_checkquote.development
拋棄式 HTML mockup 比稿:產出 2 到 3 個設計立場不同的變體(密度 / 版式 / 強調軸,不是換色),各附取捨說明,最後給有立場的對比結論。適用:「畫個草圖」「比較 A 版 B 版」「先看方向再做」「給我看幾種做法」。要 production 元件或設計已定案時不適用。
tools
需求不明時的意圖萃取訪談:一次一題、每題附上自己的猜測、聽出「真正想要 vs 覺得應該要」,直到能預測使用者反應(約 95% 信心)才動工。適用:需求缺少對象 / 動機 / 成功標準 / 約束,或使用者點名「訪談我」「先確認一下」「我們確定嗎」。明確自足的指示、純資訊查詢、機械性操作不適用。
development
對非平凡決策啟動新鮮 context 對抗審查(找碴不背書),在修正還便宜的時候抓出錯誤方向。適用:高風險改動(production、資安敏感邏輯、不可逆操作)、不熟的程式碼、要宣稱「這樣是安全的 / 可行的」之前。機械性操作與一行修改不適用。
testing
Reference for writing and editing agent skills well — the vocabulary and principles that make a skill predictable. Consult when authoring, reviewing, or pruning a SKILL.md.