Skip to main content
SecureAuthSecureAuth
Back to Blog
AI Security
July 14, 2025
5 min read

Inside the Firewall: Securing Internal Tools

Lukasz Radosz
5-Part Series: Architecting Identity for Agentic AI

Internal Deployments: A Unified but Unguarded Domain

Many enterprise AI deployments keep every component behind the corporate firewall: the Identity Provider, the MCP servers, and the tools themselves all operate within a single network boundary. This unified domain of control simplifies identity management, but it does not eliminate the need for robust security. Lateral movement, over-scoped tokens, and implicit trust assumptions are just as dangerous inside the perimeter as outside it.

In Part 3 of this series we focus on how OAuth 2.1 and advanced authorization patterns apply specifically to these fully internal architectures, ensuring that AI agents accessing internal tools are authenticated, authorized, and auditable at every step. We cover delegation with OAuth Token Exchange, fine-grained access with Rich Authorization Requests (RAR), secure token issuance via Pushed Authorization Requests (PAR), and decoupled authentication using Client-Initiated Backchannel Authentication (CIBA).

Fully Internal Architecture

Corporate Firewall

Identity Provider

OAuth 2.1 / OIDC

MCP Server

Tool orchestration

Internal Tools

APIs & microservices

mTLSToken-based accessScoped permissions

Internal Does Not Mean Inherently Secure

Even when every service sits behind the firewall, you must enforce OAuth 2.1 standards. Network proximity is not a substitute for cryptographic proof of identity. Internal systems are frequent targets of lateral movement attacks, and implicit trust between services creates the exact gaps that adversaries exploit.

OAuth 2.1 in a Fully Internal Architecture

In an internal environment, all components — the AI agent (client), IdP, and MCP tool servers — reside within the organization's network. The AI agent can leverage Single Sign-On with the internal IdP, and every tool trusts tokens issued by this IdP. Unlike public integrations, there's no need for multi-tenant federation or external identity trust here. However, internal doesn't mean simplistic — strong security and least privilege are still paramount.

OAuth 2.1 consolidates the best of OAuth 2.0, mandating secure defaults like PKCE and eliminating unsafe legacy flows — even for internal systems. An AI agent that needs user identity should use the Authorization Code flow with PKCE (never the old implicit grant), even if all traffic stays inside the firewall.

Autonomous Agents

Use the Client Credentials flow. The agent authenticates directly with the IdP using its own credentials, receiving a scoped token without any user interaction. Ideal for background jobs, scheduled pipelines, and fully automated workflows.

Human-in-the-Loop

Use the Authorization Code + PKCE flow. A human user explicitly grants consent before the agent acts on their behalf. This preserves user context and ensures that delegated actions are traceable back to a real identity.

Delegation with OAuth Token Exchange (On-Behalf-Of)

In complex internal systems, an AI agent often needs to call multiple microservices or tools in a chain to fulfill a single request. OAuth Token Exchange, defined in RFC 8693, standardizes a secure delegation flow where one service can exchange an access token for a new token to call another service on behalf of the same user. This is commonly called the On-Behalf-Of (OBO) flow.

Suppose an AI agent has a user's token to call Tool A, but fulfilling the request requires data from Tool B. Instead of the agent directly requesting the user's credentials for Tool B, Tool A itself performs a token exchange — presenting the original user token as a "subject token" to the IdP's token endpoint with the grant type urn:ietf:params:oauth:grant-type:token-exchange, indicating it needs a token for Tool B's audience.

Token Exchange (On-Behalf-Of) Flow

AI Agent

Holds user token

Tool A

Receives token, needs Tool B

IdP

Exchanges token (RFC 8693)

Tool B

Accepts new scoped token

User identity is preserved at every hop. No re-authentication required.

All of this happens behind the scenes — the user doesn't have to re-authenticate or even know that multiple services are involved.

Benefits of Token Exchange

End-to-End User Context

Tool B receives a token that represents the user (delegated via Tool A), so it can enforce user-specific authorization and auditing. User identity propagates through the call chain without prompting the user again.

Scoped Delegation

The token issued for Tool B includes claims and scopes specific to Tool B's functions, which might not have been in the original token for Tool A. Each token is tailored to its audience.

Isolation of Services

Tool B only honors tokens issued specifically for itself. It doesn't accept the original token (intended for Tool A only), reducing exposure to misuse from calls that weren't explicitly delegated.

Simplified Trust Management

Tool B doesn't handle user authentication or session management. It trusts the IdP and Tool A's delegation. As long as the IdP only allows authorized clients to perform exchange, Tool B can be confident any request was approved.

Token Type Transformation

