Secure AI Architecture, Engineering and IAM, 65 min read

4.5 Identification and authentication for humans, workloads and agents

In this lesson you will:

  1. List the kinds of identity in an AI system, and say who owns each and how it should prove who it is.
  2. Design agents so that every action can be attributed to the right person and the right agent.
  3. Choose the strongest practical way for one machine to authenticate to another.
  4. Bring staff AI tools under the organization's identity system.
  5. Keep secrets out of agents' hands altogether.

Opening case: "I never sent that"

Meridian's accounts payable team uses an agent to process supplier queries. Last month, a supplier received an email from a payables clerk's mailbox confirming that a disputed USD 120,000 invoice was "approved for immediate payment". Payment was made. The invoice turned out to be fraudulent.

The clerk says she never sent the email. The mailbox log shows the email was sent by her account, from a server IP address, at 02:13. Investigation finds that the agent was configured with the clerk's own username and password "so it can work in her inbox", and that an instruction hidden in an earlier supplier email told it to confirm approval.

The agent also calls Meridian's ERP system with a static API key stored in a configuration file, shared by five other automations.

By the end of this section you will be able to explain why nobody can prove who approved the payment, and redesign the agent's identity so that next time the logs answer the question unambiguously.

The identities in an AI system

AI systems involve more kinds of identity than traditional applications, and each needs an owner and an appropriate way to authenticate [5]. Figure 4.15 shows the types.

Human and non-human identity types in an AI estate, with anti-patterns
Figure 4.15 Human and non-human identity types in an AI estate, with anti-patterns
Identity type Examples Owner How it should authenticate
Human Employees, customers, administrators, reviewers The person; HR or customer identity system SSO with phishing-resistant MFA
Workload Inference service, training pipeline, RAG indexer The team that runs it Workload identity (platform-issued, short-lived)
Agent An assistant acting for a user; an autonomous agent A named business or technical owner Its own workload identity, plus delegated user context when acting for someone
Tool / MCP server A calendar API, a database connector The tool's owner Mutual TLS or OAuth client credentials
External Model provider APIs, partner agents The vendor relationship owner Provider-issued keys or federated tokens, stored in a vault

Agents deserve special mention. An agent is not a user and not just a service: it makes decisions, acts on someone's behalf, and may run for long periods. Treat each agent as a distinct non-human identity with a named human owner, so its actions can be attributed, and its access reviewed and revoked, independently.

The figure lists three anti-patterns, and the opening case has two of them: an agent running on a person's account, and a shared, long-lived key copied between automations.

Non-repudiation: who really did this?

Non-repudiation means an action can be reliably attributed so that the actor cannot plausibly deny it. In agentic systems this is hard: was the email sent by the clerk, by the agent, or by an attacker who injected an instruction? Four design choices preserve attribution [16][17].

Delegation, not impersonation

Figure 4.16 compares the two patterns.

Impersonation gives the agent the user's identity and full power; delegation records both identities with narrow scope
Figure 4.16 Impersonation gives the agent the user's identity and full power; delegation records both identities with narrow scope
  • With impersonation, the agent uses the user's own credentials. Its actions look exactly like the user's, logs cannot tell them apart, and the agent holds all of the user's power.
  • With delegation, the agent presents a token that records both identities ("agent X acting on behalf of user Y") with only the permissions needed for the task. OAuth 2.0 Token Exchange (RFC 8693) supports this: it issues a new token carrying the user as the subject and the agent as the actor.

Bound tokens, signatures and logs

  • Bound tokens: tokens tied to a key the client holds (sender-constrained tokens, for example through mutual TLS or DPoP), so a stolen token cannot be replayed from elsewhere.
  • Signatures on significant requests or agent messages, so their origin can be verified later.
  • Tamper-evident logs that record the full chain: user, agent, tool, parameters, result, the untrusted content the agent had just processed, and the policy decision.

Worked example: the same email, two designs

Question Impersonation (as built) Delegation (redesigned)
Whose identity sent the email? The clerk's Token: subject = clerk, actor = AP agent
Could the agent approve payments? Yes: it had every right the clerk had No: scope is read_inbox, draft_reply; sending approval messages requires the clerk's step-up confirmation
What does the log show at 02:13? "clerk@meridian sent email" "AP agent, on behalf of clerk, drafted reply; send blocked pending clerk approval; preceding input: supplier email #8812"
Can the clerk deny it? Plausibly, and nobody can disprove her The log shows exactly what the agent did and that the clerk did not approve

With delegation, the fraud also fails: the agent cannot send an approval on its own.

Machine-to-machine authentication

