← AI agents and your data

What are the best practices for AI agent security?

Updated · DBShifts

Short answer

Treat every AI agent as an untrusted user that can be talked into anything. Give each its own identity and only the access its task needs, mask sensitive data on the server, treat everything it reads as untrusted, cap what it can do, require a person for risky actions, and log every request so you can prove what happened.

Key facts

  • The model is not a security boundary: anything an agent can be asked to do, it can be tricked into doing.
  • Each agent needs its own revocable identity, never a credential shared with other agents.
  • Access should be default-deny: tables, tools and other agents are reachable only by an explicit rule.
  • Everything an agent reads — tool results, retrieved documents, other agents' replies — is untrusted input.
  • Actions with consequences, such as writes, payments and deletions, should wait for a person.
  • Every request, including the refused ones, should be logged with the agent and the person it acted for.

In the glossary:Agentic AI

1. Start from identity

One token per agent, so you can tell agents apart in the log and stop one without stopping the rest. When an agent acts for a person, the person signs in and the agent carries their identity, so it reads with their permissions rather than a superuser's. Keep tokens short-lived and bound to the one service they are for.

2. Least privilege for data and tools

Allow the specific tables, columns and tools a task needs, not a whole database or a whole tool server. Mask personal data on the server that returns it. Check tool arguments, not just tool names. Cap rows per request and cumulative reads per agent.

3. Assume prompt injection

Any text an agent reads can carry instructions. Scan returned data, tool descriptions and other agents' replies, and never let retrieved content change what an agent is permitted to do — permissions live on the server, not in the conversation.

4. Contain the blast radius, then prove it

Rate limits, usage budgets and loop limits keep a confused agent from doing damage at machine speed, and a kill switch stops it at once. An audit log of every request — ideally tamper-evident — and traces across agents let you show exactly what happened afterwards.

Checklist

  1. 1

    A separate, revocable identity for every agent

  2. 2

    Per-person sign-in when an agent acts for a user

  3. 3

    Default-deny allowlists for tables, columns, tools and agents

  4. 4

    Server-side masking of personal data and blocking of secrets

  5. 5

    Injection scanning of results, descriptions and agent replies

  6. 6

    Rate limits, budgets, loop limits and a kill switch

  7. 7

    Human approval for writes and other consequential actions

  8. 8

    An audit log of every request, including refusals

Common mistakes

Relying on the system prompt

Instructions to the model are suggestions it can be talked out of. Rules belong in the server that returns the data or runs the tool.

One shared credential for all agents

You cannot attribute a request, scope access per task or revoke one agent without breaking every other.

Logging only what succeeded

Refused requests are where misuse shows up first. A log without them hides the attempts that matter.

How DBShifts does it

  • DBShifts Agent Gateway gives each agent a scoped token and enforces table and column allowlists, server-side PII masking, row caps, rate limits and usage budgets, a prompt-injection shield and a kill switch, with every request in an audit log and a tamper-evident ledger.
  • DBShifts Agent Mesh applies default-deny rules to agent-to-agent and agent-to-tool calls, masks data on every hop, signs a chain token that names who asked, stops loops and fan-out, and holds risky calls for approval.
  • Neither uses an AI model to make decisions: every check is a fixed rule.

Questions people also ask

What is the biggest AI agent security risk?

Over-broad access combined with prompt injection. An agent that can read or do too much, and that takes instructions from the data it reads, will eventually be told to misuse that access.

Is a read-only database user enough?

It stops writes. It does not stop an agent reading far more than its task needs, exposing personal data, or following instructions planted in a row. Use it as the ceiling and govern each agent beneath it.

Related questions

Give AI agents data access you can defend

Scoped tokens, PII masked on the server, every request audited. Free to start.

Start free

28 answers in this series. See all or browse the AI agent glossary.