AWS ML ★ 104 5 min

Securing AI agents with temporal policies in Amazon Bedrock AgentCore

Amazon Bedrock AgentCoreFoundational (100)Technical How-to

🔗 https://aws.amazon.com/blogs/machine-learning/securing-ai-agents-with-temporal-policies-in-amazon-bedrock-agentcore/

📌 【Amazon Bedrock AgentCore】單看單一動作不夠安全:引入「時序策略」管控 AI Agent 的行為軌跡

TL;DR:透過 Amazon Bedrock AgentCore 的時序策略(Temporal Policies),能依據 Agent 的歷史行為(Trajectory)來執行狀態化(Stateful)的授權,防止 Agent 繞過安全流程。

🎣 當 AI Agent 變得太聰明,傳統的「無狀態」權限控制失效了

傳統應用程式的存取控制通常將每個動作視為獨立事件,並依賴確定性的業務邏輯來確保動作順序與資料時效。然而,AI Agent 的行為模式完全不同:它們會在執行時(Runtime)自行決定要呼叫哪些工具、使用什麼參數,以及執行順序。

這種靈活性帶來了巨大的安全挑戰。單一工具呼叫在孤立狀態下可能是安全的,但若放在上下文(Context)中看,卻可能極度危險。例如:在讀取了不可信的資料源後,緊接著進行敏感操作,這時單靠傳統的無狀態(Stateless)權限檢查(僅檢查「誰能呼叫哪個工具」)是無法察覺風險的。

🤔 從無狀態到狀態化:為什麼需要時序策略?

目前的存取控制(如 AgentCore Policy)主要執行無狀態、確定性的規則。但面對 Agent 時,這往往不足以應對以下情境:

  • 違反工作流順序:Agent 跳過了必要的資料檢核步驟,直接執行敏感指令。
  • 資料偽造:在工具呼叫之間,Agent 可能利用模型特性產生虛假資訊來誘導下一個步驟。
  • 累積風險過高:單次交易金額在安全範圍內,但多筆交易累計後的總金額已超過限制。

為了補足這點,Amazon Bedrock AgentCore 引入了時序策略(Temporal Policies)。它透過評估當前請求在 Agent 軌跡(Trajectory)中的歷史背景,來決定是否授權。

🧩 AgentCore 的防禦機制:在邊界外執行,讓 Agent 無法干預

時序策略的設計核心在於其「位置」與「運作邏輯」:

  1. 邊界執行(At the Perimeter):策略是在 AgentCore Gateway 執行,位於 Agent 程式碼之外。這意味著無論 Agent 如何被提示(Prompting)或程式碼存在什麼 Bug,都無法攔截或操縱這些控制規則。
  2. 軌跡感知(Trajectory-aware):策略會追蹤一個由「主體(Principal)」與「工作階段 ID(Session ID)」定義的動作序列。
  3. 單一入口管理:由於 Gateway 路由了所有 Model Context Protocol (MCP) 工具呼叫、Agent 間的呼叫以及模型推論,時序策略可以統一治理這三種呼叫,提供一致的行為判斷。
  4. 安全性原則:延續現有的設計,採用「預設拒絕(Deny by default)」以及「禁止優先於允許(Forbid wins over permit)」的原則。

📊 技術細節:工作階段與 Dogwood 語言

  • 工作階段(Session)的定義
    • 每個請求必須攜帶 x-amzn-bedrock-agentcore-policy-session-id
    • 工作階段結合了 Session ID 與終端使用者的身份,確保不同使用者即便使用相同的 ID 也會被視為獨立的軌跡。
    • 時效性:軌跡事件最多保留 24 小時,超過時間的事件會自動刪除。
    • 更新機制:一旦修改了 Policy 規則,現有的工作階段會立即失效,確保所有請求都依據最新的規則進行評估。
  • Dogwood 語言
    • 時序策略使用一種名為 Dogwood 的開源治理語言。
    • 它支援評估現有的 Cedar 策略,並允許加入時序條件(Temporal conditions),因此使用者不需要遷移現有的 Cedar 策略。