The exchange can even change token format if needed. If Tool B is a legacy system that only accepts SAML assertions, the IdP can issue a SAML token in exchange for an OAuth JWT from Tool A.

Least Privilege Throughout

The AI agent orchestrates multi-step workflows without collecting broad privileges upfront. The IdP acts as a central switchboard, issuing service-specific tokens as needed.

Fine-Grained Access with Rich Authorization Requests (RAR)

While OAuth scopes provide a coarse mechanism to limit what an access token can do, modern applications often need more fine-grained control. A scope like read:documents grants access to every document. OAuth 2.0 Rich Authorization Requests (RFC 9396) address this by allowing clients to describe desired access in detail using structured JSON objects instead of flat scope strings.

RAR introduces the authorization_details request parameter carrying a JSON structure. Each object has a mandatory "type" defining the kind of access, plus fields for specifics:

  • locations — resource identifiers (URIs or server endpoints) the client wants to access.
  • actions — the operations the client wants to perform (read, write, delete).
  • datatypes — the types of data involved or affected.
  • identifier — an ID for a specific resource instance (account number, file ID).
  • privileges — the level or role of access being requested.

For example, an AI agent needing to retrieve a finance report from an internal file service could send:

{
  "type": "file_access",
  "locations": ["https://files.internal.corp/finance"],
  "actions": ["read"],
  "identifier": "Q4-report.pdf"
}

This tells the IdP exactly what the agent wants: read access to Q4-report.pdf in the finance file repository. The IdP decides (based on policy or user input) whether to allow that specific access, and issues a token constrained to that file and action.

RAR in the Authorization Flow

  1. 1
    Agent Sends RAR Details

    The AI agent initiates an authorization request including the authorization_details JSON (rather than or in addition to the usual scope parameter), along with standard parameters like client ID, redirect URI, and PKCE code challenge.

  2. 2
    User Authentication & Consent

    The IdP authenticates the user via SSO. It detects the rich authorization details and displays a consent page listing the requested access in detail — e.g. "This AI assistant is requesting read access to Q4-report.pdf on the Finance File Server." Far clearer than a generic scope name.

  3. 3
    Token Issuance

    If the user approves, the IdP issues an authorization code which the agent exchanges for an access token. The resulting token carries the rich authorization — as structured claims or a reference to stored details — limited to exactly what was approved.

  4. 4
    Accessing the Resource

    The AI agent calls the internal API with this token. The resource server validates the token and enforces the constraints — ensuring the user, file, and action all match what was authorized.

RAR vs. Scopes

RAR doesn't replace scopes entirely — it supplements them. You might still use high-level scopes to indicate general categories of access, and use RAR for specifics within those categories. For example, define a scope like tools.access to signal the agent is allowed to request tool access, but require authorization_details specifying exactly which tool and action. A token without authorization_details becomes essentially useless for any real action.

Securing Authorization Flows with Pushed Authorization Requests (PAR)

In a traditional OAuth flow, the client redirects the user's browser to the IdP's authorization endpoint with a long URL containing all request parameters — client ID, scopes, redirect URI, state, and potentially RAR details. This front-channel request can be susceptible to tampering and may expose sensitive details in browser logs. Pushed Authorization Requests (RFC 9126) address these concerns by moving the authorization request from the front channel to a back-channel POST request.

How PAR Works

Instead of immediately redirecting the user with a full query string, the client first opens a direct connection to the IdP's PAR endpoint. It sends all authorization request parameters in an authenticated HTTP POST — a secure server-to-server call. The IdP responds with a request_uri, a short-lived handle to the stored request data.

The client then redirects the user to the IdP's authorization URL with only client_id and the request_uri:

https://idp.internal.corp/authorize
  ?client_id=AI-Agent123
  &request_uri=urn:ietf:params:oauth:request_uri:TX123...

The IdP already has the full details from the prior PAR call, so it proceeds with authentication and consent knowing the request is exactly what the client intended — unaltered in transit. The request_uri is one-time use and typically expires in minutes.

Integrity & Confidentiality

Authorization details are communicated over a direct back-channel secured by TLS and client authentication — not through the user's browser. RAR JSON with resource IDs won't leak via browser history or logs.

Supports Complex Requests

PAR enables long or complex parameters (RAR, JWT request objects) without URL length or encoding issues. Recommended in financial and healthcare contexts where authorization requests carry detailed data.

Pre-Validated Requests

The IdP validates the request immediately in the PAR call — checking client auth, redirect URI, etc. Malformed or unauthorized requests are rejected upfront, before the user ever sees a prompt.

Simplified Front-Channel

The final user-facing step is simplified to just referencing the request. Even if an attacker intercepts the request_uri, it's useless without the original pushed request.

