AI Agent Security Solutions

AI agent security best practices, by layer

Good AI agent security practice limits what an agent can do before it acts. Apply least functionality, least permission and limited autonomy at each layer, put a blocking control on the tool call, issue short-lived scoped credentials, route traffic through a control point and keep logs that name the agent, the user and the tool.

Facts read on .

What are the best practices for AI agent security?

Cut the three root causes OWASP names for excessive agency: excessive functionality, excessive permissions and excessive autonomy. Give each agent only the tools it needs, only the permissions those tools need, and a human approval step for actions that are hard to undo.

Apply the same rule at every layer rather than once in the model prompt, because a prompt is advice to the model and a control is enforced outside it.

Start with an inventory, since you cannot limit what you have not found. List agents, the tools each can call, the credentials each holds and the data each can reach. Then apply the three limits to the list, agent by agent, beginning with the agents that can write, send or spend.

Sources: OWASP LLM06:2025 Excessive Agency.

Which practices stop an action rather than record it?

Controls that run before the call executes stop an action: a pre-tool hook on the endpoint, an allow list at a gateway, a Conditional Access block on the token, or a guardrail attached to the platform agent. Logging records the action after the fact.

Claude Code documents PreToolUse as running before a tool call executes and able to block it. Cisco's DefenseClaw says its guardrail checks a prompt, shell command or tool call before the agent acts. Bay says its enforcer decides allow, ask, deny or steer on every action.

Approval steps belong on the actions that are hard to undo: deleting data, sending messages outside the company, changing access and moving money. An ask decision that pauses the agent for a person is a stop in the same sense as a block, and it keeps the agent useful for the rest of its work.

Sources: Claude Code hooks reference; Cisco DefenseClaw: guardrail; Bay: agent runtime enforcement.

How should you handle credentials and tokens?

Issue short-lived, narrowly scoped credentials per task and keep the underlying secret away from the agent. Revoke on a schedule and on any suspicion.

RFC 9700 collects current OAuth security practice, and RFC 8693 defines token exchange, including delegation, which lets a service swap one token for another with narrower rights. Island says its MCP Gateway issues just-in-time credentials scoped to one task so the agent never sees the underlying secret.

Rotate on a schedule that matches the exposure. An agent that runs for minutes needs a credential that lives for minutes. Keep a list of standing credentials still held by agents and cut it each month. Where a service cannot issue short-lived credentials, place a gateway or broker in front of it.

Sources: RFC 9700, Best Current Practice for OAuth 2.0 Security; RFC 8693, OAuth 2.0 Token Exchange; Island: agentic identity.

How do you control which tools and MCP servers an agent can call?

Keep an approved list and deny everything else. WitnessAI says a tool or MCP server not on the approved list is denied before the tool executes.

The MCP specification treats a protected MCP server as an OAuth 2.1 resource server, so require authorization on every server you approve. Review remote servers before approval and pin versions of local ones.

For local MCP servers, record the package name, version and publisher at approval, and compare on every update. A server that changes its own tool descriptions after approval deserves a re-review. Remote servers should authenticate every client and issue tokens scoped to that server.

Sources: WitnessAI: agentic control; MCP specification: authorization.

What should you log for every agent?

Log the agent, the user it acts for, the tool, the arguments class, the decision and the rule that made it. Without those five fields an investigation cannot say who or why.

OpenTelemetry publishes GenAI semantic conventions, including agent spans, so logs from different tools can share field names. Forward them to the SIEM you already run.

Keep logs where an investigator can reach them and where a rogue agent cannot edit them. Send them to a store the agent has no write access to. Set a retention period long enough to cover your slowest detection, commonly several months.

Sources: OpenTelemetry GenAI semantic conventions.

How do you test that a control works?

Test each control with a harmless action it should block, then confirm the block, the log entry and the alert. Repeat after every agent or policy update.

Keep a list of the controls and the date each was last tested, and put it in the monthly report.

Include a test of the human path as well: confirm that the person who gets an approval request can read what the agent is asking to do and has the authority to decide. An approval prompt that nobody understands becomes a click-through.

Sources: NIST AI Risk Management Framework.

What belongs in a first-month plan?

Week one: inventory agents and approved tools. Week two: deploy one blocking control on the first layer in monitor mode. Week three: move the clear cases to block and scope the credentials of the five most capable agents. Week four: test, log and write the first report.

Each step uses controls you can install through tools you already run, so the plan needs process more than new products.

Sources: NIST AI Risk Management Framework; Claude Code hooks reference.

Sources