💡 實務範例:私人銀行代理人的安全防線

假設有一個協助理財顧問管理客戶投資組合的 Agent,其工具包含:get_client_profile(獲取客戶資料)、load_portfolio(載入投資組合)以及 rebalance_portfolio(重新平衡投資組合)。

為了符合合規要求,團隊設定了以下時序控制:

  • 強制執行工作流順序
    • 規則:必須依序完成 get_client_profileload_portfoliorebalance_portfolio
    • 防禦效果:如果 Agent 試圖跳過「載入投資組合」的步驟,直接執行「重新平衡」,即便該動作本身在權限範圍內,也會被 Gateway 直接拒絕。

🎯 實務啟示

對於正在開發 AI Agent 的工程師來說,安全設計不應僅停留在「工具的權限管理」,更應轉向「行為的流程管理」。透過在 Gateway 層級實施時序策略,可以有效在不侵入 Agent 核心邏輯的情況下,建立一道堅實的防禦屏障,確保 Agent 的行為不僅符合權限,更符合預期的業務邏輯與合規流程。

🔗 來源

  • 標題:Securing AI agents with temporal policies in Amazon Bedrock AgentCore
  • 作者/機構:Sean Eichenberger @ AWS ML
  • 連結:aws.amazon.com/blogs/machine-learning/securing-ai-agents-with-temporal-policies-in-amazon-bedrock-agentcore/

#AI #MachineLearning #AWS #AmazonBedrock #AIAgent #Cybersecurity #CloudComputing #SoftwareEngineering #MachineLearningOps #BedrockAgentCore

原始資料 AWS ML · 收集於 2026-08-07
來源原標題
Securing AI agents with temporal policies in Amazon Bedrock AgentCore
作者
Sean Eichenberger
原始標籤
Amazon Bedrock AgentCore · Foundational (100) · Technical How-to
原始連結
https://aws.amazon.com/blogs/machine-learning/securing-ai-agents-with-temporal-policies-in-amazon-bedrock-agentcore/

摘要原文

