AIニュース最前線
最新ニュースAI日報Hacker日報週報動画AIツールトレンド企業

AIニュース最前線

世界中のAI最新情報を日本語で毎時更新

最新ニュース日報トレンド企業プレミアムRSS
© 2026 ainew.jp特定商取引法に基づく表記
ニュース一覧元記事を開く
AWS Machine Learning Blog·2026年6月2日 02:54·約16分で読める

Amazon Bedrock AgentCore Gateway でポリシーと Lambda インターセプタを用いた AI エージェントのセキュリティ強化

#Agentic AI#Policy as Code#Cedar#Lambda#Amazon Bedrock
TL;DR

AWS は、大規模な AI エージェントのガバナンス課題に対処するため、Amazon Bedrock AgentCore Gateway にて Cedar ベースのポリシーと Lambda インターセプタを組み合わせた階層型セキュリティアーキテクチャを発表した。

AI深層分析2026年6月2日 14:27
4
重要/ 5段階
深度40%
5
関連度30%
5
実用性20%
4
革新性10%
3

キーポイント

1

動的ワークフローにおけるガバナンス課題

LLM 駆動のエージェントは実行時にツール呼び出しを決定するため、従来の静的な監査では対応できず、ランタイムでの制御メカニズムが不可欠である。

2

Cedar ベースの確定的アクセス制御

Amazon Bedrock AgentCore のポリシー機能により、主権・アクション・リソースに基づき Cedar 言語で記述された決定論的な許可/拒否判断を自動記録できる。

3

Lambda インターセプタによる動的検証

ツール呼び出し前後にカスタムコードを実行可能とし、動的な検証、ペイロードの拡張、トークン交換、レスポンスフィルタリングを実現する。

4

複合的なセキュリティアーキテクチャの実装

ポリシーと Lambda インターセプタを組み合わせることで、地理情報に基づくアクセス制御など、動的要件と確定的要件の両方を満たす高度な保護が可能となる。

5

JWT からテナント別 IAM クレデンシャルへの動的交換

Lambda インターセプタが JWT のグループ権限を基に STS:AssumeRole を実行し、各テナント固有のscopedなIAMクレデンシャルを取得して MCP リクエストに注入します。

6

Lake Formation による自動的なデータアクセス制御

取得したテナント権限を持つ Athena クライアントがクエリを実行する際、SQL の WHERE 句を明示的に記述しなくても Lake Formation が行レベルおよび列レベルのフィルタリングを自動的に適用します。

7

レスポンスインターセプタによるツールリストの動的フィルタリング

レスポンス側でも Lambda インターセプタが機能し、利用可能なツールのリストをフィルタリングして、認可されたテナントのみが特定のツールにアクセスできる仕組みを実現しています。

影響分析・編集コメントを表示

影響分析

本発表は、AI エージェントが組織規模で普及する中で直面するガバナンスとセキュリティのボトルネックに対する具体的な解決策を示すものであり、実務レベルでの安全なエージェント構築を加速させる重要な一歩です。特に、Cedar という標準的なポリシー言語を採用し、既存のクラウドセキュリティプラクティスと統合可能なアーキテクチャを提供することで、開発者が複雑なセキュリティ要件を効率的に実装できる環境を整備しました。

編集コメント

AI エージェントの普及に伴い、セキュリティとガバナンスはもはやオプションではなく必須要件となっています。AWS が提供するこの二重構造(ポリシー+インターセプタ)は、開発者が柔軟性を損なわずに堅牢な制御を実現するための理想的なアプローチと言えます。

AI エージェントの行動を保護することは、エージェント型ソリューションを構築する際の主要な顧客課題です。企業が AI エージェントを急速に導入してワークフローを自動化するにつれ、組織全体にわたるツールへの安全なアクセスを管理する上でスケーリングの課題に直面しています。現代の統合されたエンタープライズ AI プラットフォームには、組織全体のユーザーに対してサービスを提供する数百のエージェントが存在します。これらのエージェントは、異なるチーム、組織、事業部門にまたがる数千の Model Context Protocol (MCP) ツールへのアクセスを必要とします。これらのプラットフォームのスケーラビリティが根本的なガバナンスの問題を生み出しています。従来のアプリケーションは固定されたロジックを実行しますが、大規模言語モデル(LLM)によって駆動されるエージェントは、実行時にどのツールをどのような引数で、どのような順序で呼び出すかを決定します。このワークフローの動的な性質のため、事前に通話グラフを検証することは困難になります。LLM が意図した通りに振る舞うためのメカニズムを構築する必要があります。