The weakest pattern is a long-lived API key pasted into configuration, which is how the AP agent reaches the ERP. Better options, strongest first:

  1. Workload identity federation: the platform (a cloud provider, Kubernetes, or a framework such as SPIFFE [18]) issues each workload a verifiable identity, which it exchanges for short-lived access tokens. No secret is stored.
  2. Mutual TLS with certificates issued and rotated automatically.
  3. OAuth client credentials with short-lived tokens.
  4. Static API keys only where nothing better is supported (for example, some external model providers), and then stored in a vault, injected at runtime, scoped, rotated, monitored, and never placed in prompts, code or logs.

A static key shared by six automations has two extra problems: one compromise exposes all six, and logs cannot say which automation made a call.

Federating AI tools for people

AI tools used by staff should join the organization's identity system rather than keep their own accounts:

  • Single sign-on (SSO) with SAML or OpenID Connect, so access follows the corporate identity and ends when someone leaves.
  • SCIM provisioning to create, update and remove accounts automatically [20].
  • Phishing-resistant MFA (FIDO2 passkeys or security keys) for AI platforms, especially for administrators and anyone who can change models, prompts or guardrails [19].
  • Conditional access: allow sensitive AI tools only from managed devices or trusted locations.
  • Step-up authentication: require re-authentication before high-impact actions, such as approving an agent's payment, sending an agent-drafted approval, or exporting a model.

Secrets for AI platforms

AI systems handle many secrets: model provider keys, database credentials for RAG, tool tokens and signing keys. Manage them with [5][6]:

  • a vault as the single store, with access logged;
  • runtime injection into workloads, never baked into images, notebooks or configuration files;
  • credential brokering for agents: the agent never sees raw secrets. When it calls a tool, the harness or a broker attaches a short-lived, narrowly scoped credential to the call (Figure 4.17). Even a fully compromised agent cannot leak a long-lived secret, because it never had one;
  • secret scanning of code, notebooks, prompts and logs;
  • fast revocation, rehearsed, so an exposed key can be killed in minutes. The LiteLLM compromise in section 3.7 shows why: its payload specifically harvested AI provider keys and pipeline secrets.
A credential broker attaches short-lived, scoped credentials to agent tool calls so the agent never holds secrets
Figure 4.17 A credential broker attaches short-lived, scoped credentials to agent tool calls so the agent never holds secrets

Exam lens. "The agent uses the user's credentials" or "an API key is in the prompt or config" are always findings. Look for answers with a distinct agent identity, delegated, scoped, short-lived tokens, and brokered credentials the agent never sees.

The opening case, resolved

  • Why nobody can prove who approved the payment: the agent impersonated the clerk using her password, so the mailbox log cannot distinguish clerk from agent, and the agent held all of her authority, including sending approvals.
  • The redesign:
  • a distinct identity for the AP agent, with a named owner;
  • delegated tokens via token exchange (subject = clerk, actor = agent) with read and draft scopes only;
  • step-up confirmation by the clerk for any message that approves or changes a payment;
  • workload identity federation to the ERP in place of the shared static key, or at least a unique vaulted key per automation;
  • brokered credentials, so the agent never holds secrets;
  • tamper-evident logs recording the chain, including the untrusted email the agent had just read.

Check your understanding

Try each before reading the reasoning.

1. An AI assistant needs to read a user's calendar to schedule meetings. Which design best preserves least privilege and attribution?

Reasoning: a delegated, scoped OAuth token (calendar read, and perhaps create-event), issued to the assistant's own identity acting on behalf of the user, short-lived and logged with both identities. Not the user's password, and not a full mailbox scope.

2. Rank these for a training job that reads cloud storage: a static access key in a vault; workload identity federation; an administrator's personal key; OAuth client credentials with short-lived tokens.

Reasoning: best to worst: workload identity federation; OAuth client credentials with short-lived tokens; a static key in a vault (acceptable only if nothing better exists); an administrator's personal key (never).

3. An agent was prompt-injected and tried to send all its environment variables to an external URL. With credential brokering in place, what could it leak?

Reasoning: no long-lived secrets, because the agent never held any; brokered credentials are attached per call, short-lived and narrowly scoped. Egress controls and action-layer policy should also block the outbound call.

Key takeaways

  • AI systems contain humans, workloads, agents, tools and external services. Each needs an owner and a suitable authentication method.
  • Treat each agent as a distinct non-human identity with a named human owner.
  • Delegation, not impersonation: tokens that name both user and agent, with narrow scope (OAuth Token Exchange), bound to the client, with signed requests and tamper-evident logs.
  • Machine-to-machine: workload identity federation first; static keys last, vaulted and rotated.
  • Staff AI tools use SSO, SCIM, phishing-resistant MFA, conditional access and step-up for high-impact actions.
  • Agents should never see raw secrets: vault, runtime injection, credential brokering, scanning and rehearsed revocation.