Agentic security in the enterpriseAdvancedLesson 1475 min read

Agent identity: non-human identities and least privilege

Every agent should log in as itself, with short-lived credentials and only the permissions its job needs. Shared human accounts and forever-keys turn every mistake into a mystery.

Lesson in motion

In 60 seconds

Agent identity: non-human identities and least privilege

Every agent should log in as itself, with short-lived credentials and only the permissions its job needs. Shared human accounts and forever-keys turn every mistake into a mystery.

1/6
In simple words
In a big office, every worker gets their own ID card. It opens only the doors they need, and it stops working when they leave. An AI agent is a new kind of worker. It needs its own card too, not a copy of someone else's.
A non-human identity (NHI) is any identity used by software instead of a person: service accounts, API keys, cloud roles, bot accounts, and now AI agents. In many companies, non-human identities already outnumber human ones, and they are often less well managed: no owner, no expiry, broad rights.
The earlier lesson on secrets and identity set the rules for one agent. Here the question is scale: how does a company issue, track and remove identities for hundreds of agents without losing control?

Common anti-patterns

What we often find
  • The agent logs in with a real employee's account
  • One API key shared by every agent in a team
  • Keys that never expire, pasted in config files
  • Admin rights "because it was easier to set up"
  • No owner listed; nobody knows if it is still needed
What good looks like
  • One identity per agent, per environment (test and production separate)
  • Short-lived credentials issued at run time
  • Secrets kept in a secrets manager, fetched by tool code, never shown to the model
  • A role listing the exact permissions the job needs
  • A named owner and an expiry or review date on every identity

Short-lived beats long-lived

A long-lived key is a standing risk. If it leaks in a log, a screenshot or a prompt, it works for whoever finds it until someone notices. A short-lived credential expires on its own, often in minutes or hours. The agent's runtime gets a fresh one from a trusted issuer when it starts a task.
This is called workload identity: the platform proves which workload is running (this container, this job, this agent) and gives it a credential for that moment. Cloud providers offer their own versions. SPIFFE is an open standard for giving workloads verifiable identities across different platforms. You do not need a specific product; you need the idea: identity comes from where and what the workload is, not from a secret someone copied.
  1. 1

    Agent starts a task

    The runtime, not the model, asks the identity service for a credential.
  2. 2

    Platform proves the workload

    It confirms this really is agent X in environment Y.
  3. 3

    Short-lived token issued

    Scoped to agent X's role. Expires soon.
  4. 4

    Tool code uses the token

    The model calls a tool; the tool holds the token. The model never sees it.
  5. 5

    Token expires

    Nothing to rotate by hand. A leaked copy is soon useless.

Least privilege, written down

AgentNeedsDoes not need
Invoice-reading agentRead invoices folder; write to a review queuePay invoices; read HR files; delete anything
IT helpdesk agentRead tickets; reset passwords for non-admin users after checksChange admin accounts; change security settings
Report-writing agentRead-only access to a reporting database viewWrite access to production tables

Lifecycle: joiners, movers, leavers

  • Joiner: identity created only through the approval process, with owner and role.
  • Mover: when the agent's job changes, its role is reviewed; old permissions are removed, not just added to.
  • Leaver: when the agent is retired or its owner leaves, the identity is disabled and credentials revoked. Orphaned agent identities are a common way in for attackers.
  • Rotation: any remaining long-lived secrets (for systems that cannot issue short-lived ones) are rotated on a schedule and after any suspected leak.
Danger
Never let an agent use a human's password or personal session to "act as them". You lose the audit trail, the person may be blamed for the agent's actions, and you cannot revoke the agent without locking out the person.
Try this. Pick one agent or automation at your workplace. Can you answer: which identity does it use, who owns it, when does its credential expire, and how would you switch it off in one step?

Watch and read more

Lab

An identity plan for three agents: identity, permissions, credential type, owner and off-switch.

~30 min

The problem

You are the identity lead. Three agents are about to go live: an invoice-reading agent, an IT helpdesk agent that can reset passwords, and a sales report agent that queries a database.

  1. For each agent, fill in the starter table.
  2. List permissions as specific actions on specific resources, not "access to finance".
  3. Mark which credential is short-lived and how it is issued. If you must use a static key anywhere, say how it is stored and rotated.
  4. For each agent, write the single action that switches it off in an emergency.
  5. Add one "must never" rule per agent and say where it is enforced (in code, in the identity system, or in the target app, but not only in the prompt).
Starter codetext
agent            | identity name        | environment | permissions (action:resource) | credential type & lifetime | owner | off-switch | must never (enforced where?)
invoice-reader   | agent-invoice-read-prod | prod     |                               |                            |       |            |
helpdesk-agent   |                      |             |                               |                            |       |            |
sales-report     |                      |             |                               |                            |       |            |

You are done when

Hard questions

Try to answer before you reveal. If you can answer these, you understood the lesson.

Q1The helpdesk agent must reset passwords, but never for administrators. Where do you enforce that, and why not in the prompt?Reveal

Enforce it in the identity system or the reset tool's code: the agent's role simply lacks permission on admin accounts, or the tool checks the target's group and refuses. A prompt rule can be talked around by a clever ticket. A permission check in code cannot be persuaded.

Q2Short-lived tokens expire in minutes, but an attacker who controls the agent's runtime can keep asking for new ones. Does short-lived still help?Reveal

Yes, but it is not enough alone. It helps against leaked copies (in logs, prompts, screenshots) and forces an attacker to stay inside the runtime. To stop an active attacker you also need to revoke the agent's ability to get new tokens (disable the identity), which is why a one-step off-switch and monitoring of token requests matter.

Please sign in to continue.

Questions people ask

Isn't one service account for all our agents simpler?

Simpler to set up, much harder to run. With one shared account you cannot tell which agent did what, you cannot give each agent only its own permissions, and revoking it during an incident breaks every agent at once.

What if a system only supports static API keys?

Keep the key in a secrets manager, give it the narrowest rights the system allows, let only the tool code fetch it, rotate it on a schedule, and watch its use. Put that system on the list for a better option later.

Do I need SPIFFE to do this well?

No. SPIFFE is one open standard for workload identity. Cloud platforms have their own workload identity features. What matters is the pattern: identity based on the running workload, short-lived credentials, and no copied secrets.

Should the model ever see a credential?

No. Anything in the model's context can end up in an output, a log or a URL. The model asks for an action; the tool code holds the credential and performs it.

Lesson test

5 questions. Get 3 right (60%) to pass and complete this lesson.

Sign in to take the test and save your progress