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.
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 Model | Secret Exposure | Prompt Injection Blast Radius | Sub-Factor Isolation | Linear Revocation |
|---|---|---|---|---|
| Secrets in Context / Static Env | Critical: enters LLM windows, logs, and memory snapshots | Catastrophic: indirect instructions exfiltrate passwords and raw 2FA seeds | Poor: sharing Base32 seeds grants permanent cloning capability | None: leakage forces manual credential rotation everywhere |
| Unattended Static Proxy | Moderate-High: stolen proxy tokens yield continuous ambient access | High: rogue tool calls silently harvest unrelated domains | Isolated seed, but lacks per-request human judgment | Post-hoc auditing without synchronous human veto |
| HITL Ephemeral Envelope Protocol | Minimal: scoped plaintext lives briefly in RAM; relay sees only ciphertext | Contained: verified domain binding + 1-of-k blind match + biometrics | Trusted device projects ephemeral 6-digit OTPs without exporting seed K | Atomic 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.
// 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)}`;Interactive Lab: ECDH P-256 Sealing, Blind Match & Burn-After-Reading
--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.
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.