PAR + RAR: Better Together

Because RAR often involves sending complex JSON in the authorization request (which might not fit cleanly in a URL), PAR is the recommended delivery mechanism. Together they let your AI agent securely request precisely scoped permissions without front-channel exposure.

Decoupled Authentication with CIBA

OpenID Connect Client-Initiated Backchannel Authentication (CIBA) is a flow for scenarios where the typical front-channel redirect for user login is not possible or desired. It enables the AI agent to trigger an authentication process without directly involving the user's interaction on the client device. Instead, the user completes authentication on a separate device via an out-of-band mechanism — think of it as "login by push notification."

When CIBA Is Useful

  • Hands-free or unattended scenarios: the user initiated an action via voice interface, and the agent needs approval to fetch sensitive data.
  • Secure approval for sensitive actions: an AI assistant autonomously attempts a large fund transfer or critical deletion, but policy requires explicit user approval via a separate device.
  • Devices with limited UI: internal IoT or kiosk devices without full browsers — the user authenticates on their phone instead.

How CIBA Works

  1. 1
    Backchannel Auth Request

    The AI agent sends a request directly to the IdP's Backchannel Authentication Endpoint, including its client credentials, the requested scopes/resources, and an identifier for the user (login_hint, id_token_hint, or login_hint_token). Since there's no immediate user interaction, the client must indicate which user it wants to authenticate.

  2. 2
    User Notification

    The IdP validates the request and initiates authentication with the user via a separate channel — typically a push notification to the user's registered authenticator app or device. The user sees: "AI Agent XYZ is requesting access to Resource ABC. Do you approve?" The user then approves (possibly with MFA) on their Authentication Device.

  3. 3
    Token Delivery

    The AI agent waits for the outcome. In poll mode, the agent periodically calls the IdP's token endpoint. In ping mode, the IdP calls a pre-registered endpoint on the client. In push mode, the IdP sends tokens directly to the client's backend. Once the user approves, the IdP issues an access token (and ID token). If the user denies or times out, the client receives a failure.

  4. 4
    Agent Proceeds with Token

    The AI agent now has an access token representing the user and the requested scopes. It calls the internal MCP tool or API just as it would in a normal OAuth flow — fully authenticated and authorized.

Decoupled Experience

The user interacts with the IdP on their phone, not the AI agent's interface. The agent simply shows "Waiting for confirmation..." until it receives the token.

Leverages Existing MFA

Users authenticate on the same device they use for corporate MFA — push MFA apps or SSO mobile apps. No new infrastructure required.

CIBA + RAR

CIBA can carry authorization_details in its request, enabling rich description of what the user is approving even though the consent happens out-of-band.

CIBA is the ultimate fallback for trust — if the AI wants to do something and isn't sure if it should, it can fire off a CIBA request to get explicit human approval using standard OAuth mechanisms rather than custom ad-hoc confirmations.

Defense in Depth for Internal AI

Together, these four patterns implement a defense-in-depth strategy for internal agentic AI systems. Each tool access is authenticated with modern OAuth protocols and authorized with the minimum necessary scope and explicit user involvement when needed.

1

Token Exchange (OBO)

Allows microservices to seamlessly call each other on behalf of a user, ensuring identity and permissions carry through without over-privileging any single component.
2

Rich Authorization Requests (RAR)

Lets the AI agent request precisely scoped permissions using structured JSON, so tokens are narrowly tailored to each task — greatly limiting potential damage from misuse.
3

Pushed Authorization Requests (PAR)

Strengthens the OAuth flow by moving sensitive request details to a backchannel — preventing tampering and handling large, complex authorization details securely.
4

Client-Initiated Backchannel Auth (CIBA)

Provides a way to authenticate users and get consent when direct interaction with the client app isn't feasible — critical for human-in-the-loop control with out-of-band approvals.

By adhering to OAuth 2.1 standards now, your internal AI integrations are not only secure for today's closed-world deployments, but also laying the groundwork for future expansions — such as federation with external IdPs or third-party tool integrations — which will be tackled in subsequent parts of this series.

Download the Full Whitepaper

Get the complete “Inside the Firewall: Securing Internal Tools” guide with architecture diagrams, sequence flows, and implementation details.

Ready to transform your identity security?

See how SecureAuth's Continuous Authority platform can protect your organization.

About SecureAuth

SecureAuth provides identity and access management solutions that enable enterprises to implement customized, resilient authentication infrastructure. Through Continuous Authority, flexible deployment options, and deep composable capabilities, SecureAuth helps organizations defend against modern identity threats while maintaining usability and operational efficiency.

Share this article: