Speaker Notes

How to Secure Agents using OAuth — Jared Hanson (Keycard, Passport.js)

Securing AI agents requires moving away from static API keys toward robust OAuth architectures, separating authorization servers in MCP, and adopting advanced patterns like PKI-based identities and transactional authorization.

AI Engineer · 18:59 · YouTube ↗

Talk · solo speaker  Advanced · concepts and protocol architecture

Highlights

4 clips · 3 min of 19 min
    • Long-lived API keys and static secrets create a major security risk for large-scale agent deployments.
    • Developers currently face an impossible choice between broad access and limited agent capabilities.
    • Transitioning to dynamic access using OAuth resolves this trade-off.
    • Early MCP authorization drafts incorrectly collapsed the resource server and authorization server into one.
    • This design caused confusion and pushback from enterprise security and OAuth experts.
    • Correctly modeling MCP servers strictly as OAuth resource servers simplifies server implementation.
    • Dynamic client registration often leaves agents anonymous due to uncredentialed requests.
    • A better approach for verifiable agents is using URLs combined with public key infrastructure (PKI).
    • Agents can sign JWT assertions or HTTP message signatures verified against public keys.
    • Traditional OAuth scopes are too coarse-grained and long-lived for advanced agent tasks.
    • Agents performing commercial or financial actions require transactional permissions and budgets.
    • Rich authorization requests (RAR) provide a specification framework to handle these dynamic permissions.

Questions this video answers

10 · every answer cites the moment it was said
01 Why are static API keys a security risk for AI agents? 2 sources · 1:09

Using long-lived, broadly scoped API keys in configuration files creates massive security vulnerabilities as agent deployments scale. If thousands of agents run with broad access keys, a single compromise exposes all connected systems. We must transition away from these static secrets to dynamic access models.

02 How does the OAuth authorization code flow work? 3 sources · 2:18

The authorization code flow mediates requests between a client application and a resource server via an authorization server. The authorization server authenticates the user, obtains consent, and issues an access token to the client. This token is then used to access protected resources while supporting short-lived, rotated refresh tokens.

03 How did the first version of the Model Context Protocol handle security? 2 sources · 7:01

The initial version of MCP featured no authorization mechanisms at all, prioritizing rapid prototyping primarily for local servers. While it sparked ecosystem interest, it left remote and connected servers entirely unprotected. This required developers to look toward formal authorization protocol drafts.

04 What was wrong with the early MCP authorization specification draft? 2 sources · 8:03

The late March draft erroneously forced MCP servers to implement all of OAuth 2, including token issuance and authentication. This collapsed the authorization server role directly into the resource server, violating core OAuth principles and causing widespread industry criticism.

05 How should MCP servers be modeled in an OAuth architecture? 2 sources · 9:08

MCP servers should act strictly as OAuth resource servers rather than handling their own token issuance. The authorization server must remain a completely separate entity that handles authentication and issues tokens. This simplifies the MCP server's job to simply verifying incoming HTTP tokens.

06 When should agents use the OAuth client credentials flow? 2 sources · 11:03

While the authorization code flow handles end-user delegation, the client credentials flow applies when agents communicate autonomously. Agents use this flow to interact with other agents or MCP servers on their own behalf rather than acting for a logged-in user.

07 Why is dynamic client registration problematic for agent identities? 2 sources · 12:08

Dynamic client registration allows agents to request credentials at runtime without prior manual registration. However, because the registration request itself is uncredentialed, it leaves all agents effectively anonymous. This makes building trust and tracking identity across agent ecosystems extremely difficult.

08 How can we use URLs and PKI for secure agent identity? 2 sources · 13:27

Instead of dynamic registration, we can use standard URLs as client identities in OAuth flows. By leveraging public key infrastructure (PKI) and key sets, agents can sign assertions or HTTP messages. Receiving servers then use corresponding public keys to cryptographically authenticate the agent.

09 What is transactional authorization and why do agent workflows require it? 2 sources · 15:15

Traditional OAuth scopes are often too coarse-grained and long-lived for advanced AI agent operations. Transactional authorization allows agents to obtain permissions on a per-transaction basis, such as approving specific financial budgets or transaction amounts. Specifications like rich authorization requests provide a model for this dynamic requirement.

10 How do we secure downstream interactions and chain of custody for MCP servers? 2 sources · 16:24

When an MCP server calls another internal API or third-party service, basic OAuth connections are no longer sufficient. Developers should implement techniques like OAuth token exchange and identity assertion grants for cross-domain identity chaining. This preserves security visibility across complex multi-agent communication graphs.

Section-by-section summary

4 parts

Moving from static secrets to OAuth for agents

Agents need dynamic access rather than long-lived API keys to prevent security risks at scale. OAuth provides a standardized way to delegate access through short-lived tokens instead of pasting secrets into configs.

Fixing authorization in the Model Context Protocol

Early versions of MCP either lacked authorization or incorrectly combined the resource server and authorization server roles. The updated draft correctly models MCP servers as OAuth resource servers with a separate authorization server.

Expanding OAuth for agent identity and communication

Securing autonomous agents requires moving beyond standard user flows to support agent-to-agent communication and client credentials. Dynamic client registration struggles with anonymity, making alternative approaches like public client strings or PKI-based URLs more promising.

Advanced authorization patterns for complex agent workflows

Future agent interactions demand transactional authorization like rich authorization requests to handle specific budgets or permissions. Additionally, securing multi-step interactions requires chain of custody mechanisms like token exchange and identity chaining across domains.

0:00 / 18:59
k play/pause · f fullscreen · m mute
n next · p previous clip · t highlights/full
< > slower/faster · / search what was said
  • OAuth21× · first 0:23

    A protocol allowing applications to request delegated access to APIs without exposing user credentials.

  • OpenID Connect2× · first 3:59

    An identity layer built on top of OAuth that standardizes user authentication and profile information.

  • Model Context Protocol14× · first 1:21

    An open protocol designed to connect AI chat assistants and agents to external tools and servers.

  • Dynamic Client Registration1× · first 12:06

    An OAuth specification allowing clients to request credentials at runtime instead of manual registration.

  • PKI1× · first 13:32

    Public key infrastructure used alongside URLs to cryptographically authenticate agent identities.

  • Rich Authorization Requests1× · first 15:50

    An authorization specification enabling granular, transaction-based permission grants.

  • OAuth Token Exchange1× · first 16:28

    A security technique used to propagate and exchange tokens when services call downstream APIs.