Before AI agents, it was generally sufficient for access controls to treat each action as an independent event. Applications relied on deterministic business logic to enforce whether actions happened in the right order or whether the data was up-to-date. AI agents behave in fundamentally different ways than traditional applications. They decide at runtime which tools to call, with which arguments, and in what order. That flexibility, combined with increasingly intelligent models, makes agents equal measures capable and challenging to control. One tool call might be deemed safe when considered in isolation, but harmful in the context of the preceding call, such as after reading from an untrusted data source. The question then becomes, how do you enforce authorization rules that account for an agent’s session history, in a way the agent cannot circumvent? Temporal policies in Amazon Bedrock AgentCore let you define stateful rules that determine authorization to AgentCore Gateway targets by evaluating the current request in the context of prior events in an agent’s trajectory. Because these policies run at the AgentCore Gateway perimeter, outside the agent’s own code, the agent cannot intercept or manipulate them. In this post, you will learn what temporal policies are, how they work, and walk through an example to demonstrate. We will show you how to use temporal policies to enforce workflow sequencing, prevent data fabrication between tool calls, cap cumulative financial exposure per session, and require human approval for high-value actions. You will also see how to automatically tighten permissions when an agent operates without human engagement. First, however, we will explore the needs and use cases for stateful policies in more detail. Existing access controls in AgentCore Policy enforce stateless, deterministic rules on each individual request: who can call which tool, under what conditions. Stateless controls are necessary but often insufficient for agents. Consider the following scenarios where existing stateless controls fail to catch critical issues: Each individual tool call in these scenarios would pass a stateless policy check. The problem only becomes apparent when you look at the agent’s trajectory, the ordered sequence of actions in a session. Temporal policies extend Policy in AgentCore with this trajectory-aware enforcement layer. Temporal policies run at the gateway, outside the agent’s code, so they cannot be bypassed regardless of what the agent does, how it is prompted, or what bugs exist in the agent code. Some common temporal policy use cases include: Temporal policies operate on the traffic that flows through AgentCore Gateway. Because Gateway routes an agent’s Model Context Protocol (MCP) tool calls, agent-to-agent calls, and model inference calls through a single endpoint, a temporal policy can govern all three whenever your agent issues those calls through the gateway. This gives you one consistent place to reason about an agent’s behavior over time, regardless of which kind of call the agent is making. Temporal policies build on the existing policy engine that’s already used for stateless access control. They introduce the concept of agent trajectories, which are bounded sequences of actions identified by a principal and session ID. Agents never see the policy logic, never touch the state store, and cannot alter the controls. As with the existing AgentCore Policy features, temporal policies deny by default and forbid wins over permit. When the gateway receives a tool call, the policy engine: Every request that a temporal policy evaluates must carry an x-amzn-bedrock-agentcore-policy-session-id header, which identifies the session the request belongs to. You decide what constitutes the beginning and end of a session. The boundary can reflect whatever unit of work makes sense for your application, whether that is a single user conversation, a multi-step task, or a longer-running workflow. Because there can be no more than one concurrent authorization request per session, we recommend keeping the scope of a session as narrow as possible. If no header is passed, one will be generated on your behalf. However, note that a new session ID means that the policy engine will evaluate against a new, empty trajectory with no history. A session is never defined by its ID alone. AgentCore combines the session ID with the end user’s identity to produce a unique session, which means two different identities can present the same session ID and still be treated as having entirely separate sessions. Policies apply independently to each trajectory, because the underlying identity differs. Within an active session, agent trajectories carry a maximum look-back window of 24 hours. Any trajectory events older than that are automatically deleted. One additional rule governs the relationship between sessions and the policies themselves. Whenever a change is made to the policies in a policy engine, existing sessions are invalidated. This makes sure that each session is evaluated against the current set of policies and each relevant trajectory event is recorded with the expected schema. To make these concepts concrete, we’ll walk through how temporal policies can secure a hypothetical private banking agent. The agent helps wealth advisors at a financial services firm manage client portfolios. It retrieves client profiles, loads portfolio holdings, fetches real-time market prices, performs analysis, and executes trades on the advisor’s behalf. In this scenario, the following MCP tools are exposed through the AgentCore Gateway: There are three different advisor roles: junior advisors (limited trade authority), senior advisors (full trade authority), and compliance officers (read-only monitoring access). In this example, we will use Amazon Cognito for identity and pass JWTs for inbound auth to the AgentCore Gateway, which hosts our agent’s tools. To learn about AgentCore Gateway and how to set up auth with Gateway, read the AgentCore Gateway Documentation . Temporal policies use Dogwood , a new open-source governance language designed for agents and their tools. Dogwood supports evaluating existing Cedar policies and enables support for temporal conditions. Because Dogwood is compatible with existing Cedar policies, customers can continue to use their current Cedar policies without needing to migrate. For additional detail on Dogwood and its semantics, you can read the language documentation or this blog post . The compliance team requires the following temporal controls before the agent reaches production: Figure 1: Request flow through AgentCore Gateway and Policy This diagram demonstrates how requests to your gateway are intercepted and evaluated by Policy in AgentCore. When the portfolio agent initiates a tool call, the following steps occur: If you have an existing policy engine in ENFORCE mode, you can either update its enforcement mode to LOG_ONLY , or you can change the enforcement mode of the individual policies. Switching existing policies or policy engines to LOG_ONLY mode is not recommended for production workloads since policies will no longer enforce those security rules. Before implementing this solution, verify that you have met the following prerequisites: The compliance team requires that the agent follow get_client_profile , then load_portfolio , then rebalance_portfolio in sequence. Without the client profile, the agent has no system-verified context about which portfolios belong to this client, what the client’s risk tolerance is, or what account restrictions apply. This policy forbids rebalance_portfolio unless get_client_profile and load_portfolio have both completed in the correct order within this trajectory. An agent that skips the load profile step and jumps directly to rebalancing is denied regardless of what instructions it received.

tencent/hy3:free 自動生成