Least-Privilege Credentials for AI Agents and Service Accounts
When an AI agent runs with an administrator’s account, a single mistake in its instructions can change directories, reset passwords or delete data. The agent does not need broad rights to do its job. It needs its own identity with only the rights for that job, and nothing else.
Rule 1: one identity per agent
Do not let agents share an account with a person or with another service. Create a dedicated identity for each
agent in Active Directory or in Microsoft Entra ID, named for its job, for example svc-agent-ticket-summary. The name
tells the audit log who acted.
Set the account so that it cannot sign in interactively and cannot be used to log on to servers. Limit it to the computers and services it needs.
Rule 2: no stored passwords where possible
Long-lived passwords stored in scripts or configuration files are the most common way agent credentials leak. Where the platform supports it, use a managed identity. Microsoft describes managed identities as a way for applications to obtain tokens without the developer managing the credentials. Credentials are not visible to the people who manage the application. If a managed identity is not available, store the secret in a vault, rotate it on a schedule and never put it in a prompt or a log.
Rule 3: grant rights by task
Start with no rights and add only what the task needs. Read-only access to one share is a better starting point than full control of a folder tree. Review the rights every quarter. If the agent’s task changed, the rights should change with it.
Rule 4: keep administrator work separate
An agent must never hold a domain administrator right. If an agent needs a change that requires that level, a person should perform the change through a separate, audited process. This is the same principle that applies to human admins in Least privilege and admin accounts in Active Directory.
Rule 5: log what the identity does
Enable auditing for the agent’s account. Record sign-ins, object changes and file access. Review the log for actions that fall outside the task. A sign-in at an unusual hour or a read of a folder the agent has never touched is worth an alert.
Checklist
- Each agent has its own identity with a clear name.
- The identity cannot sign in interactively or hold administrator rights.
- Secrets are in a vault, or replaced by a managed identity.
- Rights match the current task and are reviewed each quarter.
- Audit logs for the identity are sent to a central place.