Provide Spire Workload Attestation Support to ztunnel #4
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4"
general
weight: 0.35
MikeZappa87
SPIRE Delegated Identity API Integration for ztunnel
Overview
This document describes the design and implementation of SPIRE integration in ztunnel using the Delegated Identity API. The implementation supports one attestation modes: PID-based, each with different security and efficiency trade-offs.
Background
Current ztunnel Certificate Management
The existing ztunnel certificate management uses
SecretManagerto cache certificates byIdentity(SPIFFE ID). When multiple pods share the same service account, they share a single cached certificate, reducing CA calls and memory usage.SPIRE Delegated Identity API
SPIRE's Delegated Identity API allows a trusted delegate (ztunnel) to request certificates on behalf of workloads. The API supports two attestation methods:
PID: Identify workloads by their process ID for stronger attestation
Design
Attestation Modes
In PID mode, each workload is attested individually using its container process ID. This approach:
CompositeId Design
Motivation
The original
SecretManagerusedIdentityas the cache key. To support PID-based attestation while maintaining backward compatibility with the existingCaClientTraitinterface, we introducedCompositeId<RequestKeyEnum>.Structure
Trade-offs
This design was chosen to maintain backward compatibility with
CaClientTrait:Benefits:
SecretManagercan track per-workload state when neededConsequences:
SecretManagercaches byCompositeId, resulting in one cache entry per pod even if they share the same identityPID Verification Flow
In PID mode, ztunnel performs the following steps:
1. Receive certificate request with
WorkloadUid2. Query Container Runtime (CRI) for the container's PID
3. Call SPIRE with the PID for attestation
4. Re-verify PID after SPIRE returns (guards against PID reuse attacks)
5. Return certificate to caller
Comparison Summary
| Aspect | Selector Mode | PID Mode |
|--------|---------------|----------|
| Attestation Granularity | Per identity (ns/sa) | Per workload (pod) |
| Certificate Sharing | Yes—same identity shares cert | No—each pod gets own cert |
| SPIRE Calls | 1 per unique identity | 1 per pod |
| Memory Usage | Lower | Higher |
| Security Level | Standard | Enhanced |
| Cache Key |
CompositeIdwithIdentitykey |CompositeIdwithWorkloadUidkey |Configuration
Future Considerations
1. Certificate Caching with Per-Pod Attestation: In PID mode, we should cache and reuse certificates by
Identitywhile still attesting every pod individually. This would reduce SPIRE server load and memory usage—multiple pods with the same identity would share one certificate after each pod passes local PID verification. The first pod triggers a SPIRE call; subsequent pods with the same identity only require local PID verification before reusing the cached certificate.2. Collaborate with SPIRE/SPIFFE Community: Work with the SPIRE and SPIFFE community to improve the Delegated Identity API and related interfaces to better support delegated attestation use cases like ztunnel's.
3. Consider a different trait for attested workloads instead of modifying fetch_certificate.