Amazon Bedrock AgentCore gateway を使用すると、2 つの補完的なメカニズムを通じてエージェントとツールを保護できます。1 つ目は、決定論的なアクセス制御のための Amazon Bedrock AgentCore におけるポリシー です。2 つ目は、動的な検証のための AgentCore gateway のインターセプター です。Amazon Bedrock AgentCore におけるポリシーを使用すると、ゲートウェイに紐付けられたツールに対してポリシーを定義できます。ポリシーは Cedar という宣言型ポリシー言語で記述され、各リクエストが *主体 (principal)*、*アクション (action)*、*リソース (resource)* に対して評価されます。また、リコンテキストに対する任意の条件も設定可能です。その結果、監査ログに自動的に記録される決定論的な許可または拒否の判断が得られます。Lambda インターセプターを使用すると、各ツールの呼び出し前または後に実行するカスタムコードを定義でき、動的な検証、ペイロードの拡張、トークン交換、レスポンスフィルタリングをサポートします。これらの 2 つのメカニズムを組み合わせて、エージェントソリューションのための階層化されたセキュリティアーキテクチャを構築できます。

本稿では、レイクハウスデータエージェントを使用して、決定論的なアクセス制御のためにポリシーを使用し、動的な検証のために Lambda インターセプターを使用する方法を実証します。その後、動的な検証と決定論的なアクセス制御の両方を必要とする地理ベースのアクセス制御を実装するために、Lambda インターセプターとポリシーをどのように組み合わせるかを示します。

前提条件

このソリューションを実装する前に、以下の準備が必要です:

  • AWS アカウント。
  • GitHub リポジトリへのアクセス権限。
  • 前提条件を設定するための AWS Identity and Access Management (IAM) の権限。

ソリューションの概要

Lakehouse データエージェントは、保険会社の従業員が請求データを照会できる AI アシスタントです。データは Amazon S3 Tables(Apache Iceberg)に保存され、Amazon Athena および AWS Lake Formation を通じて照会されます。アプリケーションには 3 つのユーザーロールが存在します:保険契約者(自分の請求のみ閲覧可能)、調整担当者(割り当てられた請求を管理)、管理者(監査ログを含むすべてのデータにフルアクセス)。Streamlit UI は Amazon Cognito を介してユーザー認証を行い、JSON Web Tokens (JWT) をエージェントへ渡します。

MCP サーバーは 5 つのツールを公開しています:query_claims, get_claim_details, get_claims_summary, query_login_audit, text_to_sql です。ロールとツールのアクセス権限、テナント IAM ロールマッピング、ユーザーの地理情報は Amazon DynamoDB に格納されています。AWS Lake Formation は照会時に行レベルおよび列レベルのセキュリティを強制します。このケースでは、エージェントが広範な SQL クエリを構築した場合でも、結果は呼び出し元の IAM ロールで許可されている範囲に自動的にスコープされます。

以下の図は、lakehouse データエージェントのアーキテクチャを示しています:

ユーザーは Streamlit UI を通じて湖屋エージェントにアクセスし、Amazon Cognito による認証とベアラートークンの発行が行われます。AgentCore Runtime は湖屋エージェントをホストし、これらのトークンを検証して各ユーザーに対して孤立したセッションを確立します。エージェントがツールを呼び出す際、AgentCore Gateway はリクエストを Lambda Interceptor を経由してルーティングします。Interceptor はベアラートークンを抽出し、テナントロールマッピングを通じてツールのアクセス権限を検証し、テナントスコープのクレームを含むトークンを生成します。AgentCore Policy Engine は、各ツール呼び出しが定義されたポリシーに合致しているかを評価してからアクセスを許可します。その後、湖屋 MCP サーバーはスコープ付き資格情報を使用してデータを照会します。AWS Lake Formation は、ユーザーテーブルとクレームテーブルに基づいて行レベルおよび列レベルのセキュリティを適用し、各ユーザーが権限を持つデータのみを表示できるように支援します。AgentCore の観測性とセッションログは Amazon CloudWatch にストリーミングされ、リアルタイムモニタリングとコンプライアンス監査が可能になります。

リクエストフロー

以下の図は、本ソリューションにおけるツール呼び出しの流れを示しています:

image
image

