Protocol Design · Zero-Knowledge HITL 10 min read Updated 2026-11-24

Ephemeral Delegation Protocols for Autonomous Agents: ECDH Channels, Blind Matching & Linear Consumption

When autonomous agents must authenticate against services lacking scoped OAuth delegation, handing over long-lived credentials recreates the classic Confused Deputy vulnerability. This note formalizes a zero-knowledge delegation protocol built on ephemeral ECDH envelopes, 1-of-k blind number matching, and transactional single-use erasure.

AI Agent RAM Boundary ECDH P-256 (sk_A, pk_A) Private key stays in RAM Screen Match Code 47 Receives Ephemeral 6-Digit OTP Raw Base32 seed stays isolated Blind Broker State Relay PENDING → APPROVED FOR UPDATE → CONSUMED 🔒 Zero Plaintext Visibility Ciphertext wiped on consume Biometric Trusted Vault Blind 3-Option Match [ 19 ] [ 47 ✓ ] [ 83 ] Device OTP + ECDH Seal AES-256-CBC + HMAC-SHA256 Biometric Gate · Fail-Closed 1. AI Request (Ephemeral pk_A Only) ECDH P-256 · Match Code: 47 Private sk_A never leaves AI memory 2. Blind Broker (Zero Plaintext) 🔒 Strips match code, serves 3 candidates FOR UPDATE → CONSUMED → NULL 3. Blind Match + Biometric Seal [ 19 ] · [ 47 ✓ ] · [ 83 ] Device OTP + ECDH EtM Envelope
The relay coordinates state transitions over opaque envelopes while ephemeral private keys stay in agent RAM and long-term secrets remain inside the trusted device

1. The Confused Deputy Problem Under Indirect Prompt Injection

First formalized by Norm Hardy (1988), the Confused Deputy problem arises when a privileged intermediary executes actions influenced by untrusted external inputs. Autonomous agents parsing untrusted DOM content or third-party documents exhibit precisely this failure mode whenever granted ambient access to passwords or 2FA seeds.

Delegation ModelSecret ExposurePrompt Injection Blast RadiusSub-Factor IsolationLinear Revocation
Secrets in Context / Static EnvCritical: enters LLM windows, logs, and memory snapshotsCatastrophic: indirect instructions exfiltrate passwords and raw 2FA seedsPoor: sharing Base32 seeds grants permanent cloning capabilityNone: leakage forces manual credential rotation everywhere
Unattended Static ProxyModerate-High: stolen proxy tokens yield continuous ambient accessHigh: rogue tool calls silently harvest unrelated domainsIsolated seed, but lacks per-request human judgmentPost-hoc auditing without synchronous human veto
HITL Ephemeral Envelope ProtocolMinimal: scoped plaintext lives briefly in RAM; relay sees only ciphertextContained: verified domain binding + 1-of-k blind match + biometricsTrusted device projects ephemeral 6-digit OTPs without exporting seed KAtomic burn-after-reading + domain blocklists + kill switch

2. Forward-Secure Ephemeral Channels (ECDH P-256 + Domain Separation)

To allow a relay broker to coordinate requests between an agent and a personal approval device without becoming a plaintext escrow target, every grant establishes a one-time asymmetric channel via ephemeral ECDH over NIST P-256:

(sk_A, pk_A) ← KeyGen_P256()                      (generated per request in agent RAM; only pk_A transmitted)
(sk_D, pk_D) ← KeyGen_P256()                      (generated upon human approval on trusted device)
Z            = ECDH(sk_D, pk_A) = ECDH(sk_A, pk_D)
K_session    = SHA-256(Z ∥ "ephemeral_grant_v1")  (domain-separated 256-bit session key)
C            = AES-256-CBC(K_session, IV_16B, ScopedJSON)
GrantBlob    = Base64(IV_16B) : Base64(HMAC-SHA256(K_session, IV_16B ∥ C)) : Base64(C)
  • Forward Secrecy: Destroying (sk_A, sk_D) immediately after single-use completion prevents any past or future compromise from decrypting prior envelopes;
  • Least-Privilege Projection & EtM: The trusted device trims the response strictly to approved attributes and seals it under AES-256-CBC + HMAC-SHA256 prior to relay upload.
Ephemeral ECDH P-256 + Encrypt-then-MAC Pattern (Web Crypto API)
// 1. Derive domain-separated 256-bit session key over ECDH P-256
const sharedBits = await crypto.subtle.deriveBits(
  { name: 'ECDH', public: agentEphemeralPubKey },
  deviceEphemeralKeyPair.privateKey,
  256
);
const sessionKeyRaw = await crypto.subtle.digest(
  'SHA-256',
  concatBytes(new Uint8Array(sharedBits), utf8('ephemeral_grant_v1'))
);

