Course 4: Zero-Trust, Cedar & HTTP/3
Course 4 prepares you to deploy GAP in adversarial production environments: isolating untrusted T2 tools, enforcing two-person Cedar rules on IRREVERSIBLE mutations, stopping MCP rug pulls & SSRF, and serving dual-stack HTTP/3 QUIC with BLAKE3 audit verification.
What you'll learn
- Enforce
T0/T1/T2OS sandbox boundaries and<gap:untrusted>indirect prompt-injection containment. - Write & verify Cedar rules in
policies/default.cedar(gap policy check --dir policies). - Inspect
DriftMonitor,EgressGuardSSRF IP pinning,0-RTT-disabled HTTP/3 QUIC, andgap audit verify.
On this page
Lesson 1: Trust Tiers (T0/T1/T2) & <gap:untrusted> Escaping
Every upstream branch sits in an explicit trust boundary: T0 (Ed25519 organization-signed manifest; invalid signature demotes cleanly to T2), T1 (admin-approved with JCS BLAKE3 hashes pinned), or T2 (untrusted/external). All T2 stdio processes require OS sandboxing (Bubblewrap/nsjail on Linux, Seatbelt on macOS—failing closed if absent) and cannot join across trust domains (INV-07).
Moreover, every payload leaving T1/T2 branches is wrapped in <gap:untrusted>...</gap:untrusted> with fake closing tags escaped (SEC-080) so upstream web/tool text can never hijack AI host instructions.
Key Takeaways
- Invalid Ed25519 manifest signatures demote a branch safely from
T0toT2. T1/T2outputs are automatically escaped inside<gap:untrusted>envelopes (SEC-080).
Lesson 2: Two-Person Cedar Authorization Rules (INV-04, INV-11)
In GAP, access control is never left to LLM judgment (INV-04). Cedar evaluates deterministically over (principal, action, resource, context) where forbid unconditionally beats permit. Look at the shipped rule in policies/default.cedar:
@id("forbid-mutate-irreversible-or-unknown-unapproved")
forbid (
principal,
action == Action::"Mutate",
resource
) when {
(resource.sideEffect == "IRREVERSIBLE" || resource.sideEffect == "UNKNOWN")
&& !(context.approved && context.approverIsDifferent)
};
# Validate syntax & types offline:
./target/dist/gap policy check --dir policies
Enforce Two-Person Approval in Cedar
Complete the shipped Cedar guard so a caller cannot self-approve an IRREVERSIBLE mutation:
when {
(resource.sideEffect == "IRREVERSIBLE" || resource.sideEffect == "UNKNOWN")
&& !(context.approved && context.____)
}
Key Takeaways
- Cedar
forbidrules always override anypermitstatement. - Run
gap policy check --dir policiesin CI before reloading policies atomically withgap policy reload.
Lesson 3: Stopping MCP Rug Pulls (DriftMonitor) & SSRF (EgressGuard)
- Anti-Rug-Pull Pinning (
SEC-082,INV-08): Before an upstream serves a modified tool description to sneak hidden prompt injections after admin review,DriftMonitorrecomputes the JCS BLAKE3desc_hash, detects mismatch, freezes the branch intoBranchStatus::Drift, and continues serving only the pinned approved description. - Zero-Bypass SSRF Defense (
SEC-075): When calling OpenAPI or webhook hosts,EgressGuardresolves DNS exactly once, blocks loopback/RFC1918/octal/hex/169.254.169.254metadata targets, pins the verified IP socket directly against DNS rebinding, and forbids HTTP redirects.
Key Takeaways
DriftMonitorprevents post-approval tool description tampering from ever reaching LLM agents.EgressGuardblocks DNS rebinding, private ranges, cloud metadata IPs, and redirect pivots.
Lesson 4: HTTP/3 QUIC, BLAKE3 Audit Ledger & Crash Recovery (28.86 ms)
Ready for production deployment? Enable dual-stack HTTP/2 + HTTP/3 over UDP QUIC (which measured 5,013 req/s at 2.36 ms p95 with zero errors and recovered /readyz in 28.86 ms after SIGKILL), with max_early_data_size = 0 disabling 0-RTT replay risks:
./target/dist/gap audit verify --nightly
./target/dist/gap audit export --format jsonld > prov-o-audit.json
Why does GAP explicitly set max_early_data_size = 0 (disabling QUIC TLS 1.3 0-RTT) across HTTP/3 listeners?
Key Takeaways
profile = "prod"fails closed unless explicittls_cert_secretandtls_key_secretreferences are configured.gap audit verify --nightlyvalidates the tamper-evident BLAKE3 SQLite hash chain across mutations and approvals.