湖屋エージェントが AgentCore Gateway を介してツール呼び出しを開始すると、リクエストは Request Interceptor Lambda 関数によってインターセプトされます。Request Interceptor は、ベアラートークンをテナントスコープの認証情報に置き換え、追加のコンテキストを注入することでリクエストを変換します。その後、Policy Engine が Cedar ポリシーに基づいて変換されたリクエストを評価します。変換されたリクエストは、湖屋 MCP Server を使用してツールを呼び出すために利用されます。レスポンスはその後、Response Interceptor Lambda 関数によって評価され、ユーザーに返される前にツールリストがフィルタリングされます。

Gateway は Cedar ポリシーを実行する前にリクエストインターセプターを評価します。この順序は、ポリシーを使用してその拡張されたコンテキストを評価する前に、インターセプターを使用してリクエストコンテキストを強化するという設計パターンにおいて基本的なものです。

AgentCore Gateway におけるポリシーの適用

Amazon Bedrock AgentCore のポリシーは、Gateway での決定論的かつ監査可能なアクセス制御を実行するために Cedar ポリシー言語を使用します。Cedar ポリシーは、原則(principal)、アクション(action)、リソース(resource)に対して評価される許可または禁止ルールとして表現され、条件はアクションのコンテキストに基づきます。

認証ルールをアイデンティティ属性、アクション識別子、およびリクエストコンテキストに対する論理条件として表現できる場合に、きめ細かいアクセス制御のために Cedar ポリシーを使用します。典型的なユースケースには、ロールが呼び出せるツールの制限や、特定のユーザーグループに対する機密操作へのアクセスブロックがあります。Cedar はまた、インターセプターによって注入されたコンテキスト属性に基づいてデータ居住性ルールを強制し、リクエストが下流サービスに到達する前にゲートウェイでスコープチェックまたは時間ウィンドウの強制をサポートします。

デザイン 1: ポリシーのみ

まず、レイクハウスエージェントに対するセキュリティ層として機能するポリシーの例を見てみましょう。ビジネス側が保険加入者が get_claims_summary を呼び出せないように決定したシナリオを想定してください。保険加入者は自分自身の個別請求を確認できますが、集計されたサマリーは調整担当者や管理者にのみ予約されています。これを行うには、ゲートウェイにポリシーエンジンをアタッチ して、協調して機能する 2 つの Cedar ポリシーを定義します。すなわち、ベースラインの許可ルールとターゲット型の禁止ルールです。

ポリシーエンジンがゲートウェイにアタッチされると、デフォルトで拒否するセマンティクスに従います。明示的にリクエストを許可するポリシーがない場合、そのリクエストは拒否されます。したがって、まずエージェントがゲートウェイ上でツールを呼び出せるようにするベースラインの許可ポリシーが必要です:

permit(

principal,

action,

resource == AgentCore::Gateway::""

);

このポリシーのみでは、認証されたすべてのユーザーが任意のツールを呼び出すことができます。

次に、ポリシー加入者に対する特定の制限を定義する forbid ルールを追加します。Cedar では forbid ルールが permit ルールよりも優先されるため、この単一のルールだけで対象となるツールの呼び出しをブロックしつつ、他のすべてのアクセスは維持したままにできます。

forbid(

principal is AgentCore::OAuthUser,

action == AgentCore::Action::"lakehouse-mcp-target___get_claims_summary",

resource == AgentCore::Gateway::"") when {

principal.hasTag("cognito:groups") &&

principal.getTag("cognito:groups") like "*policyholders*"

};

これらの 2 つのポリシーを組み合わせることで、エージェントは任意のツールを呼び出すことができますが、ポリシー加入者が請求サマリーにアクセスしようとする場合は例外となります。

注記: ベストプラクティスとして、まずポリシーエンジン上のポリシー強制モードを LOG_ONLY に設定することをお勧めします。すべてのポリシー決定は CloudWatch に記録されますが、リクエストはブロックされません。これにより、ENFORCE モードへ切り替える前に、すべてのポリシールールが期待通りに動作していることを検証できます。

以下の図は、ポリシーのみパターンに従ったツール呼び出しフローを示しています:

image
image

湖家エージェントが着信リクエストを送信すると、AgentCore Gateway はまず組み込みの認証機能を使用して JWT トークンを検証します。次に、Policy Engine が添付された Cedar ポリシーの組み合わせに対してリクエストを評価します。この例では、Cedar ポリシーは「禁止 - 許可」パターンを使用しています。最初に OAuth ユーザーに対する get_claims_summary ツールへのアクセスを禁止し、その後、主体(principal)が policyholders に一致する Cognito グループタグを持っている場合にのみアクセスを許可します。この決定論的なポリシー評価により、承認されたグループに所属するユーザーのみが特定のツールを呼び出せることが保証されます。ポリシー評価の結果に基づき、Gateway は湖家 MCP サーバーへの呼び出しを許可して元のレスポンスをエージェントに返すか、またはツールに到達する前にリクエストを拒否します。

