threatdeck
Live 13:45 UTC ·

Learn / Agents, tools and MCP

Lesson 2 of 69 minReviewed

Agent identity and least privilege

Choose how an agent authenticates, keep the end user visible in every action, and manage agent credentials as non-human identities with narrow, short-lived scope.

Every action an agent takes is performed by some identity, and that identity decides two things: what the action is allowed to touch, and what the logs will say afterwards. Most agent deployments use one of three patterns.

Three ways an agent authenticates
PatternWhat the logs showMain risk
Shared service account or static API keyThe service, never the personEvery user's request runs with the union of everyone's privileges, and a confused-deputy attack leaves no trail to the requester
The user's own credential handed to the agentThe user, never the agentThe agent can do everything the user can, usually with a long-lived token stored on disk
A delegated token issued to the agent on the user's behalfBoth the user and the agentNeeds an authorisation server and token plumbing, but scope and lifetime can match the task

OWASP's guidance for LLM extensions points to the third pattern: run each extension in the user's context, with the minimum scope necessary, and enforce authorisation in the downstream system rather than trusting the model to do it, which OWASP calls complete mediation [1]. OAuth already has a standard for the delegation step: RFC 8693 token exchange lets a service trade one token for another that acts on behalf of a subject, and can record the acting party in an act claim so the downstream system sees who delegated to whom [2].

Agent credentials are non-human identities

API keys, OAuth clients and service accounts used by agents and MCP servers are non-human identities (NHIs), and they fail in the ways OWASP's NHI Top 10 (2025) describes [3]:

  • Secret Leakage (NHI2) and Long-Lived Secrets (NHI7): a personal access token pasted into an MCP client configuration file, valid until someone remembers to revoke it.
  • Overprivileged NHI (NHI5): an account-wide token used by a server that only needs one repository.
  • NHI Reuse (NHI9): one key shared by several agents or servers, so a leak in one exposes all of them and logs cannot tell them apart.
  • Human Use of NHI (NHI10): a developer borrowing the agent's token to debug, which erases the line between human and automated activity.
  • Improper Offboarding (NHI1): the agent is retired but its credentials keep working.

Practices that hold up

  1. One identity per agent and per environment. Never share an identity across agents, and never let people use it.
  2. One credential per tool or server. The MCP project's local-server guidance recommends giving each server its own narrowly scoped token through per-server configuration instead of secrets exported globally in a shell profile, so a leak is contained and revocable [4].
  3. Short lifetimes. Prefer credentials issued at launch by a broker or secrets manager, and rotate whatever a server held when you remove it [4].
  4. Audience binding. For remote MCP servers, tokens must be issued for that specific server; servers must reject tokens issued for other resources and must not pass them on [5].
  5. Least privilege as a release gate. OWASP's agent cheat sheet recommends treating any change to credential scope as a trigger for review, and checking the caller's permissions at the receiving service rather than trusting that a message is well formed or signed [6].

Privilege drops to the least trusted input

Identity alone does not settle the question. An agent acting for an administrator that reads an attacker's email lets that email borrow the administrator's privileges. OWASP's agentic list names this class Identity and Privilege Abuse (ASI03) [7]. Two design responses follow: give tasks that process outside content a separate, lower-privileged identity, and make the high-privilege identity unusable without the approval steps covered later in this path.

Try it on ThreatDeck

Self-check

4 questions

Pick an answer to see whether it is right and why. Only your score is saved, in this browser.

  1. Every action in your audit log is attributed to svc-ai-assistant. What is the main problem?
  2. What does OWASP mean by complete mediation for LLM extensions?
  3. A developer copies an agent's API key to reproduce a bug from their laptop. Which OWASP NHI risk is this?
  4. What does RFC 8693 token exchange add to an agent design?

References

  1. LLM06:2025 Excessive Agency. OWASP GenAI Security Project, 2024-11.
  2. RFC 8693: OAuth 2.0 Token Exchange. IETF, 2020-01.
  3. OWASP Non-Human Identities Top 10 (2025). OWASP, 2025.
  4. MCP Local Server Security. Model Context Protocol, 2026-07-28.
  5. MCP specification: Authorization (2026-07-28). Model Context Protocol, 2026-07-28.
  6. AI Agent Security Cheat Sheet. OWASP Cheat Sheet Series.
  7. OWASP Top 10 for Agentic Applications for 2026. OWASP GenAI Security Project, 2025-12.
Completing the self-check also marks the lesson complete. Saved in this browser only.

Following

Follow the vendors, products, AI tools, techniques and actors you care about. Matching stories, CVEs and exploited bugs are marked, a Following tab appears in the feed, and returning visits show what changed. Saved only in this browser.

Presets

Get updates

A personal RSS feed of new stories on everything you follow. Paste it into any feed reader, Slack or Teams RSS app.