Security Boundaries for AI Agent Actions: Policy Gateways and Human Takeover

    As AI agents transition from generating text to executing actions in real systems, they introduce significant security risks. This article explores how to secure agent operations using execution environment isolation, policy gateways, and declarative rule configurations. It covers the architecture of a policy gateway, the principles of default deny and fail-safe, rule evaluation strategies, and the mechanism for human takeover during authentication challenges.

    1. The Shift from Talking to Doing

    The earliest form of large language model (LLM) assistants was a simple chat box: a user asks a question, the model provides a text answer, and all subsequent actions are performed by a human. This model carries low risk because the model’s output is just text and does not directly alter any system state.

    The situation changes when an agent gains access to browsers, file systems, and command execution capabilities. A single misjudgment could result in submitting the wrong form, deleting critical files, or sending internal documents to an external address. The stronger the capability, the more carefully the authorization boundaries must be designed.

    Consider expense report review as an example. A reviewer needs to find policy documents, download receipts, verify amount calculations, and reply to the submitter. The most time-consuming part of these steps is usually not the final decision, but the process of searching and verifying. If an agent can handle the searching and verification on behalf of a human, it needs access to multiple systems, each with its own permission structure.

    Therefore, a usable agent system must answer three questions: In what environment does it run? What actions can it perform? Who decides whether it can perform them?

    2. Execution Environment Isolation: A Dedicated Space for Each Agent

    A common practice is to allocate an independent runtime environment for each agent instance, typically including the following components:

    • An independent browser session, where cookies and login states are saved separately and not shared between instances;
    • An independent file directory, mounting only the data required for that specific task;
    • An independent network egress or access whitelist;
    • A container with resource quotas, limiting CPU, memory, and runtime duration.

    Isolation provides three main benefits. First, if an agent makes an error, the blast radius is confined to its own environment. Second, credentials do not leak between tasks; for example, Task B cannot access the account logged in during Task A. Third, during an audit, every operation can be traced step-by-step by environment, making accountability boundaries clear.

    Isolation alone does not guarantee security. A container merely confines a process to a box; what the process can do inside that box is still determined by policy. This is the layer discussed in the next section.

    3. Policy Gateway: A Checkpoint Before Action Execution

    One of the most valuable design patterns to adopt is routing all actions with side effects through a unified policy gateway. Side effects here include clicking submit buttons, writing to files, calling external APIs, and sending messages. Read-only queries can be relaxed as needed, but all write operations should traverse the same path.

    A reasonable gateway processing flow looks like this:

    1. Parse Action: Convert the model’s intent into a structured description, such as “click element X on page Y” or “write content to path Z.”
    2. Get Trusted Snapshot: Target information is parsed by the server based on the current state, rather than directly trusting parameters provided by the model. This prevents the model from forging target addresses or file paths.
    3. Evaluate Policy: Use rules to determine whether to allow, deny, or require human confirmation.
    4. Write Audit Record: Regardless of the outcome, log the request, the verdict, and the basis to disk first.
    5. Execute Action: Only after the previous four steps are complete is the underlying capability actually invoked.

    By placing Step 4 before Step 5, the system eliminates any “act first, log later” path. If the audit write fails, the action is not executed at all. While this sequence may seem cumbersome, it is the foundation for post-incident accountability.

    3.1 Rule Evaluation Order

    Policy rules are generally divided into two types: allow and deny. A robust convention is that deny rules take precedence over allow rules. If even one deny rule is matched, the action is blocked regardless of how many allow rules exist. This allows security teams to add global prohibitions without having to modify individual allow rules one by one.

    3.2 Default Deny and Fail-Safe

    Two other principles are equally critical:

    First, no action is allowed when a policy is missing. A newly created agent without a configured policy file should not be able to do anything, rather than inheriting a set of loose defaults.

    Second, execution is denied when rules are corrupted. If the policy file fails to parse, field types mismatch, or expressions cannot be evaluated, these situations should result in a denial, not skipping the error and allowing the action to proceed.

    Both principles fall under fail-safe design. When a configuration error occurs, the system stops on the safe side. The cost is temporary loss of functionality, but it prevents privilege escalation. For agents that interact with real systems, this trade-off is usually acceptable.

    4. Expressing Policies with Rules

    Policies are typically written using declarative syntax. Below is an illustrative rule structure; the field names are fictional and used solely to explain the concept, not tied to any specific implementation:

    1. rules:
    2. - name: deny-external-email-in-scheduled-jobs
    3. effect: deny
    4. when:
    5. action.type: send_email
    6. trigger.source: scheduled
    7. - name: allow-email-when-human-initiated
    8. effect: allow
    9. when:
    10. action.type: send_email
    11. trigger.source: manual
    12. - name: deny-writes-outside-workspace
    13. effect: deny
    14. when:
    15. action.type: write_file
    16. target.path_not_under: /workspace

    These rules express three intentions: scheduled jobs cannot send external emails; emails triggered manually by a human can be sent; any file writes are restricted to the workspace directory.

    The most noteworthy field in these rules is the trigger source. The same action carries different risks depending on who initiates it and how. Scheduled jobs lack real-time human oversight, making errors harder to detect promptly, so constraints on them are usually stricter than on manual operations. Incorporating the trigger source as a policy dimension allows you to tighten the attack surface while preserving automation capabilities.

    A few best practices for writing rules:

    • Group rules by resource and action to avoid overloading a single rule with too many conditions;
    • Write a clear reason for each rule to facilitate audit understanding;
    • Put rule files under version control, requiring review for any modifications;
    • Run replay tests using historical requests before deployment to observe which actions will be affected by the new rules.

    5. Handing Over Control During Login Challenges

    During execution, agents frequently encounter secondary verification, CAPTCHAs, or login pages. In these scenarios, the automated process should pause and return control to a human.

    A viable takeover mechanism includes the following steps:

    • Detect Blocking Conditions: Identify situations requiring human intervention through page features or response status codes;
    • Suspend Task: Save the current context but halt the execution of subsequent actions;
    • Notify Relevant Personnel: Send an alert with a context link via a messaging channel;
    • Return Control: The task resumes after the human completes verification, and operations performed during the takeover are logged.

    Operations performed during the takeover must also be audited; otherwise, human intervention becomes an audit blind spot. Additionally, CAPTCHAs and passwords should never pass through the agent’s context. They must be entered directly by the human in a controlled interface.

    6. Differences from Conversational Assistants

    Conversational assistants and action-oriented agents solve different problems and require different risk controls.

    Dimension Conversational Assistant Action-Oriented Agent
    Output format Text State changes in external systems
    Primary risk Information error, misleading Misoperation, privilege escalation, data leak
    Control focus Content quality Permissions, audit, isolation
    Human role Read and decide whether to adopt Approve key actions, handle exceptions

    This table does not imply that action-oriented agents are superior. Many tasks only require a conversational assistant, and introducing execution capabilities increases maintenance costs and security burdens. When selecting an approach, ask first: Does the task truly require read/write access to real systems? If the goal is just to organize information or draft text, there is no need to grant execution permissions.

    Tools should also be allocated following the principle of least privilege. An agent designed for expense report review does not need to delete files.