Secrets and credentials around AI agents
For engineers
Keeping API keys and tokens out of the context window, brokering credentials in the tool layer, delegated OAuth and leaked-key response
110 questions across four stages: Understand, Apply, Solve and Judge.
Try 5 questions
Practice items, not counted towards your mastery. No account needed.
Check yourself · 1 of 5
Why is a secret in an agent's context window a risk?
Check yourself · 2 of 5
Which tool signature keeps the credential away from the model?
Check yourself · 3 of 5
Why should an MCP server not forward the user's incoming token to a downstream API?
Check yourself · 4 of 5
A model API key was pushed to a public repo ten minutes ago. What do you do first?
Check yourself · 5 of 5
Which command is the most likely to put a secret into an agent's context by accident?
Topics
- How secrets reach the context window5 min read · .env files an agent reads, keys pasted into chat and tool output that echoes tokens, and why a secret in context can leak through logs or injection
- Keeping credentials outside the model5 min read · Tools that attach credentials server-side, handles instead of raw keys, and never letting the model choose or pass a token
- Delegated OAuth for agents acting for users6 min read · On-behalf-of flows, token exchange, audience-bound tokens and why MCP servers must not pass user tokens through
- Detecting and rotating leaked AI keys5 min read · Secret scanning in repos and transcripts, stolen model API keys used for compute abuse, spend alerts and a rotation runbook
Start here
- Secrets Management Cheat Sheet (OWASP) (opens in a new tab)ArticleFree
Central storage, short-lived secrets, rotation and auditing: the baseline every agent setup should meet.
- MCP specification: Authorization (opens in a new tab)StandardFree
How MCP servers and clients must handle OAuth, audience-bound tokens and token passthrough.
- MCP security best practices (opens in a new tab)DocsFree
Names the confused deputy and token passthrough attacks and what servers must do instead.
Helps to know first
110 questions · last verified 2026-12