Design 1 のポリシー評価結果

ユーザー

ツール

期待される結果

決定権限者

policyholder001

query_claims

許可

ポリシー:許可が一致

policyholder001

get_claim_details

許可

ポリシー:許可が一致

policyholder001

get_claims_summary

拒否

ポリシー:禁止が優先

adjuster001

get_claims_summary

許可

ポリシー:禁止の一致なし

ポリシーベースの実装の利点

Cedar ポリシーは、AI エージェントを保護するために 3 つの重要な利点を提供します:

  • これらは決定論的です。LLM の動作に関わらず、同じ入力に対して常に同じ判断が下されます。
  • 監査可能です。ゲートウェイで CloudWatch ログ配信を有効にすると、許可または拒否のすべての判断が完全なコンテキストとともに記録され、完全な監査証跡が提供されます。
  • 低遅延を実現します。Cedar の評価はリクエスト処理に最小限のオーバーヘッドしか追加しません。

ダイナミック制御のためのインターセプター

インターセプターは、AgentCore Gateway がリクエストライフサイクルの 2 つの段階で呼び出すカスタム Lambda 関数です。REQUEST インターセプターは、リクエストがダウンストリームのツールに到達する前に実行され、RESPONSE インターセプターは、レスポンスがエージェントに返される前に行われます。Gateway は各インターセプターに、元のリクエストヘッダーとボディを含む mcp キーの下で JSON イベントを渡します。インターセプターはリクエストコンテンツを変換し、同じ構造で返します。インターセプターは、Lambda 関数、OpenAPI エンドポイント、MCP サーバーなど、すべての Gateway ターゲットタイプと連携して動作します。完全なペイロード契約と詳細な手順については、こちらの記事 をご覧ください。

ユーザーに代わってエージェントがツールを呼び出す際、重要なセキュリティ判断の一つは、その呼び出しチェーンを通じてどのようにアイデンティティが伝播するかです。なりすましアプローチでは、元のユーザーの JWT を変更せずに各下流サービスへ渡します。これはシンプルですが、下流サービスが必要以上に多くの権限を受け取ってしまう可能性があります。侵害されたサービスが、過度に特権的なトークンを他の場所でも再利用してしまうリスクがあります(confused deputy problem)。もう一つの代替アプローチは「代理実行」で、各下流ターゲットにはそのサービス固有の範囲を持つ、最小限の権限を持つ個別のトークンが渡されます。監査のためにユーザーのアイデンティティコンテキストは伝播します。Design 2 はこのパターンを実装しています。REQUEST インターセプタは、sts:AssumeRole を通じてユーザーの Cognito JWT を短期間でテナントスコープ付きの IAM クレデンシャルに交換し、その範囲限定されたクレデンシャルが MCP Server に到達します。

Design 2: インターセプタのみ — 代理実行によるトークン交換とコンテキスト伝播

Cedar では実行できない REQUEST インターセプタ内の 3 つの操作があります:

  • JWT から IAM トークンへの交換(act-on-behalf)。JWT からユーザーの Cognito グループを読み取り、DynamoDB 内で対応するテナント IAM ロールを検索し、sts:AssumeRole を呼び出して短期間のスコープ限定認証情報を取得します。
  • コンテキスト注入。ユーザー ID と一時的な IAM 認証情報を MCP リクエスト本文の params.arguments.context に書き込み、MCP サーバーがこれらを使用してスコープ限定 Athena クライアントを構築できるようにします。
  • ツール認可。リクエスト転送前に DynamoDB の allowed_tools をチェックし、不正な呼び出しに対して構造化された MCP エラーを返します。

REQUEST インターセプタハンドラ(簡略化版):

def lambda_handler(event, context):

# インターセプタイベントから MCP ゲートウェイリクエストを解析

mcp_data = event.get('mcp', {})

gateway_request = mcp_data.get('gatewayRequest', {})

body = gateway_request.get('body', {})

headers = gateway_request.get('headers', {})

token = extract_bearer_token(headers)

claims = validate_and_decode_jwt(token) # ステップ 1: Cognito JWT の検証

# ステップ 2: DynamoDB の allowed_tools に対してツール認可をチェック

