How we keep API keys out of reach of our agents (after the OpenCode key leak)
retained text
After OpenCode's breach (an intruder hit a legacy system on Oct 16 and may have exposed saved OpenAI, Anthropic and Google keys for 1.4% of Console users), I went back over how our agents touch credentials. Here's what I'd tell anyone running agents in production: 1. Never let the agent hold the real key. If it's in the prompt, the env the agent can read, or a tool output, assume it can leak. 2. Put a broker or proxy in between that adds the key on the way out. Infisical Agent Vault, Latch and Keycard all do versions of this, so the agent only ever sees a placeholder. 3. When a real key has to exist, make it scoped and short-lived, with read-only where possible and an expiry of hours, not months. 4. Give each agent its own provider key with a hard spend cap. When something goes wrong, you know which agent did it, and the damage has a ceiling. 5. If a key leaks, revoke it at the provider first, then rotate. Deleting it from your own config doesn't stop anyone who already copied it. How are you all handling this? Is anyone running a proxy setup in prod?
document fetched 2026-10-27 00:19 · canonical https://reddit.com/r/AI_Agents/comments/1xfxnty/how_we_keep_api_keys_out_of_reach_of_our_agents