OAuth for AI agents: what to grant, what to watch
OAuth gives an AI agent standing access to company data. What to grant, how to handle its tokens and what to watch after consent, using the Drift breach.
On this page7 sections
An AI agent connected through OAuth acts with a person’s delegated access for as long as its token lives, so the risk sits less in the moment of consent than in everything the agent does afterwards. Grant the narrowest scopes the task needs, keep tokens short-lived and bound to one service, and investigate what the agent actually does with the grant, read against the person it acts for. The 2025 Salesloft Drift breach shows why the last part matters: the stolen tokens were valid, so every request arrived as the integration itself.
What an OAuth grant gives an AI agent
OAuth lets a person or an admin authorize an application to call an API on their behalf without handing over a password. The application receives an access token, usually short-lived, and often a refresh token that mints new access tokens without asking the person again. The scopes on the grant set what the token can reach: one mailbox, or every file the person can open.
For AI agents, that delegation is the point. A meeting assistant reads calendars and email, a coding agent reads repositories, a sales agent reads and writes CRM records. Each acts as an extension of the person who connected it, with that person’s access, at machine speed.
Two defaults decide how many of these grants exist before security reviews any of them:
- In Microsoft Entra ID, all users are allowed by default to consent to applications for permissions that don’t require administrator consent (opens in a new tab), such as letting an app access their mailbox. Microsoft recommends allowing user consent only for apps from verified publishers.
- In Google Workspace, the default for unconfigured third-party apps is to allow users to access any third-party apps (opens in a new tab). Admins can restrict this and review requests instead.
In Entra, tightening the setting governs future grants only: Microsoft notes that existing consent grants remain unchanged (opens in a new tab) and have to be reviewed and revoked on their own.
Four ways an agent’s OAuth grant goes wrong
- The scopes are broader than the task. An agent that summarizes meetings does not need to write to Drive. The OAuth 2.0 Security Best Current Practice, RFC 9700 (opens in a new tab), says the privileges associated with an access token should be restricted to the minimum required. Broad scopes turn a narrow assistant into a reader of everything its owner can see.
- The tokens outlive their reason. A refresh token keeps working after the pilot ends, the project closes or the person who connected the agent changes role. A grant made for one quarter can still be live a year later.
- The vendor holds the keys. When an agent runs as a SaaS service, the vendor stores the tokens of every customer that connected it. One breach at the vendor hands an attacker valid access to all of them.
- The token travels further than intended. In agent toolchains a token can be handed from one service to the next. The Model Context Protocol’s authorization specification (opens in a new tab) requires an MCP server to validate that a token was issued specifically for it and to accept or transit no other token. Its security guidance (opens in a new tab) names forwarding a client’s token to a downstream API “token passthrough”, an anti-pattern that can create a confused deputy, where the downstream API trusts the token as if the server had validated it.
The Drift breach: valid tokens, the integration’s own access
In August 2025, Google’s Threat Intelligence Group reported that an actor it tracks as UNC6395 targeted Salesforce customer instances through compromised OAuth tokens associated with the Salesloft Drift third-party application (opens in a new tab), from as early as August 8 through at least August 18, 2025. Drift is a chatbot that companies connected to Salesforce so that website visitors could reach them, as Cloudflare described its own integration (opens in a new tab). The integration held OAuth tokens to each customer’s CRM, the same position an AI agent holds.
What the actor did with the tokens is the part to study. According to Google’s report:
- It ran count queries against Accounts, Opportunities, Users and Cases, then systematically exported large volumes of data.
- It searched the exported data for secrets: AWS access keys, passwords and Snowflake-related access tokens. Google assessed its primary intent as harvesting credentials.
- It deleted query jobs to cover its tracks, though the logs themselves were not affected.
- It also held tokens for the Drift Email integration, and used them on August 9 to access email from a very small number of Google Workspace accounts.
Victims described what that meant in their own systems. Cloudflare, for one, reported that the actor exfiltrated data from its Salesforce tenant between August 12 and 17, 2025 (opens in a new tab), found 104 Cloudflare API tokens in that data, and rotated all of them.
On August 20, Salesloft and Salesforce revoked all active access and refresh tokens for the Drift application. Salesloft later reported, from Mandiant’s investigation, that the actor accessed the Salesloft GitHub account from March through June 2025 (opens in a new tab), then accessed Drift’s AWS environment and obtained OAuth tokens for Drift customers’ technology integrations.
Google states that the issue did not stem from a vulnerability in the core Salesforce platform. Every request carried a token a customer had granted. A control that asks only whether the token is valid said yes the whole time.
What to grant: a checklist
- Scope to the task. Read before write, one resource before many, and no catch-all scopes. After Drift, Google told Salesforce admins to review and restrict connected app scopes (opens in a new tab) and avoid overly permissive ones such as
full. - Bind each token to one audience. RFC 9700 says access tokens should be audience-restricted to a specific resource server. The MCP specification requires clients to name the target server with Resource Indicators (RFC 8707), and servers to reject tokens issued for anyone else.
- Keep refresh tokens on a short leash. RFC 9700 requires refresh tokens for public clients to be sender-constrained or rotated. Shorter session timeouts make a stolen token stop working sooner.
- Restrict where tokens work from. Enforce IP restrictions on connected apps where the platform supports them, as Google recommended after Drift.
- Put consent behind review. In Entra, limit user consent to verified publishers and low-impact permissions and turn on the admin consent workflow. In Google Workspace, restrict unconfigured third-party apps and review requests.
- Inventory and revoke. Review existing grants on a schedule, and revoke a grant when its owner changes role or leaves.
Where the checklist stops
Every item above narrows what a token can do. None of them says what a valid token is doing right now.
What to watch after consent
A narrow, well-managed grant can still be misused: by an attacker holding the token, by an agent going past its task, or by the person directing it. Catching that means reading behavior against intent, meaning the grant, the purpose it was made for and the person the agent acts for. The Drift activity turns into concrete questions:
- Volume against purpose. Does a chatbot that answers website visitors need to export every Case record? A bulk export through an integration’s token is the signal, however valid the token.
- The shape of reconnaissance. Count queries across many objects, followed by exports, is enumeration, not a workflow.
- What the export holds. Objects with free text, such as support cases where customers paste keys and passwords, carry more than records. Cloudflare found 104 of its own API tokens in what was taken.
- Where requests come from. New IP ranges, Tor exit nodes or unfamiliar user agents on an integration that normally calls from its vendor’s infrastructure. Google’s indicators for UNC6395 included user agents such as
Salesforce-Multi-Org-Fetcher/1.0and traffic from Tor exit nodes. - Clean-up. Deleted query jobs after a burst of access is a reason to escalate.
- The person behind the agent. Is the person who connected it still in the same role, still employed, still using the tool? An agent working while its owner is offline or gone is a case to open.
No single item is a verdict. A bulk export can be a migration and a new IP can be a vendor change. This is the shape of every insider case: legitimate access, ordinary-looking actions, and a meaning that appears only when the sequence is read in order, with business context.
An engineer's Claude Code agent reads 1,200 Finance files on its own, outside its task
Signed inClaude Code runs with the engineer's own access
ViewedClaude Code opens 1,200 Finance files in Google Drive
FlaggedThe task the engineer gave Claude Code never mentions Finance
An agent with a token is an insider
Identity and access tools decide who may hold access. Insider Risk work decides whether what is being done with that access makes sense. An AI agent with an OAuth token falls in the second category: it acts on a person’s behalf, with that person’s access, and its actions belong in the same investigation as the person’s own. That is how Above approaches AI agent risk: its AI investigators work every insider and AI-agent risk to a verdict and hand the security team a finished case. The same reading applies to agents connected without approval, covered under shadow AI, and to stolen tokens, which behave like any compromised account.
Frequently asked questions
What OAuth scopes should an AI agent have?
An AI agent should hold the narrowest scopes its task needs: read before write, one resource before many, and never a catch-all scope such as Salesforce's full. RFC 9700 says a token's privileges should be restricted to the minimum required. Review the scopes again whenever the agent's task or its owner's role changes.
How do OAuth token compromises enable AI agent impersonation attacks?
A stolen OAuth token lets an attacker call APIs exactly as the agent would, with the same scopes and a valid credential, so every access check passes. In the 2025 Salesloft Drift breach, tokens stolen from the vendor were used to export Salesforce data and hunt it for credentials, and access checks could not tell the attacker from the integration.
What are the best practices for managing OAuth tokens for AI agents?
Keep access tokens short-lived, rotate or sender-constrain refresh tokens, bind each token to one resource server and restrict where it can be used from. Never pass a token from one service to the next. Revoke grants when their owner changes role or leaves, and watch what each token is used for, because a valid token can still be misused.
What is the OAuth threat model for AI agents?
The OAuth threat model for an AI agent covers four failures: scopes broader than the task, tokens that outlive their purpose, tokens stored at the agent's vendor where one breach exposes every customer, and tokens passed to services they were not issued for. Each leaves an attacker, or a misbehaving agent, holding valid access.
What is the biggest insider threat from AI agents?
The biggest insider threat from AI agents is valid access used for the wrong purpose. An agent acts with a person's delegated permissions, so a stolen token, an agent running past its task and a person directing it toward harm all pass access checks. Only behavior, read against the task and the owner, shows the difference.
About the author

The Above team
The Above team builds Insider Risk management for humans and AI agents. Its AI investigators work every insider and AI-agent risk to a verdict and hand the security team a finished case.