is_authorized, error_msg, tool_name = validate_tool_access(claims, body)

if not is_authorized:

return build_mcp_error_response(error_msg, status_code=403)

# ステップ 3: act-on-behalf --- JWT のグループ主張をテナント IAM 認証情報に交換

claim_name, claim_value = get_claim_for_exchange(claims)

tenant_credentials = exchange_jwt_to_iam(claim_name, claim_value) # sts:AssumeRole

ステップ 4: MCP リクエストボディにユーザー ID とスコープ付き認証情報を注入

if 'params' in body and 'arguments' in body['params']:

body['params']['arguments']['context'] = {

'user_id': user_principal,

'tenant_credentials': {

'access_key_id': tenant_credentials['AccessKeyId'],

'secret_access_key': tenant_credentials['SecretAccessKey'],

'session_token': tenant_credentials['SessionToken'],

}

}

# 必要なインターセプター出力形式に変換されたリクエストを返す

return {

'interceptorOutputVersion': '1.0',

'mcp': {

'transformedGatewayRequest': {

'headers': transformed_headers,

'body': body,

}

}

}

The MCP Server は、注入されたコンテキストを含む変換済みリクエストを受信します。各ツール関数は context 引数を受け取り、それを使用してスコープ付きの Athena クライアントを構築します。Lake Formation はその後、テナントロールの権限に基づいて、SQL の WHERE 句なしでクエリ実行時に自動的に行レベルおよび列レベルのフィルタリングを適用します:

# server.py --- query_claims ツール

def query_claims(claim_status=None, context=None):

user_id, tenant_creds = get_user_id_with_fallback(context)

Athena クライアントはテナントのスコープ付き IAM 認証情報(ユーザーの JWT ではありません)を使用します

# Lake Formation は行レベルおよび列レベルのフィルタを自動的に適用します

athena_client = boto3.client(

'athena',

aws_access_key_id=tenant_creds['access_key_id'],

aws_secret_access_key=tenant_creds['secret_access_key'],

aws_session_token=tenant_creds['session_token']

)

...

Interceptor のみを使用するパターンの呼び出しフロー

以下の図は、Interceptor のみを使用するパターンの呼び出しフローを示しています:

<img src="https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2026/05/29/ML-20712-4.png" alt="Interceptor-only call flow showing AgentCore Gateway routing the original request to the Request Interceptor Lambda, which exchanges the JWT for tenant-scoped credentials, calls the lakehouse MCP Server, and routes the response through a Response Interceptor that filters the tool list before returnin

原文を表示

Securing AI agent behavior is a key customer challenge in building agentic solutions. As enterprises rapidly adopt AI agents to automate workflows, they face a scaling challenge in managing secure access to tools across the organization. Modern unified enterprise AI platforms have hundreds of agents serving users across the organization. These agents need to access thousands of Model Context Protocol (MCP) tools spanning different teams, organizations, and business units. The scale of these platforms creates a fundamental governance problem. Traditional applications execute fixed logic. Agents powered by a large language model (LLM) decide at runtime which tools to invoke, with what arguments, and in what sequence. Because of the dynamic nature of this workflow, auditing the call graph in advance becomes a problem. You must build mechanisms for an LLM so that it behaves the way you intend.

You can use Amazon Bedrock AgentCore gateway to secure agents and tools through two complementary mechanisms: Policy in Amazon Bedrock AgentCore for deterministic access control and interceptors for AgentCore gateway for dynamic validation. Policy in Amazon Bedrock AgentCore lets you define policies on tools attached to your Gateway. Policies are authored in Cedar, a declarative policy language that evaluates each request against a *principal*, an *action*, and a *resource*, with optional conditions over request context. The result is a deterministic allow or deny decision, automatically recorded in the audit log. Lambda interceptors let you define custom code that runs before or after each tool call, supporting dynamic validation, payload enrichment, token exchange, and response filtering. You can combine both mechanisms to build a layered security architecture for your agentic solutions.

In this post, we use a lakehouse data agent to demonstrate how you can use Policy for deterministic access control and Lambda interceptors for dynamic validation. We then show how to combine Lambda interceptors and Policy to implement a geography-based access control which requires both dynamic validation and deterministic access control.

Prerequisites

Before implementing this solution, you need:

  • An AWS account.
  • Access to the GitHub repository.
  • AWS Identity and Access Management (IAM) permissions to set up the prerequisites.

Solution overview

