This lesson treats “give the agent the password” as an architecture decision and shows why it fails on scope, attribution, revocation and confidentiality all at once. It then walks through the alternatives an engineer can actually build: delegated OAuth access, dedicated agent identities, credential brokers that keep secrets out of the model, and fill-without-reveal with its residual risks. By the end you should be able to choose a credential pattern for an agent integration and state its threat model in a few lines.
The problem was named in 2012
The OAuth 2.0 specification opens with a list of what goes wrong when a third-party application is given a user’s password. Read it with “AI agent” in place of “third-party application” [7]:
- Third-party applications “are required to store the resource owner’s credentials for future use, typically a password in clear-text.”
- They “gain overly broad access to the resource owner’s protected resources, leaving resource owners without any ability to restrict duration or access to a limited subset of resources.”
- Resource owners “cannot revoke access to an individual third party without revoking access to all third parties, and must do so by changing the third party’s password.”
- “Compromise of any third-party application results in compromise of the end-user’s password and all of the data protected by that password.”
The OAuth 2.0 Security Best Current Practice (RFC 9700, 2025) goes further and states that the resource owner password credentials grant “MUST NOT be used”, because it “insecurely exposes the credentials of the resource owner to the client”, increases the places credentials can leak, trains users to type passwords in the wrong places, and does not work with two-factor or multi-step authentication [11]. An agent that logs in by replaying your password is that deprecated pattern, implemented by hand.
Properties of the credential, compared
| Property | Shared password | Scoped OAuth access token | Dedicated agent account |
|---|---|---|---|
| Bearer? | Yes | Usually yes (RFC 6750); can be sender-constrained | Yes, if password-based |
| Scope | Everything the user can do | scope parameter, enforced by the resource server |
Role-based, set by an admin |
| Audience | Every service that accepts the password, including reused ones | Can be bound to one resource server (RFC 8707) | One service |
| Lifetime | Until changed | Minutes to hours; refresh governed by policy | Until disabled |
| Revocation | Change password, breaking all other uses | Revoke grant or token | Disable account |
| Attribution in logs | Indistinguishable from the user | Client identity is known to the authorisation server | Distinct principal |
| MFA | Bypassed or broken | Handled at consent time | Configurable |
Bearer token means “any party in possession of a bearer token (a ‘bearer’) can use it to get access to the associated resources (without demonstrating possession of a cryptographic key)” [12]. Passwords share that property and lack every other row’s improvements.
Where a password leaks in an agent system
Context window. If a tool returns the password to the model, or the user pastes it, it is now input to every subsequent model call. OWASP LLM02:2025 lists security credentials among the sensitive data LLM applications risk disclosing through output, and recommends least-privilege access to such data as a primary control [5].
Persistence. Prompts and tool results are typically retained in conversation history, provider-side logs, tracing and evaluation pipelines. Treat any string that has entered a context window as written to several logs you do not fully control.
Injection-driven exfiltration. Indirect prompt injection lets third-party content steer tool calls [4]. With a password in context and any egress (a fetch tool, an email tool, even a rendered link), the attacker’s path is short. This is the lethal trifecta with the password as the private data [6].
Reuse amplification. Das et al. measured 42–51% of users reusing passwords across sites [2]; Thomas et al. found 7–25% of breach-exposed passwords matched the victim’s Google account [3]. A password leaked from an agent’s transcript is a credential-stuffing input for other services.
Pattern 1: delegated access (preferred)
Use the target service’s OAuth authorisation flow so the agent
receives an access token, never the password. Ask for the narrowest
scope and, where the authorisation server supports RFC 8707, a
resource parameter so the token’s audience is the one API
the agent needs [13]. RFC 9700
recommends that access tokens be restricted to “the minimum required for
the particular application or use case” and audience-restricted to a
specific resource server [11].
For MCP-based integrations, the 2025-06-18 authorisation specification requires this discipline: MCP servers “MUST validate that access tokens were issued specifically for them as the intended audience, according to RFC 8707”, and clients “MUST NOT send tokens to the MCP server other than ones issued by the MCP server’s authorization server” [14]. Token passthrough, where a server forwards a client’s token to a downstream API, is explicitly forbidden.
Where the agent acts on behalf of a user through an intermediary,
OAuth 2.0 Token Exchange (RFC 8693) lets the intermediary obtain a
downstream token and record the delegation chain in the act
(actor) claim, preserving attribution [15].
Pattern 2: a distinct agent principal
When a service has no OAuth integration but supports multiple users and roles, create an account for the agent with the lowest role that works. Google’s agent-security framework argues that agents “acting on behalf of teams or groups need distinct identities and clear authorization models”, that maximum permission levels must be “definable and enforceable”, and that users “must also retain the ability to inspect and revoke any authority delegated to an agent” [9]. A distinct principal gives you all three, plus clean audit trails.
Pattern 3: a credential broker
If the agent must call an API that only accepts a static secret, keep the secret in a component the model cannot read and expose a narrow tool instead:
# Illustrative credential broker. The model calls fetch_statement(); it never sees the key.
import httpx
ALLOWED = {("GET", "api.supplier.example", "/v2/statements")} # method, host, path prefix
def fetch_statement(month: str, *, vault, audit) -> bytes:
method, host, path = "GET", "api.supplier.example", f"/v2/statements/{month}"
if not any(method == m and host == h and path.startswith(p) for m, h, p in ALLOWED):
raise PermissionError("not in broker allowlist")
secret = vault.get("supplier_api_key") # resolved here, not in the model
r = httpx.get(f"https://{host}{path}", headers={"Authorization": f"Bearer {secret}"},
timeout=10, follow_redirects=False) # don't follow redirects off-host
audit.record(tool="fetch_statement", target=f"{host}{path}", status=r.status_code)
r.raise_for_status()
return r.content # response only; no headers echoedThe broker binds three things the model cannot change: the destination, the operation and the credential. That is Hardy’s capability fix for the confused deputy expressed as a tool: the authority and the designation of what it applies to travel together [16]. It also centralises logging and revocation.
Pattern 4: fill without reveal
For browser-only services with no API, a credential manager can fill the login form on the agent’s behalf so the stored password never enters the model context. Three residual risks need explicit handling.
- The DOM is readable. Once filled, the value sits in a page input. Page scripts, extensions with host permissions and any automation framework attached to that tab can read it. The pass privacy policy states this boundary for its own implementation: the agent does not receive stored passwords, but software that can read or control the page, including an agent’s browser-automation or “computer use” tool, may be able to read a filled login [10].
- Fill policy. Silver et al. showed that some autofill policies let a remote network attacker extract multiple passwords from a password manager without any user interaction [17]. A manager filling for an agent should match the exact origin, refuse cross-origin frames and require an approval step for sensitive sites.
- Composition. If the same agent has a browser tool with page-read access on the credential’s origin, fill-without-reveal reduces to “reveal with extra steps”. Separate the roles: the component that fills credentials should not be the component that can read arbitrary page content, or the agent session should not have read access to that origin’s DOM.
Pattern 5: passkeys for humans
Passkeys are WebAuthn credentials: key pairs generated by an authenticator and “scoped to a specific WebAuthn Relying Party”, usable only by origins belonging to that relying party [8]. They are phishing-resistant because the browser enforces that scoping. They are not designed for delegation, and that is the point: keep human accounts on passkeys with user verification, and give agents their own delegated access rather than trying to automate a human’s passkey ceremony. Where humans still use passwords, NIST SP 800-63B-4 requires verifiers to “allow the use of password managers and autofill functionality”, which supports unique passwords per service [1].
Decision guide
Does the service support OAuth / app integrations?
├─ yes → Pattern 1: narrowest scope, audience-bound token, short lifetime
└─ no → Does it support multiple users/roles?
├─ yes → Pattern 2: dedicated agent account, lowest role, MFA where possible
└─ no → Does it have an API with a static key?
├─ yes → Pattern 3: broker; key never in model context
└─ no → Pattern 4: fill-without-reveal, approval per use,
no page-read tools on that origin in the same session
In every case: log each use, set an expiry or review date, and know how to revoke.
Worked threat model
A property management agency wants an agent to download monthly supplier statements.
- Assets: supplier portal access (includes payment details), statements (contain tenant names).
- Untrusted inputs: the portal’s support-message page; emails the agent triages.
- Naive design: password in the system prompt; browser tool with full page read. Failure: an injected support message instructs the agent to post its instructions, including the password, into a reply field. The password is reused on two other systems.
- Chosen design: the portal offers a read-only statements API with per-integration keys. Pattern 3 broker with a single allowlisted path; key stored in the organisation’s secret manager; broker logs each call; key rotated quarterly; agent has no browser tool for this task. Residual risk: the agent can fetch any month’s statement. Accepted, because that is the job.
Key takeaways
Giving an agent a password reproduces the exact problems OAuth was designed to solve, which is why current OAuth security guidance forbids the password grant outright: the client gets unlimited, long-lived, unattributable authority that can only be revoked by breaking every other use. In agent systems the damage is compounded because a password that enters a model’s context is persisted in logs and reachable by prompt injection through any egress tool. Prefer delegated, scoped, audience-bound tokens; failing that, a distinct agent principal; failing that, a broker that binds destination, operation and secret outside the model. Fill-without-reveal is a reasonable last resort for browser-only services, provided the agent session cannot also read or control the page the credential was filled into.
How primitive approaches this. Beyond filling logins, the pass privacy policy states that for each connected agent it keeps the permissions you approve, the purpose given, “approval and expiry times, and an audit receipt of each use”; that audit receipts “never contain the password or other secret”; and that “You can revoke an agent’s access at any time” [10].
Sources and further reading
- Temoshok, D., Fenton, J., Choong, Y.-Y., Lefkovitz, N., Regenscheid, A., Galluzzo, R., & Richer, J. (2025). Digital Identity Guidelines: Authentication and Authenticator Management (NIST SP 800-63B-4). NIST. https://pages.nist.gov/800-63-4/sp800-63b.html
- Das, A., Bonneau, J., Caesar, M., Borisov, N., & Wang, X. (2014). The Tangled Web of Password Reuse. NDSS 2014. https://www.ndss-symposium.org/ndss2014/programme/tangled-web-password-reuse/
- Thomas, K., Li, F., Zand, A., Barrett, J., Ranieri, J., Invernizzi, L., et al. (2017). Data Breaches, Phishing, or Malware? Understanding the Risks of Stolen Credentials. ACM CCS ’17, 1421–1434. https://doi.org/10.1145/3133956.3134067
- Greshake, K., Abdelnabi, S., Mishra, S., Endres, C., Holz, T., & Fritz, M. (2023). Not what you’ve signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection. AISec ’23, 79–90. https://doi.org/10.1145/3605764.3623985
- OWASP Gen AI Security Project. (2025). LLM02:2025 Sensitive Information Disclosure. https://genai.owasp.org/llmrisk/llm022025-sensitive-information-disclosure/
- Willison, S. (2025, 16 June). The lethal trifecta for AI agents. https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/
- Hardt, D. (Ed.). (2012). The OAuth 2.0 Authorization Framework (RFC 6749), Section 1. IETF. https://www.rfc-editor.org/rfc/rfc6749
- W3C. (n.d.). Web Authentication: An API for accessing Public Key Credentials, Level 3. https://www.w3.org/TR/webauthn-3/
- Díaz, S., Kern, C., & Olive, K. (2025). Google’s Approach for Secure AI Agents: An Introduction. Google. https://research.google/pubs/an-introduction-to-googles-approach-for-secure-ai-agents/
- Primitive AI (PRIMITIVE AI LABS PTY LIMITED). (2026, 25 October). Primitive Pass Privacy Policy, section 03 (“AI agent access”). https://pass.primitiveai.com.au/privacy.html (primitive’s own statements; effective 25 October 2026)
- Lodderstedt, T., Bradley, J., Labunets, A., & Fett, D. (2025). Best Current Practice for OAuth 2.0 Security (RFC 9700, BCP 240), Sections 2.3–2.4. IETF. https://www.rfc-editor.org/rfc/rfc9700
- Jones, M., & Hardt, D. (2012). The OAuth 2.0 Authorization Framework: Bearer Token Usage (RFC 6750). IETF. https://www.rfc-editor.org/rfc/rfc6750
- Campbell, B., Bradley, J., & Tschofenig, H. (2020). Resource Indicators for OAuth 2.0 (RFC 8707). IETF. https://www.rfc-editor.org/rfc/rfc8707
- Model Context Protocol. (2025). Specification 2025-06-18: Authorization; Security Best Practices. https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization and https://modelcontextprotocol.io/specification/2025-06-18/basic/security_best_practices
- Jones, M., Nadalin, A., Campbell, B. (Ed.), Bradley, J., & Mortimore, C. (2020). OAuth 2.0 Token Exchange (RFC 8693). IETF. https://www.rfc-editor.org/rfc/rfc8693
- Hardy, N. (1988). The Confused Deputy (or why capabilities might have been invented). ACM SIGOPS Operating Systems Review, 22(4), 36–38. https://doi.org/10.1145/54289.871709
- Silver, D., Jana, S., Boneh, D., Chen, E., & Jackson, C. (2014). Password Managers: Attacks and Defenses. 23rd USENIX Security Symposium. https://www.usenix.org/conference/usenixsecurity14/technical-sessions/presentation/silver