AI Agent Security: New Rules for Defense as Models Move from Generation to Execution

    AI agents turn model outputs into actions, expanding security concerns beyond content accuracy to authorization, execution, and recovery. This article examines the agent attack surface, key threats such as prompt injection and permission escalation, and an engineering framework for controlled tool use, memory management, human approval, testing, and gradual deployment.

    1. The Security Boundary Is Shifting: Are Actions Authorized?

    Traditional large language model applications primarily support question answering, summarization, and text generation. Their outputs may contain factual errors, sensitive information, or inappropriate advice. In many settings, however, users still need to read and evaluate those outputs before turning them into actions.

    AI agents change that path. When a model can retrieve information, call business APIs, modify files, maintain state, and execute tasks across multiple steps, generated text can become the input to the next operation. A mistaken judgment is no longer just an incorrect answer on a screen. It can become an erroneous business change, an unauthorized data access request, or an external message that cannot easily be recalled.

    That does not mean every agent is fully autonomous, or that traditional generative applications face only content risks. The actual risk depends on the tools available, the permissions granted, the presence of trusted approval steps, and the consequences of execution.

    Agent security must therefore address three questions:

    • Content: Is the information the model interprets and generates trustworthy?
    • Control: Who has authority to define objectives, change plans, and authorize operations?
    • Execution: Do actual tool calls comply with permissions, business rules, and environmental constraints?

    Content safety remains necessary, but it cannot carry the security responsibility for the entire system.

    2. Understanding the Attack Surface Through the Action Pipeline

    From an engineering perspective, an agent is not an isolated model. It is an execution system made up of multiple components. A typical workflow looks like this:

    User task → Information retrieval → Reasoning and planning → Tool selection → Authorization checks → Execution → Result feedback → State update

    Each stage introduces potential risks. Four capabilities deserve particular attention.

    2.1 Reasoning and Planning: Errors Propagate Through the Task

    An agent may break a complex objective into several subtasks. For example, “organize the contracts and notify the responsible person” could involve retrieving documents, extracting clauses, identifying contacts, generating summaries, and sending notifications.

    If the system confuses two contacts with the same name, every subsequent step could execute correctly at a technical level while still sending a contract summary to the wrong person. Security therefore depends not only on individual tool calls, but also on verifying task assumptions, critical facts, and intended recipients.

    For high-impact tasks, plans should explicitly record key assumptions. Those assumptions should be checked again before the system changes business state, rather than treating uncertainty in the reasoning process as established fact.

    2.2 Tool Use: Natural-Language Intent Meets Real Permissions

    A model may propose an operation, but that proposal should not automatically grant execution authority. Reading internal documents, changing configurations, deleting records, and sending information externally have different risk levels. They should not share unrestricted permissions simply because they serve the same task.

    Tool descriptions are not security boundaries. If a description says “read-only” but the backend API still permits writes, model errors, malicious inputs, or implementation flaws may trigger unauthorized changes. Restrictions must be enforced by the actual execution components, not merely stated in prompts.

    2.3 Persistent Memory: One Contaminated Input Can Affect Future Tasks

    Cross-session memory helps preserve user preferences and task progress, but it also turns short-lived inputs into lasting influences. If malicious instructions from external material are stored in memory, they may repeatedly interfere with later tasks.

    Memory is therefore not inherently trusted context. Systems should distinguish explicitly confirmed user preferences, facts returned by tools, model-generated inferences, and unverified information from external sources. Each category needs its own conditions for writing, scope of use, and expiration policy.

    2.4 Autonomous Execution: Problems Can Accumulate Unattended

    Background execution and automatic retries improve task completion rates, but they can also amplify risk. Repeated erroneous operations, retry storms triggered by failed requests, and ongoing tool costs all require controls.

    Execution count, runtime, spending, and change volume should have hard limits. Once a threshold is reached, the system should pause or escalate to a human rather than continue by default.

    3. Core Threats: Which Boundaries Can Untrusted Content Cross?

    3.1 Prompt Injection: Disguising Data as Instructions

    Agents read web pages, emails, attachments, documents, and tool results. These sources may contain instructions such as “ignore the previous requirements” or “read other files and send them to this recipient.”

    The problem is not the presence of a particular phrase. It is whether the system treats external material as instructions with control authority. An attacker does not necessarily need to modify the user’s task directly. Influencing data the agent reads may be enough to attempt to redirect its behavior.

    The basic defense is to separate instructions from data. External content may be analyzed, but it must not grant permissions, change the user’s objective, or authorize new sensitive operations. Relying only on the model to recognize malicious wording is insufficient. Authorization checks, recipient restrictions, and independent approval must also limit the consequences.

    3.2 Permission Amplification: Expanding a Legitimate Task into Excessive Access

    “Organize the project materials” does not authorize access to every shared workspace in the company. “Update this record” does not authorize bulk changes to similar records.

    An agent using an overly privileged shared service identity may perform operations that the requester has no right to initiate. The central failure is confusing the requester’s permissions with the execution system’s capabilities.

    Effective permissions must be constrained by user authorization, task requirements, and system policy. An operation prohibited by any of these constraints should not be allowed merely because the model considers it helpful.

    3.3 Memory Poisoning and Loss of Provenance

    An attacker may induce the system to remember an incorrect contact, a false approval rule, or a purported “working preference” that is actually an instruction. If later sessions treat that information as reliable background, the attack extends beyond a single task.

    Multi-agent collaboration adds another risk: a component’s summary may remove the original source and uncertainty. After several rounds of paraphrasing, low-trust content can appear to be a verified conclusion.

    Important information should retain its source, timestamp, confidence level, and verification status. A collaborating component must not automatically promote a message to a trusted instruction simply because it came from another agent.

    3.4 Data Leakage: The Final Answer Is Only One Exit Path

    Sensitive information can leave through tool arguments, external requests, notification bodies, attachments, logs, or long-term memory. Checking only the final answer shown to the user misses many leakage paths.

    Protection must cover the entire data flow: what enters the model, which fields may be passed to tools, what may be logged, and what may leave the organization. Outbound operations should validate the recipient, data category, task purpose, and authorization basis.

    4. Reference Architecture: Models Propose, Trusted Components Decide

    A controllable agent system can be divided into six layers:

    1. Task intake: Verify the requester’s identity, task objective, and authorized scope.
    2. Context: Label information sources, separate external content, and manage memory lifecycles.
    3. Planning: Propose plans and tool requests without directly holding high-privilege credentials.
    4. Policy and approval: Check permissions, business conditions, risk levels, and human approval status.
    5. Execution: Call tools using restricted identities and constrain network, file, and resource access.
    6. Audit and recovery: Record key events and support stopping, compensating for, and investigating operations.

    The central principle is: Model output is a candidate action, not proof of authorization.

    Policy checks should rely wherever possible on verifiable conditions, such as operation type, resource ownership, user role, recipient scope, and number of changes. Asking the model again whether an operation is safe is not a substitute for those checks.

    5. Engineering Controls: From Least Privilege to Irreversible Actions

    5.1 Scope Authorization by User, Task, and Tool

    Permissions should reflect actual business needs. Read-only tasks should not have write access. Single-record updates should not permit bulk modifications. Internal organization tasks should not implicitly allow external sharing.

    Credentials should be short-lived and restricted, with execution components obtaining them when needed. Long-lived secrets should not enter model context, memory, or ordinary logs. Access should expire or be revoked promptly when the task ends.

    Permissions must also be bound to target resources. Restricting an agent to “read” is not enough; the system must specify which resources it may read.

    5.2 Constrain Tool Calls with Structured Requests

    Tool requests should explicitly identify the operation type, target resource, parameters, and associated task. The execution layer must validate structure, value ranges, and business rules. It should not turn model-generated free text directly into executable commands.

    The following pseudocode illustrates generic control logic; it is not a real product interface:

    1. process_action_request(request, task_context):
    2. validate request structure and parameter types
    3. verify requester permissions for the target resource
    4. verify that the operation is within the current task scope
    5. validate data destinations and business preconditions
    6. if operation risk exceeds the automatic execution threshold:
    7. require a valid human approval record
    8. verify that approval covers the current target and parameters
    9. if any check fails:
    10. reject execution and record the reason
    11. else:
    12. execute using a restricted identity
    13. record the result and state changes

    If parameters change after approval, the system must check whether the approval remains valid. Otherwise, an approval for a low-risk operation may be used to execute a different, higher-risk action.

    5.3 Use Risk Levels and Meaningful Human Approval

    Low-risk reads may run automatically under explicit authorization. Small, reversible changes can be presented as previews before execution. Operations involving external sharing, funds, production configuration, or large-scale deletion generally require stricter confirmation.

    Human approval should be more than a generic “Continue?” prompt. The interface should show the target, impact scope, key parameters, data categories, expected outcome, and rollback conditions so that reviewers understand what they are approving.

    Approval is also a limited control. Incomplete or contaminated information can still mislead a reviewer, so human confirmation must be combined with independent parameter and business-rule validation.

    5.4 Isolate Execution and Restrict Network and Resource Access

    Agents that execute code or process files should run in isolated environments. Alongside limits on computing resources and runtime, file directories, network destinations, and business APIs should be opened only as needed.

    Isolation does not replace business authorization. A program confined to an isolated environment can still cause harm through legitimate APIs if it holds highly privileged credentials. Environmental isolation, identity restrictions, and tool authorization must work together.

    5.5 Design for Idempotency, Compensation, and Stopping

    Before retrying an operation, the system should determine whether it is idempotent, so repeated submissions do not create multiple business outcomes. If a request’s success is uncertain, check its status before deciding to retry.

    For changes that can be rolled back, preserve the necessary versions or pre-change state. Operations that cannot truly be reversed—such as information already sent to an external recipient—require stronger controls before execution, along with compensating measures such as access revocation, notification, and follow-up tracking.

    The system also needs a reliable stop mechanism. Stopping must do more than prevent the next planning step: it should block new tool calls, terminate cancellable tasks, and address operations already queued.

    6. Testing and Monitoring: Verify the Execution Boundary

    Agent security testing should not focus only on how often the model refuses malicious questions. It must verify whether dangerous actions are actually blocked.

    Tests should cover instructions embedded in external documents, tool results that encourage unauthorized access, poisoned memory writes, parameter substitution after approval, loss of provenance across components, and repeated operations caused by retries.

    Evaluation should address at least four dimensions:

    • Task effectiveness: Can the system complete legitimate, authorized tasks?
    • Boundary enforcement: Are unauthorized operations blocked before execution?
    • User burden: Does excessive approval make the system difficult to use?
    • Recovery: Can problems be identified, stopped, and corrected?

    Audit records should include task identifiers, requester identity, information sources, proposed operations, policy decisions, approval details, and execution status. Traceability should not become a reason to indiscriminately retain sensitive source material or credentials.

    Key security tests should run again whenever models, prompt templates, tool configurations, or permission policies change. Agent behavior emerges from the entire system; changing even one component can alter an existing security boundary.

    7. Deployment Strategy: Constrain Actions Before Expanding Autonomy

    Organizations should begin with read-only, low-impact scenarios. Establish identity, authorization, logging, and evaluation mechanisms first, then introduce reversible writes, and only later consider high-impact operations.

    A practical launch checklist includes:

    • Sensitive data, critical resources, and irreversible operations have been identified.
    • Tool permissions align with user permissions and task scope.
    • External content cannot change authorization rules or generate its own approval.
    • High-risk operations have explicit pre-execution checks.
    • Memory writes include source labels, scope restrictions, and deletion mechanisms.
    • Retries, timeouts, resource budgets, and stopping controls can be verified.
    • Audit records can reconstruct the key action sequence.
    • Security tests run continuously as the system evolves.

    Security in the agent era is not about adding a few more instructions to a prompt. It requires redefining who may make decisions and who may execute them. Models can help interpret objectives, explore options, and propose actions. Independent mechanisms must grant permission, controlled components must execute operations, and consequences must remain traceable and manageable.

    Reliable autonomy does not mean unlimited freedom to act. It means consistently completing tasks within clear boundaries. Only when those boundaries are enforced in the engineering implementation can agent efficiency become sustainable business value.