Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/verifier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Browser TDX verifier

# verify/tdx-verify.js is a port of agent_manifest._tdx_verify, published on the
# homepage as the thing a visitor can check without trusting us. A port that
# drifts from its original is exactly the kind of quiet failure that page is
# about, so every change runs both verifiers over the committed captures and a
# few thousand mutated copies and fails on the first disagreement.
#
# No paths filter on purpose: a filter that misses a file is a green check that
# never ran, and this job takes under a minute.

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

jobs:
differential:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install the Python verifier the port is checked against
run: python -m pip install "agent-manifest==0.12.0"
- name: Record Python verdicts
run: python tools/tdx-differential.py --out differential.json
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Replay them through the browser port
run: node tools/check-tdx-verifier.mjs differential.json
1 change: 1 addition & 0 deletions llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ AgenTrust is the ecosystem at https://agentrust-io.com and the GitHub organizati
## Start here

- [Overview and architecture](https://agentrust-io.com/): The components, trust boundaries, governance, and evidence links.
- [Verify an Intel TDX quote](https://agentrust-io.com/verify/): Runs the four-step DCAP check on a genuine GCP confidential VM quote in the browser, ending at the pinned Intel SGX Root CA. A pass proves genuine Intel TDX silicon signed the quote. These captures do not tie a TRACE record to that machine, and the check does not appraise TCB currency or revocation.
- [10-minute tool-call tutorial](https://agentrust-io.com/quickstart/): Write a policy, observe a denied call, and inspect a signed session record on a laptop. Software mode provides no hardware isolation or hardware-backed provenance.
- [Weight Custody Manifest (WCM)](https://wcm.agentrust-io.com/): Bind model-weight identity and custody terms to key-release policy. The local walkthrough uses synthetic evidence and a placeholder key; it does not load a real model or demonstrate hardware protection.
- [Runnable demos](https://agentrust-io.com/demos/): Software examples for policy decisions, evidence verification, delegation, and model-weight custody. Follow each demo's stated prerequisites and limits.
Expand Down
1 change: 1 addition & 0 deletions sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
<url><loc>https://agentrust-io.com/quickstart/</loc></url>
<url><loc>https://agentrust-io.com/registry/</loc></url>
<url><loc>https://agentrust-io.com/telemetry/</loc></url>
<url><loc>https://agentrust-io.com/verify/</loc></url>
</urlset>
97 changes: 97 additions & 0 deletions tools/check-tdx-verifier.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env node
/**
* Checks verify/tdx-verify.js, the in-browser port of agent_manifest._tdx_verify.
*
* Without an argument it runs the checks that need nothing but this repository:
* the committed captures are the ones the hardware produced, both verify, a
* tampered one and an expired chain are rejected at the right step.
*
* With the JSON written by tools/tdx-differential.py it also replays every
* recorded mutation and fails if the port and the Python original disagree on
* any of them. CI always passes the JSON; see .github/workflows/verifier.yml.
*/
import { readFile } from 'node:fs/promises';
import { createHash } from 'node:crypto';
import {
verifyTdxQuote, pinnedRootFingerprint, OFF_MRTD, QUOTE_HEADER_LENGTH,
} from '../verify/tdx-verify.js';

const root = new URL('../', import.meta.url);
const WHEN = '2026-09-14T00:00:00Z';

// Pinned in agent-manifest's tests/test_tdx_verify.py for the same files, so a
// swapped or re-captured fixture fails here rather than changing what
// "a genuine quote" refers to on the public page.
const CAPTURES = {
'gcp-tdx-2026-07-21-tdx_quote.bin': 'f9efbac112efe510aa8ccd20703b063591b8c2c54c474d0ff1d6500299bae0ba',
'gcp-tdx-2026-07-21-tdx_quote_manifest.bin': '1ae04c74b564ef8795d4c4e4ffd1835d080d9dad4f8879e5cd1e8249503828b2',
};
const MRTD = '9bf86e6280ec4282b8b5822d8166410a456cdb720109aa799f0011fa63df1de3ee5e35e293fc410c061433163acb03a6';

const failures = [];
const check = (condition, message) => { if (!condition) failures.push(message); };

const load = async (name) => new Uint8Array(await readFile(new URL(`verify/fixtures/${name}`, root)));

for (const [name, digest] of Object.entries(CAPTURES)) {
const quote = await load(name);
check(createHash('sha256').update(quote).digest('hex') === digest, `${name}: not the committed hardware capture`);

const result = await verifyTdxQuote(quote, { verificationTime: WHEN });
check(result.accepted, `${name}: genuine capture rejected (${result.error})`);
check(result.steps.every((s) => s.status === 'pass'), `${name}: a step did not pass`);
check(result.quote && result.quote.mrtd === MRTD, `${name}: MRTD differs from the capture's`);
check(result.quote && result.quote.reportData.slice(64) === '0'.repeat(64), `${name}: REPORTDATA tail is not zero`);
check(result.chain.length === 3, `${name}: expected a three-certificate PCK chain`);

const tampered = quote.slice();
tampered[QUOTE_HEADER_LENGTH + OFF_MRTD] ^= 0xff;
const t = await verifyTdxQuote(tampered, { verificationTime: WHEN });
check(!t.accepted && t.steps[1].status === 'fail', `${name}: tampered MRTD not rejected at the quote signature`);

const late = await verifyTdxQuote(quote, { verificationTime: '2033-06-01T00:00:00Z' });
check(!late.accepted && late.steps[4].status === 'fail', `${name}: expired PCK leaf not rejected at the chain`);
}

const differentialPath = process.argv[2];
if (differentialPath) {
const report = JSON.parse(await readFile(differentialPath, 'utf8'));
check(report.verification_time.startsWith('2026-09-14T00:00:00'), 'differential ran at a different verification time');
check(await pinnedRootFingerprint() === report.pinned_root_sha256,
'pinned Intel root differs from the one agent_manifest._tdx_verify pins');

const quotes = {};
for (const [name, facts] of Object.entries(report.captures)) {
quotes[name] = await load(name);
check(createHash('sha256').update(quotes[name]).digest('hex') === facts.sha256, `${name}: differential used another file`);
}

const disagreements = [];
for (const c of report.cases) {
let input = quotes[c.capture];
if (c.mutation.type === 'flip') {
input = input.slice();
input[c.mutation.offset] ^= 0xff;
} else if (c.mutation.type === 'truncate') {
input = input.slice(0, c.mutation.length);
}
const ours = await verifyTdxQuote(input, { verificationTime: WHEN });
if (ours.accepted !== c.accepted) {
disagreements.push(`${c.capture} ${JSON.stringify(c.mutation)}: python ${c.outcome}, port ${ours.accepted ? 'accepted' : `rejected (${ours.error})`}`);
}
}
disagreements.slice(0, 25).forEach((d) => failures.push(d));
if (disagreements.length > 25) failures.push(`...and ${disagreements.length - 25} more disagreements`);
if (disagreements.length === 0) {
const accepted = report.cases.filter((c) => c.accepted).length;
console.log(`PASS port agrees with agent_manifest._tdx_verify on ${report.cases.length} inputs (${accepted} accepted)`);
}
} else {
console.log('differential skipped: pass the JSON from tools/tdx-differential.py to compare with the Python verifier');
}

if (failures.length) {
console.error(failures.join('\n'));
process.exit(1);
}
console.log('PASS both GCP TDX captures verify; tampered quote and expired chain are rejected at the right step');
120 changes: 120 additions & 0 deletions tools/tdx-differential.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
"""Record what agent-manifest's Python TDX verifier decides, for the browser port to match.

verify/tdx-verify.js is a port of agent_manifest._tdx_verify. A port that agrees
on two genuine quotes can still disagree on everything else, and a verifier that
accepts something its original rejects is worse than no verifier. So this script
takes both committed captures, derives a deterministic set of mutations from
them (every byte of each length and type field, dense coverage of the PEM
boundaries, a stride over everything else, and truncations at each structure
edge) and records the Python verdict for each one.

tools/check-tdx-verifier.mjs rebuilds the same mutations from this file's output
and fails if the port accepts or rejects any of them differently.

Usage: python tools/tdx-differential.py --out differential.json
"""
import argparse
import hashlib
import json
import struct
from datetime import datetime, timezone
from pathlib import Path

from agent_manifest import _tdx_verify
from agent_manifest._tdx_verify import verify_tdx_quote
from cryptography import x509
from cryptography.hazmat.primitives import hashes

ROOT = Path(__file__).resolve().parents[1]
FIXTURES = ROOT / "verify" / "fixtures"
CAPTURES = [
"gcp-tdx-2026-07-21-tdx_quote.bin",
"gcp-tdx-2026-07-21-tdx_quote_manifest.bin",
]
# Fixed, so a certificate expiring can never make the two runs disagree.
VERIFICATION_TIME = "2026-09-14T00:00:00+00:00"
STRIDE = 5


def offsets(quote: bytes) -> list[int]:
"""Byte offsets to flip, derived from the quote's own declared layout."""
auth_size = struct.unpack_from("<I", quote, 632)[0]
auth = 636
cert_data = auth + 134
qe_auth_size = struct.unpack_from("<H", quote, cert_data + 448)[0]
pck_header = cert_data + 450 + qe_auth_size
pem = pck_header + 6
pem_end = auth + auth_size
dense = [
range(0, 48), # signed header
range(632, 636), # signature data length
range(auth + 128, auth + 134), # certification data type and length
range(cert_data + 448, cert_data + 450), # QE auth data length
range(pck_header, pck_header + 6), # PCK chain type and length
range(pem, pem + 64), # first PEM marker and body start
range(pem_end - 64, pem_end + 8), # last PEM marker and what follows
]
chosen = set(range(0, len(quote), STRIDE))
for r in dense:
chosen.update(i for i in r if 0 <= i < len(quote))
# Every PEM newline and marker dash, where a tolerant parser would differ.
for i in range(pem, pem_end):
if quote[i] in (0x0A, 0x2D):
chosen.add(i)
return sorted(chosen)


def truncations(quote: bytes) -> list[int]:
auth_size = struct.unpack_from("<I", quote, 632)[0]
edges = [0, 47, 48, 631, 632, 635, 636, 700, 764, 769, 770, 1153, 1218, 1257, 1258, 636 + auth_size - 1, 636 + auth_size]
return sorted({e for e in edges if 0 <= e <= len(quote)})


def verdict(quote: bytes, when: datetime) -> dict:
try:
ok = verify_tdx_quote(quote, verification_time=when)
return {"accepted": ok is True, "outcome": "true" if ok is True else "false"}
except Exception as exc: # noqa: BLE001 - every failure mode is a rejection
return {"accepted": False, "outcome": "raise", "error": type(exc).__name__}


def main() -> None:
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
parser.add_argument("--out", required=True)
args = parser.parse_args()

when = datetime.fromisoformat(VERIFICATION_TIME).astimezone(timezone.utc)
root = x509.load_pem_x509_certificate(_tdx_verify.INTEL_SGX_ROOT_CA_PEM)
report = {
"verification_time": VERIFICATION_TIME,
"pinned_root_sha256": root.fingerprint(hashes.SHA256()).hex(),
"captures": {},
"cases": [],
}
for name in CAPTURES:
quote = (FIXTURES / name).read_bytes()
parsed = _tdx_verify.parse_tdx_quote(quote)
report["captures"][name] = {
"sha256": hashlib.sha256(quote).hexdigest(),
"mrtd": parsed.mrtd.hex(),
"report_data": parsed.report_data.hex(),
}
report["cases"].append({"capture": name, "mutation": {"type": "none"}, **verdict(quote, when)})
for offset in offsets(quote):
mutated = bytearray(quote)
mutated[offset] ^= 0xFF
report["cases"].append(
{"capture": name, "mutation": {"type": "flip", "offset": offset}, **verdict(bytes(mutated), when)}
)
for length in truncations(quote):
report["cases"].append(
{"capture": name, "mutation": {"type": "truncate", "length": length}, **verdict(quote[:length], when)}
)

Path(args.out).write_text(json.dumps(report, indent=1) + "\n", encoding="utf-8")
accepted = sum(c["accepted"] for c in report["cases"])
print(f"recorded {len(report['cases'])} Python verdicts ({accepted} accepted) to {args.out}")


if __name__ == "__main__":
main()
Binary file not shown.
Binary file not shown.
Loading
Loading