The lakehouse data agent is an AI assistant that lets insurance company employees query claims data. The data is stored in Amazon S3 Tables (Apache Iceberg) and queried through Amazon Athena and AWS Lake Formation. Three user roles exist in the application: policyholders (who can only view their own claims), adjusters (who manage assigned claims), and administrators (who have full data access including audit logs). A Streamlit UI authenticates users through Amazon Cognito and passes JSON Web Tokens (JWT) to the agent.

The MCP Server exposes five tools: query_claims, get_claim_details, get_claims_summary, query_login_audit, and text_to_sql. Role-to-tool access, tenant IAM role mappings, and user geography are stored in Amazon DynamoDB. AWS Lake Formation enforces row-level and column-level security at query time. In this case, even if an agent constructs a broad SQL query, the results are automatically scoped to what the caller’s IAM role is permitted to see.

The following diagram shows the architecture for the lakehouse data agent:

Architecture diagram of the lakehouse data agent showing Streamlit UI, Amazon Cognito authentication, AgentCore Runtime, AgentCore Gateway with Lambda Interceptor and Policy Engine, lakehouse MCP Server, AWS Lake Formation enforcement on Users and Claims tables, and CloudWatch observability
Architecture diagram of the lakehouse data agent showing Streamlit UI, Amazon Cognito authentication, AgentCore Runtime, AgentCore Gateway with Lambda Interceptor and Policy Engine, lakehouse MCP Server, AWS Lake Formation enforcement on Users and Claims tables, and CloudWatch observability

Users access the lakehouse agent through a Streamlit UI, where Amazon Cognito authenticates them and issues bearer tokens. AgentCore Runtime hosts the lakehouse agent, validates these tokens, and establishes isolated sessions for each user. When the agent invokes tools, AgentCore Gateway routes requests through a Lambda Interceptor. The Interceptor extracts the bearer token, validates tool access through Tenant Role Mapping, and generates a token with tenant-scoped claims. The AgentCore Policy Engine evaluates each tool call against defined policies before permitting access. The lakehouse MCP Server then queries data using the scoped credentials. AWS Lake Formation enforces row-level and column-level security based on the Users Table and Claims Table, helping each user see only the data they are authorized to access. AgentCore Observability and Session Logs stream to Amazon CloudWatch for real-time monitoring and compliance auditing.

Request flow

The following diagram shows the tool call flow through the solution:

Tool call flow diagram showing the lakehouse agent calling AgentCore Gateway, the Request Interceptor Lambda transforming the request, the Policy Engine evaluating against the Cedar policy, the lakehouse MCP Server executing the tool, and the Response Interceptor Lambda filtering the response before returning to the user
Tool call flow diagram showing the lakehouse agent calling AgentCore Gateway, the Request Interceptor Lambda transforming the request, the Policy Engine evaluating against the Cedar policy, the lakehouse MCP Server executing the tool, and the Response Interceptor Lambda filtering the response before returning to the user

When the lakehouse agent initiates a tool call through the AgentCore Gateway, the request is intercepted by the Request Interceptor Lambda function. The Request Interceptor transforms the request by replacing the bearer token with tenant-scoped credentials and injects additional context. The Policy Engine then evaluates the transformed request based on the Cedar policy. The transformed request is used to invoke the tool using the lakehouse MCP Server. The response is then evaluated by the Response Interceptor Lambda function, which filters the tool list before the response is returned to the user.

The Gateway evaluates the request interceptor before the Cedar policy. This order is fundamental to the design patterns where you would use the interceptor to enrich the request context before using policy to evaluate that enriched context.

Policy enforcement in AgentCore Gateway

Policy in Amazon Bedrock AgentCore uses the Cedar policy language to enforce deterministic, auditable access control at the Gateway. Cedar policy is expressed as permit or forbid rules evaluated over a principal, an action, and a resource, with conditions based on the context of the action.

We use Cedar policies for fine-grained access control when the authorization rules can be expressed as a logical condition over identity attributes, action identifiers, and request context. Typical use cases include restricting which tools a role can invoke and blocking access to sensitive operations for certain user groups. Cedar also enforces data-residency rules based on context attributes injected by an interceptor, and supports scope-checking or time-window enforcement at the gateway before requests reach downstream services.

Design 1: Policy only

First, let’s look at an example of a policy acting as a security layer for the lakehouse agent. Consider the scenario where the business decides that policyholders should not be able to call get_claims_summary. Policyholders can view their own individual claims, but the aggregate summary is reserved for adjusters and administrators. To do this, you can attach a Policy Engine to the Gateway and define two Cedar policies that work together: a baseline permit rule and a targeted forbid rule.

