# What happens when an instance rotates its ephemeral workload identity mid-handoff under per-task mTLS **Date of Record:** 2026 November 24 **Scope:** Applies to multi-agent systems where each task execution is bound to a short-lived X.509 workload identity (SPIFFE-style SVID or equivalent) minted per task, with peer agents enforcing zero-trust mTLS and authorizing on the leaf certificate's identity and bound task claims. Does not apply to long-lived service identities, static API keys, or systems where authorization is evaluated only against a stable orchestrator principal rather than the caller's leaf identity. ## Core Distinction The distinction that matters is between **identity continuity** and **task continuity**. A task can be alive and mid-execution while the identity that authorizes it has already expired or been rotated. Zero-trust mTLS validates the *presenter* at the moment of the TLS handshake; it says nothing about whether the presenter is the *same logical agent* that performed the prior step of the task, nor whether the new leaf still carries the task-binding claims the downstream peer requires. The failure mode is not "expired certificate rejected" — that is the happy path. The failure mode is **rotation-induced identity discontinuity inside a multi-hop handoff**: agent A completes step 1 under SVID_A₁, mints/rotates to SVID_A₂ (new keypair, new serial, possibly new SPIFFE path segment or shortened TTL), and forwards the handoff to agent B. B's authorization policy was compiled against the task claim set bound to SVID_A₁. B sees a valid, cryptographically sound mTLS peer whose leaf does not carry the exact task-binding extension B expects, or carries it under a different issuer chain, and either (a) rejects a legitimate continuation as a spoofing attempt, or (b) — worse — accepts it because the policy only checks the SPIFFE trust domain and not the per-task claim, silently admitting an identity that was never warranted for this task. ## What Was Observed A three-hop pipeline: planner → executor → auditor. Each hop is an mTLS call. Per-task SVIDs have a 90-second TTL, minted at task admission, rotated at 60 seconds to leave a 30-second overlap window. The task-binding claim is a custom X.509 extension `task-claim` containing `{task_id, hop_index, parent_svid_serial}`. Observed trace on a task whose executor step ran 71 seconds: 1. `t=0` planner mints SVID_plan (serial `0x1a`), calls executor over mTLS. Executor verifies chain, checks `task-claim.task_id` matches, `hop_index==0`, accepts. 2. `t=60` executor's sidecar rotates SVID_exec → SVID_exec' (serial `0x2f`). The rotation is keyed to the *workload*, not the *task*. The new leaf's `task-claim` extension is populated from the sidecar's current task table — but the sidecar's task table was populated at admission and the `parent_svid_serial` field is stamped as `0x1a` (the planner leaf), which is correct, while `hop_index` is reset to `0` because the sidecar treats each rotation as a fresh admission. 3. `t=71` executor calls auditor under SVID_exec'. Auditor's policy requires `hop_index==1` for inbound executor→auditor calls (it enforces monotonic hop progression to prevent replay of an earlier hop's identity). The leaf presents `hop_index==0`. Auditor rejects with `TLS handshake ok, authz denied: hop_index regression`. 4. Executor retries the auditor call under the *old* SVID_exec (still within its 90s not-after). Auditor accepts — but now the audit record is cryptographically attributed to serial `0x2f`'s predecessor, and the executor's own logs claim `0x2f`. The two sides disagree on which identity performed the audited action. The non-obvious part: **the retry succeeded**, so no error surfaced to the orchestrator. The task completed. The divergence was only detectable by cross-referencing the auditor's recorded peer serial against the executor's rotation log. In a second observed instance, the auditor's policy was laxer (checked trust domain only, not `hop_index`), and the rotated leaf with reset `hop_index` was accepted — meaning an identity minted for hop 0 was used to authorize a hop 1 action, silently collapsing the hop-progression invariant the system was designed to enforce. ## Condition of Validity The invariant that must hold is: > For any task T with hop sequence h₀…hₙ, every SVID presented at hop hᵢ must carry `task-claim = {task_id: T, hop_index: i, lineage: consistent}` where `lineage` is a hash chain over the serials of all prior hops' leaves. Rotation may change the keypair and serial but **must not** change `task_id`, must **not** decrease `hop_index`, and must extend `lineage` with the rotated-from serial. This holds only if the rotation authority (the sidecar / SPIRE agent / workload attestor) is *task-aware*, not merely *workload-aware*. In the observed failure, the rotation authority was workload-aware: it rotated on wall-clock TTL and re-derived claims from a task table that had no hop-progression state. The condition of validity therefore fails whenever: - rotation is triggered by time rather than by task-phase transition, **and** - the claim-minting path reads task state that is not updated at each hop, **and** - the downstream verifier's policy is not written to detect hop regression. Any one of these being absent would have caught it. All three being present is the boundary. ## Decision Boundary The decision boundary is between **binding identity to the workload** and **binding identity to the task lineage**. These coincide at task admission and diverge at every rotation thereafter. Concretely, an architect must decide, per hop: - If the verifier checks only `trust_domain` and `task_id`: rotation is safe (claims are stable), but hop-progression anti-replay is lost. Acceptable only if replay of prior-hop identities is not a threat in your model. - If the verifier checks `hop_index` monotonicity: rotation must preserve `hop_index` across the rotate, which requires the rotation authority to read hop state at mint time and the caller to pass the current hop in the rotation request. If the rotation API has no hop parameter, this is unachievable and the design is broken. - If the verifier checks `parent_svid_serial` / lineage hash: rotation must extend the lineage, which means the rotation authority must be given the prior leaf's serial. Workload-aware rotation authorities typically do not accept this input, so lineage checks are incompatible with time-triggered rotation. The safe configuration is: **task-phase-triggered rotation** (rotate at hop boundaries, not on wall-clock), with the rotation request carrying `{task_id, next_hop, prior_serial}`, and verifiers enforcing `hop_index == expected` and `lineage` prefix-match. Time-triggered rotation is only safe when no verifier enforces hop or lineage claims. ## Operational Effect Downstream of the failure, three effects propagate: 1. **Attribution split.** Audit records keyed by peer serial disagree with executor-side logs keyed by the executor's belief about its own identity. Forensic reconstruction of "who did what" requires joining on task_id and hop, not on serial. Any compliance pipeline that attributes by serial will misattribute the hop. 2. **Silent invariant collapse.** When the verifier is lax, the hop-progression check that was supposed to prevent replay of an earlier hop's identity is defeated by rotation, because the rotated leaf re-presents hop 0. The system believes it is enforcing monotonic progression; it is not. 3. **Retry masking.** Because the old SVID is usually still within its not-after window during the overlap, the caller can always fall back to the pre-rotation leaf and succeed. This means the failure is not a hard error but a **flaky attribution and a defeated guardrail** — the worst kind, because it never pages anyone. The guardrail that bounds it: make rotation a *task-state transition* that is refused unless the caller supplies the hop and prior serial, and make verifiers reject any leaf whose `hop_index` is less than the maximum hop already observed for that `task_id` within the verifier's replay window. The verifier must maintain per-task hop high-water marks — stateless verifiers cannot enforce this. ```python import hashlib from dataclasses import dataclass class IdentityContinuityViolation(RuntimeError): """Raised when a rotated workload identity breaks task-lineage invariants.""" pass @dataclass(frozen=True) class TaskClaim: task_id: str hop_index: int lineage: str # hash chain over prior hop serials serial: str def rotate_identity( current: TaskClaim, next_hop: int, new_serial: str, ) -> TaskClaim: """Task-phase-triggered rotation. Refuses to silently reset hop state.""" if next_hop < current.hop_index: raise IdentityContinuityViolation( f"hop regression on rotation: task={current.task_id} " f"current_hop={current.hop_index} requested_hop={next_hop}" ) if next_hop == current.hop_index: raise IdentityContinuityViolation( f"rotation without hop advance: task={current.task_id} " f"hop={next_hop}; time-triggered rotation is not permitted " f"under lineage-enforcing policy" ) new_lineage = hashlib.sha256( f"{current.lineage}:{current.serial}".encode() ).hexdigest() return TaskClaim( task_id=current.task_id, hop_index=next_hop, lineage=new_lineage, serial=new_serial, ) def verify_inbound( presented: TaskClaim, expected_task_id: str, expected_hop: int, hop_high_water: dict[str, int], ) -> None: """Verifier-side enforcement of hop monotonicity and lineage presence.""" if presented.task_id != expected_task_id: raise IdentityContinuityViolation( f"task mismatch: presented={presented.task_id} " f"expected={expected_task_id}" ) if presented.hop_index != expected_hop: raise IdentityContinuityViolation( f"hop mismatch: task={presented.task_id} " f"presented_hop={presented.hop_index} expected_hop={expected_hop}" ) prior = hop_high_water.get(presented.task_id, -1) if presented.hop_index <= prior: raise IdentityContinuityViolation( f"replay of prior hop identity: task={presented.task_id} " f"hop={presented.hop_index} high_water={prior}" ) if not presented.lineage: raise IdentityContinuityViolation( f"empty lineage on hop {presented.hop_index} " f"for task {presented.task_id}; rotation dropped chain" ) hop_high_water[presented.task_id] = presented.hop_index ```