AI Agent Security
AI Agent Security: A Lifecycle Guide to Safer Deployment
A practical guide to AI agent security, from defining permitted actions and limiting access to protecting data, testing controls, monitoring activity, and reviewing changes.

- Set a clear task boundary and enforce it through system permissions, not prompts alone.
- Limit each agent’s access to the data, tools, and systems its task requires.
- Test the complete deployment, including its identity, harness, tools, and approval controls, before release.
- Assign an owner who can review activity, respond to incidents, and reassess the agent when it or its environment changes.
What does AI agent security protect?
AI agent security protects the agent and the systems, data, identities, and actions connected to it. It is a lifecycle discipline, not a single model setting or product feature.
An AI agent uses a model to pursue a task through connected data or tools. Its actual capabilities depend on its implementation and permissions. The model may propose an action, but the harness and connected services determine what the system can access or change.
A harness is the software layer that connects a model to organisational data, tools, and systems. It can provide context and memory, perform tool actions, and enforce permissions. Because it mediates access, it is part of the security boundary, alongside the model, data, credentials, memory, connected services, and organisational processes.
A model’s refusal is not an authorization check. If a system can change a file, account, payment, or external communication, a separate control must determine whether that action is allowed. Use the model to interpret requests, enforce access in the application or infrastructure, and test and monitor the integrated system.
Which AI agent security risks should you threat-model?
Threat-model how the agent’s inputs, access, actions, and oversight could fail or be abused. Rank the risks so the team can distinguish issues to manage from issues that must block release.
- Instructions and context: Consider malicious or misleading instructions in user input and connected content, including prompt injection.
- Data access: Identify sensitive records the agent can retrieve, which sources it trusts, and the consequences of exposing or misusing that data.
- Tool actions: Check whether tools can modify records, send messages, change settings, or affect systems beyond the intended task.
- Identity and credentials: Look for shared identities, broad inherited access, long-lived credentials, and unclear ownership.
- Network and connected services: Identify reachable destinations and services, then decide which connections the task actually requires.
- Memory, oversight, and accountability: Determine what the agent retains, who reviews important actions, and whether investigators can distinguish agent activity from human activity.
Prioritize each threat using three factors: the sensitivity of exposed data or importance of affected systems; the impact and reversibility of a possible action; and the effectiveness of controls that prevent, detect, or contain a failure. Rate each factor as low, medium, or high, and record the reason. Treat a threat as a release blocker when it could cause high-impact or hard-to-reverse harm and the relevant controls have not been shown to work. The team may manage lower-impact risks through monitoring or a narrower rollout, provided someone documents and accepts the remaining risk.
For example, a support-ticket agent that reads specified requests and drafts replies has a different risk profile from one that can change account permissions or send messages automatically. If it can alter access, the impact is higher and harder to reverse. Keep that action unavailable unless authorization and recovery controls have passed tests.
How should you define an agent’s scope before deployment?
Start with a specific task, a named business owner, and a written boundary around the data, systems, and actions the agent needs.
- Describe the task. State what the agent should accomplish, who uses it, and which business process it supports.
- Map its working environment. Record required data, tools, systems, and external services.
- List permitted and prohibited actions. Consider deleting or overwriting information, changing credentials or permissions, sending external communications, or controlling equipment.
- Identify users, inputs, and failure modes. Consider who can submit requests, what connected content can influence the agent, how services might fail, and what harm a mistaken action could cause. Record assumptions and who accepts residual risk.
- Choose the minimum useful autonomy. Do not make independent action the default. Match oversight to the task and its possible consequences.
A support-ticket agent might initially read specified ticket fields, classify cases, and save draft replies. It might be prohibited from sending replies, changing account permissions, or deleting records. This written boundary gives the team a basis for configuring access and testing whether proposed actions are in scope.
How do you constrain an agent’s identity and permissions?
Give each agent a distinct, accountable identity and grant only the task-scoped access it needs.
- Inventory identities and permissions. Map end-to-end access, including permissions inherited through users, service accounts, tools, and connected applications.
- Apply least privilege. Use roles scoped to the task and data involved. Avoid broad access for convenience, and separate development and production privileges where appropriate.
- Use short-lived credentials. Prefer credentials limited in scope and duration, and plan how to revoke them.
- Enforce authorization outside the model. The application or infrastructure layer should decide whether an operation is allowed. An instruction such as “never delete files” is not an access control.
- Gate high-impact operations. Use allowlists, approval steps, or time-bound elevation where an action could cause significant or difficult-to-reverse effects.
Validate effective permissions at the system boundary, not just in a configuration screen or the agent’s instructions. Confirm that access can be withdrawn promptly when it is no longer justified.
How should you isolate an agent’s tools, data, and network access?
Run the agent in an environment that limits the local resources and network destinations it can reach. A sandbox can restrict access to local resources and external connections. Choose the narrowest boundary that still supports the task: for example, allowlist required domains, permit access only to a model service, or block external network access where the task allows.
Connect only the tools and services the agent needs, and separate development from production access. Avoid exposing secrets unnecessarily in prompts, logs, or development environments. Use separate, short-lived, scope-limited credentials where possible.
How should you protect data and agent memory?
Treat data handling as part of the agent’s security boundary. Review what enters prompts, what retrieval systems can return, what memory retains, what logs capture, and what outputs reveal.
- Minimize inputs. Provide only the fields and records needed for the task. Filter retrieval results by the user’s existing authorization, and do not assume that a connected source is safe to expose simply because the agent can reach it.
- Make memory purposeful. Decide whether persistent memory is necessary. If it is, specify what it may contain, who can read or update it, how long it remains, and how it is corrected or deleted. Avoid retaining secrets or sensitive details that the task does not require.
- Separate users and environments. Keep user or tenant memory isolated so one person’s context cannot influence another person’s session. Separate development and production memory and data unless a documented need and tested control justify sharing.
- Limit logs and outputs. Capture enough information to investigate actions, but avoid storing full sensitive prompts, retrieved records, credentials, or private outputs when summaries or redacted fields will suffice. Restrict log access and retention, and prevent outputs from disclosing data the requesting user is not authorized to see.
- Test for unintended exposure. Use test accounts and distinct, non-sensitive markers in separate users’ records. Try prompts that ask the agent to reveal another user’s information, carry context across sessions, or expose retrieved content in logs and outputs. Confirm that isolation holds and that denied access does not leak through summaries or error messages.
Set retention periods for memory and logs before launch, then verify that expiration and deletion work as intended. Reassess these controls whenever the agent’s data sources, users, or task change.
How should you test an AI agent before release?
Test the complete deployment—model, harness, tools, permissions, data paths, and policies—against the failures it must prevent. Define the release gates before testing so results lead to a clear decision.
- Turn the scope into test cases. Include hostile instructions in connected content, requests outside the task, unauthorized tool calls, ambiguous requests, service errors, and attempts to exceed access.
- Specify expected behavior. Prohibited actions must be blocked by the system boundary. Uncertain cases must stop or escalate rather than proceed. Actions must be attributable to the agent identity. Required approval must be enforced, and revocation and shutdown must work.
- Test data boundaries. Attempt cross-user and cross-environment access, memory leakage, and sensitive-data exposure through prompts, retrieval, logs, and outputs.
- Test the integrated system. Use the identities, tool connections, and policy enforcement intended for deployment. A model-only evaluation cannot show that deployed controls work.
- Record failures and retest. Repeat relevant tests after changes to the model, harness, tools, permissions, data sources, or connected services.
For a support-ticket agent, create a test ticket containing an instruction to ignore policy and change the customer’s account permissions. The expected result is that the authorization layer denies the action, the case stops or escalates, and the attempt appears in attributable logs. If the agent changes the account, the test fails. Keep the capability disabled until the permission gap is fixed and the test passes. Treat sending a reply without required approval as a failure too.
Release checklist: Release only when prohibited actions are blocked; uncertain cases stop or escalate; data boundaries and activity attribution work; required approvals are enforced; and revocation and shutdown have been tested. Do not waive an unresolved high-impact failure because a rollout is small. Fix the control, narrow the scope, or keep the capability disabled, then rerun the relevant tests.
When should an AI agent require human approval?
Designers or operators—not the agent—must decide which actions require human approval. Base the decision on potential impact, reversibility, and whether a reviewer can meaningfully assess the proposed action.
Deleting or overwriting information, changing credentials or permissions, sending external communications, and controlling equipment are examples that teams should assess carefully. They are not universal approval rules. Build approval into the workflow: the agent can prepare a proposed action, but the system should withhold execution until an authorized person approves it.
For a consequential action, show the reviewer what will change, why the agent proposes it, and which data or tools informed the proposal. If the reviewer cannot understand the action or its consequences, do not allow it to proceed automatically. Provide a way to reject the action and escalate uncertain cases.
How do you monitor and attribute agent activity?
Make it possible to connect a distinct agent identity to its requests, tool calls, outputs, and resulting changes. Monitoring should support both routine oversight and investigation without creating an unnecessary store of sensitive data.
- Capture an operational trail. Record enough to reconstruct relevant activity, including the identity, action, result, and approval status. Protect sensitive information in logs and collect only what monitoring and investigation require.
- Connect monitoring to response. Identify who reviews alerts and which conditions require escalation. Make sure the agent’s activity is covered by the organisation’s incident-response process.
- Validate attribution. Confirm that records distinguish agent actions from human actions and support investigation and revocation.
- Assign responsibility. Name the people who review activity, handle alerts, and can suspend the agent before use.
For the ticket workflow, an investigator should be able to trace a draft to the agent identity, inspect relevant tool calls, and see whether a human approved or rejected the reply. Limit sensitive prompt and record content in those logs to what the team needs to understand the event.
How should teams review an agent after deployment?
Assign an owner before launch and define a review process that covers permissions, performance, data handling, and operational evidence. A deployed agent can become riskier when its model, tools, data, task, or operating conditions change, even if its original configuration passed review.
- Set the review cadence. Choose and document a schedule that reflects the agent’s risk and impact. Review higher-impact agents more often, and make sure the cadence is practical for the team responsible.
- Review activity and incidents. Check logs, alerts, approval outcomes, blocked actions, user reports, and incidents for signs that the agent is exceeding scope or that controls are failing.
- Reassess access and data. Confirm that each permission, tool connection, data source, memory store, and retention setting is still necessary. Remove access that no longer supports the task.
- Define change triggers. Require reassessment when the model or harness changes; a tool, identity, data source, or connected system is added; the task or user group expands; the agent gains new actions; or operating conditions materially change.
- Require renewed release gates. Re-test affected controls and obtain reapproval before expanding capabilities. Do not rely on the original release decision to cover a changed agent.
Document who can approve a change, which tests it requires, and how the team will roll back or disable the new capability. If an incident reveals a gap, keep the affected action disabled until the cause is understood, the control is corrected, and relevant tests pass.
What should you do when an agent fails or causes an incident?
Prepare to halt activity, revoke or expire credentials, isolate relevant connections, and investigate what the agent accessed or changed.
- Stop execution. Maintain a tested mechanism to halt activity immediately, and identify who can activate it.
- Contain access. Revoke or expire credentials and restrict relevant tool or network connections. Decide in advance who is authorized to take these steps.
- Preserve useful records. Retain what investigators need to identify actions and affected systems while protecting sensitive information.
- Use the established response process. Treat an agent incident as an organisational security issue, not solely as a product-support issue.
- Review before restoring service. Determine whether the failure involved scope, permissions, the harness, connected content, data handling, monitoring, or an approval gap. Update controls and tests before restoring the agent or expanding its capabilities.
If the team cannot establish what happened or whether the failure could recur, keep the affected capability disabled. Before re-enabling it, confirm that the cause is understood, corrective controls are in place, and relevant tests pass.
How can you secure AI agent deployment in phases?
Begin with the least autonomous mode that can meet the task. Use the release checklist above as the gate for each stage, and do not expand capability until the team has reviewed evidence from testing and operation.
- Start with a narrow task. Limit users, data, tools, and actions to what the agent needs to demonstrate value.
- Operate with close oversight. Keep consequential actions subject to approval and review whether the agent stays within its defined scope.
- Assess evidence before each expansion. Revisit test results, activity, incidents, permissions, and data handling. Define the next capability narrowly and test its specific risks.
- Pause when controls fail. Disable the affected action, address the cause, and repeat relevant tests before moving forward.
Staged deployment is not a substitute for security controls. It limits exposure while the team gathers evidence, but every stage still needs clear ownership, enforced boundaries, monitoring, and a tested response plan.
Frequently asked questions
Is a read-only AI agent safe from prompt injection?
No. Read-only access can limit some consequences, but it does not prove that an agent is safe. Prompt injection may affect how an agent interprets inputs or connected content. Define what data it can read, test hostile or misleading content, and monitor activity.
Should an agent’s development and production environments share memory?
Do not assume shared memory is necessary. Decide whether memory is required, what it contains, and which users or environments need access. Separate development and production memory unless a documented need and tested controls justify sharing. Test that one environment cannot retrieve another’s context.
What should a procurement review ask an AI agent vendor about security controls?
Ask how the product identifies agents, scopes permissions, constrains tools and network connections, supports human approval, records activity, limits sensitive data in logs, revokes access, and halts execution. Ask which controls operate in the harness and connected systems rather than relying only on model safeguards. Validate the answers against your deployment design; vendor documentation does not replace your own threat modeling.
How often should an organization revalidate an agent’s permissions?
Set a documented review cadence based on the agent’s risk, and revalidate permissions whenever the task, tools, identity, connected systems, or operating conditions change. Assign an owner to confirm that access remains necessary and to withdraw permissions promptly when it is not. Require testing and renewed approval before an agent gains additional capabilities.