When a Policy Engine is attached to a Gateway, it follows deny-by-default semantics. If no policy explicitly permits a request, it is denied. Therefore, you first need a baseline permit policy that allows the agent to invoke tools on the Gateway:

code
permit(
    principal,
    action,
    resource == AgentCore::Gateway::""
);

With this policy alone, all authenticated users can invoke any tool.

Next, add a forbid rule to carve out the specific restriction for policyholders. Because forbid rules take precedence over permit rules in Cedar, this single rule is sufficient to block the targeted tool invocation while leaving all other access intact.

code
forbid(
    principal is AgentCore::OAuthUser,
    action == AgentCore::Action::"lakehouse-mcp-target___get_claims_summary",
    resource == AgentCore::Gateway::""
) when {
    principal.hasTag("cognito:groups") &&
    principal.getTag("cognito:groups") like "*policyholders*"
};

The combination of these two policies allows the agent to invoke any tool, except when policyholders attempt to access the claims summary.

Note: A best practice is to begin with the policy enforcement mode on the policy engine set to LOG_ONLY. All policy decisions are written to CloudWatch, but no requests are blocked. This lets you validate that every policy rule behaves as expected before switching to ENFORCE mode.

The following diagram shows the tool call flow following the policy only pattern:

Policy-only call flow showing JWT validation by AgentCore Gateway, Cedar Policy Engine evaluating forbid and permit rules based on Cognito group claims, and either permitting the request to reach the lakehouse MCP Server or denying it
Policy-only call flow showing JWT validation by AgentCore Gateway, Cedar Policy Engine evaluating forbid and permit rules based on Cognito group claims, and either permitting the request to reach the lakehouse MCP Server or denying it

When the lakehouse agent sends an incoming request, AgentCore Gateway first validates the JWT token using built-in authorization. The Policy Engine then evaluates the request against a combination of attached Cedar policies. In this example, the Cedar policy uses a forbid-permit pattern. It first forbids access to the get_claims_summary tool for OAuth users, then permits access only when the principal has a Cognito group tag matching policyholders. This deterministic policy evaluation makes sure that only users belonging to authorized groups can invoke specific tools. Based on the policy evaluation result, the Gateway either permits the call to the lakehouse MCP Server and returns the original response to the agent, or denies the request before it reaches the tool.

Policy evaluation results for Design 1

User

Tool

Expected result

Decision owner

policyholder001

query_claims

Allow

Policy: permit matches

policyholder001

get_claim_details

Allow

Policy: permit matches

policyholder001

get_claims_summary

DENY

Policy: forbid overrides

adjuster001

get_claims_summary

Allow

Policy: no forbid match

Benefits of policy-based enforcement

Cedar policies provide three key benefits for securing AI agents:

  • They are deterministic. The same inputs always produce the same decision regardless of LLM behavior.
  • They are auditable. Once CloudWatch log delivery is enabled for the Gateway, every allow or deny decision is recorded with full context, providing a full audit trail.
  • They add low latency. Cedar evaluation introduces minimal overhead to request processing.

Interceptors for dynamic control

Interceptors are custom Lambda functions that AgentCore Gateway invokes at two stages in the request lifecycle. A REQUEST interceptor runs before the request reaches the downstream tool, and a RESPONSE interceptor runs before the response is returned to the agent. The Gateway passes each interceptor a JSON event under the mcp key, containing the original request headers and body. The interceptor transforms the request content and returns it in the same structure. Interceptors work with all Gateway target types including Lambda functions, OpenAPI endpoints, and MCP servers. For the full payload contract and a detailed walkthrough, see this post.

When an agent invokes tools on behalf of the user, a critical security decision is how identity propagates through the call chain. The impersonation approach is to pass the original user JWT unchanged to each downstream service. This is simpler, but it also allows downstream services to receive more permissions than they need. A compromised service can then reuse the overly privileged token elsewhere (the confused deputy problem). An alternate approach is “act-on-behalf”, where each downstream target receives a separate, least-privileged token scoped specifically for that service. The user’s identity context flows through for auditing. Design 2 implements this pattern. The REQUEST interceptor exchanges the user’s Cognito JWT for short-lived, tenant-scoped IAM credentials through sts:AssumeRole, and those scoped credentials are what reaches the MCP Server.

Design 2: Interceptor only — act-on-behalf token exchange and context propagation