// 2. Seal scoped payload with fresh 16B IV and Encrypt-then-MAC
const iv = crypto.getRandomValues(new Uint8Array(16));
const cipherBytes = new Uint8Array(
  await crypto.subtle.encrypt({ name: 'AES-CBC', iv }, aesKey, utf8(JSON.stringify(scopedPayload)))
);
const macBytes = new Uint8Array(
  await crypto.subtle.sign('HMAC', hmacKey, concatBytes(iv, cipherBytes))
);
const sealedEnvelope = `${toBase64(iv)}:${toBase64(macBytes)}:${toBase64(cipherBytes)}`;
1. PENDING (90s) Submit pk_A + Min Scopes Rate limit: 5/min (429) matchCode → AI Only 2. Blind Match & Bio Pick 1 of 3 (Fail-Closed) Isolate reason vs domain ECDH(sk_D, pk_A) → K 3. APPROVED (60s) Seal EtM Ciphertext iv : hmac : aes256cbc Ephemeral OTP, No Seed 4. CONSUMED FOR UPDATE Atomic wipe on read Replay → 409 1. PENDING (90s) · Rate Limited Agent sends pk_A · matchCode kept off device 2. Blind 3-Option Match + Biometric K = SHA256(ECDH(sk_D, pk_A) || tag) 3. APPROVED (60s) · Encrypt-then-MAC iv : hmac(iv||cipher) : aes256cbc 4. CONSUMED · SELECT ... FOR UPDATE Wipe blob atomically · Replay returns 409
Protocol Flow: Agent ephemeral P-256 request -> 1-of-k blind match & device sealing -> FOR UPDATE burn-after-reading
⚡ Live Browser Web Crypto Ephemeral Envelope Lab

Interactive Lab: ECDH P-256 Sealing, Blind Match & Burn-After-Reading

1. AI Agent (RAM) IDLE
Generate an ephemeral ECDH P-256 keypair inside browser RAM.
2. Trusted Device (Match)
Waiting for request: picking a decoy number fails closed.
3. Blind Relay & Consume
Relay holds state machine + opaque EtM envelope only.
Server Ciphertext View: -
Agent Decrypted Output: -

3. 1-of-k Blind Number Matching, Provenance Isolation & OTP Projection

Channel encryption alone cannot defeat human-attention attacks such as MFA notification fatigue or misleading prompt-injected rationales:

  • 1-of-k Blind Matching (Fail-Closed): The relay generates a random 2-digit code c revealed solely to the agent screen while stripping c from the device pending payload and supplying k = 3 shuffled candidates. Accidental blind taps succeed with probability at most 1/3, and any wrong pick irreversibly transitions the request to REJECTED;
  • Provenance Isolation: Approval UIs separate broker-verified bindings (agent identity, target domain, requested field scope) from untrusted free-text agent justifications;
  • Ephemeral OTP Projection: When a workflow only needs second-factor verification, the trusted device computes only the live 6-digit token locally—keeping raw Base32 secret K permanently confined to client hardware sandboxes.

4. Linear Consumption Semantics via Row-Level Locking

  • Bounded Two-Stage TTLs: PENDING approvals expire after 90s; APPROVED grants open a strict 60s single-consumption window;
  • Eliminating TOCTOU Double-Read Races: Executing consumption inside a single ACID transaction with SELECT ... FOR UPDATE atomically validates APPROVED status, transitions the row to CONSUMED, and overwrites encrypted_grant_bundle to NULL—returning 409 Conflict to any concurrent or subsequent replay.
PostgreSQL Row-Locking Linear Consumption Pattern
BEGIN;
-- 1. Acquire exclusive row lock to eliminate TOCTOU double-consumption
SELECT id, status, consume_expires_at, encrypted_grant_bundle
FROM ephemeral_grant_requests
WHERE id = $1 AND agent_id = $2
FOR UPDATE;

-- 2. Validate APPROVED status & 60s window (410 if expired, 409 if already consumed)
-- 3. Flip state and wipe ciphertext atomically in one transaction
UPDATE ephemeral_grant_requests
SET status = 'CONSUMED',
    consumed_at = NOW(),
    encrypted_grant_bundle = NULL
WHERE id = $1;
COMMIT;

Core Protocol Axioms

  • Per-request ephemeral ECDH P-256 + Encrypt-then-MAC guarantees the coordinating relay remains cryptographically blind.
  • Combining 1-of-k fail-closed number matching, provenance isolation, and device-side OTP projection defeats prompt injection and MFA fatigue.
  • ACID row locking (FOR UPDATE) with immediate ciphertext nullification enforces strict single-use burn-after-reading semantics.

Standards & References

  • Hardy (ACM SIGOPS 1988) — The Confused Deputy: (or why capabilities might have been invented): Defines capability confinement when intermediaries process untrusted inputs.
  • NIST SP 800-56A Rev. 3 — Recommendation for Pair-Wise Key-Establishment Schemes Using Discrete Logarithm Cryptography: Specifies ephemeral ECDH on P-256 and key-derivation requirements.
  • IETF RFC 5869 — HMAC-based Extract-and-Expand Key Derivation Function (HKDF): Establishes domain-separation conventions for symmetric session key derivation.
  • Greshake et al. (AISec 2023) — Not What You’ve Signed Up For: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection: Analyzes indirect prompt injection risks against tool-using autonomous agents.