Three operations occur in the REQUEST interceptor that Cedar cannot perform:

  • JWT-to-IAM token exchange (act-on-behalf). Read the user’s Cognito group from the JWT, look up the corresponding tenant IAM role in DynamoDB, and call sts:AssumeRole to obtain short-lived scoped credentials.
  • Context injection. Write user identity and the temporary IAM credentials into the MCP request body at params.arguments.context so the MCP Server can use them to construct scoped Athena clients.
  • Tool authorization. Check DynamoDB allowed_tools before forwarding the request, returning a structured MCP error for unauthorized calls.

The REQUEST interceptor handler (simplified):

code
def lambda_handler(event, context):
    # Parse the MCP gateway request from the interceptor event
    mcp_data = event.get('mcp', {})
    gateway_request = mcp_data.get('gatewayRequest', {})
    body = gateway_request.get('body', {})
    headers = gateway_request.get('headers', {})

    token = extract_bearer_token(headers)
    claims = validate_and_decode_jwt(token)  # Step 1: validate Cognito JWT

    # Step 2: check tool authorization against DynamoDB allowed_tools
    is_authorized, error_msg, tool_name = validate_tool_access(claims, body)
    if not is_authorized:
        return build_mcp_error_response(error_msg, status_code=403)

    # Step 3: act-on-behalf --- exchange JWT group claim for tenant IAM credentials
    claim_name, claim_value = get_claim_for_exchange(claims)
    tenant_credentials = exchange_jwt_to_iam(claim_name, claim_value)  # sts:AssumeRole

    # Step 4: inject user identity and scoped credentials into the MCP request body
    if 'params' in body and 'arguments' in body['params']:
        body['params']['arguments']['context'] = {
            'user_id': user_principal,
            'tenant_credentials': {
                'access_key_id': tenant_credentials['AccessKeyId'],
                'secret_access_key': tenant_credentials['SecretAccessKey'],
                'session_token': tenant_credentials['SessionToken'],
            }
        }

    # Return transformed request in the required interceptor output format
    return {
        'interceptorOutputVersion': '1.0',
        'mcp': {
            'transformedGatewayRequest': {
                'headers': transformed_headers,
                'body': body,
            }
        }
    }

The MCP Server receives the transformed request with the injected context. Each tool function accepts a context argument and uses it to construct a scoped Athena client. Lake Formation then applies row-level and column-level filters automatically at query time based on the tenant role’s permissions without a SQL WHERE clauses:

code
# server.py --- query_claims tool
def query_claims(claim_status=None, context=None):
    user_id, tenant_creds = get_user_id_with_fallback(context)

    # Athena client uses the tenant's scoped IAM credentials (not the user's JWT)
    # Lake Formation applies row-level and column-level filters automatically
    athena_client = boto3.client(
        'athena',
        aws_access_key_id=tenant_creds['access_key_id'],
        aws_secret_access_key=tenant_creds['secret_access_key'],
        aws_session_token=tenant_creds['session_token']
    )
    ...

Call flow for the Interceptor-only pattern

The following diagram shows the call flow for the Interceptor-only pattern:

<img src="https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2026/05/29/ML-20712-4.png" alt="Interceptor-only call flow showing AgentCore Gateway routing the original request to the Request Interceptor Lambda, which exchanges the JWT for tenant-scoped credentials, calls the lakehouse MCP Server, and routes the response through a Response Interceptor that filters the tool list before returnin

この記事をシェア

関連記事

AWS Machine Learning Blog★42026年6月2日 01:12

Amazon Bedrock AgentCore を用いた大規模なエージェント AI の運用管理「AgentOps」の紹介

AWS は、予測不能な意思決定やコスト増などの課題に対応するため、Amazon Bedrock AgentCore に基づく「AgentOps」を公開し、大規模なエージェント AI の運用管理手法を提供した。

AWS Machine Learning Blog★42026年5月29日 02:51

Claude Opus 4.8 が AWS で利用可能に

AWS は、Anthropic の最新モデル「Claude Opus 4.8」を Amazon Bedrock および「Claude Platform on AWS」で提供開始した。この新モデルは、生産環境でのワークフローやエージェント型コーディングにおいて改善をもたらす。

The Register AI/ML★42026年6月4日 01:49

コパイロットを超えて、マイクロソフトの AI が運転席を握る

マイクロソフトはビルドカンファレンスで、ユーザーの行動を常時監視して背景で自動実行する新カテゴリ「オートパイロット」を発表し、その第 1 弾エージェント「スカウト」を紹介した。

ニュース一覧に戻る元記事を読む