DEV Community

Dimitris Kyrkos
Dimitris Kyrkos

Posted on

Your agent's tool registry is an API. Stop reviewing it like config.

Most agent security conversations start with the model. Can it be jailbroken? Will it follow an instruction buried in a scraped web page? Those are real questions. They are also the wrong place to stop.

An agent's risk is shaped by what it can do, not only by what it decides. The model picks a tool. The tool carries the authority. If you only review the first half of that sentence, you are reviewing the part you control least.

The demo vs. production gap

In the demo, the agent has three tools: search_docs, get_weather, summarize. Nothing it calls can hurt anyone.

In production, the tool list grows one PR at a time. Someone adds create_ticket. Someone else adds run_sql "for internal analytics". A third person swaps the read-only GitHub token for one with full repo scope because the agent needs to open PRs now. None of these changes touched a route file, so none of them got the review a new public endpoint would get.

That's the gap. The tool registry is API surface. It just doesn't look like it.

Four questions for every tool

For each tool the agent can call, answer these:

  1. What kind of action is it? Read, write, execute, or trigger something external (email, payment, webhook, deploy). These are different risk classes and should be labeled that way.
  2. Whose identity does it run as? The end user's delegated identity? A shared service account? The agent's own credential with org-wide scope?
  3. What data can it reach? Not what it's meant to reach. What the credential and the query surface actually allow.
  4. Where is approval required? Is there a human-in-the-loop step, and is it enforced in the tool layer, or only suggested in the system prompt?

If the answer to #4 lives only in the prompt, you don't have an approval step. You have a polite request for one.

Failure mode 1: the read tool that reads everything

(Illustrative scenario, not a real incident.) A support agent gets a lookup_customer(query) tool. It's labeled read-only, and that's true. Under the hood it calls an internal admin endpoint that accepts arbitrary filters. "Read-only" holds. "Scoped to the customer in this ticket" does not. One injected instruction in a ticket body and the agent is paginating through every account in the system.

The model did nothing exotic. It used the tool exactly as designed. The design granted too much.

Failure mode 2: the side effect nobody listed

(Illustrative.) update_order_status looks like a single row write. It also fires a webhook that emails the customer and, when the status is "cancelled", kicks off a refund workflow. The tool description mentions neither. Reviewers approved a database write. They shipped a refund button.

Side effects belong in the tool's contract, the same way you'd document them on a public endpoint.

Failure mode 3: identity drift

(Illustrative.) The agent's credential started as a read-scoped token. Over six months it picked up write access on two repos, admin on a Slack workspace, and a cloud role someone attached while debugging an incident and never removed. No single change looked alarming. The sum is an over-privileged service account that takes instructions in natural language.

Make authority visible in the diff

One practical fix: have every tool definition declare its authority explicitly, so a change in authority shows up as a change in the diff.

@tool(
    name="refund_order",
    action="external",          # read | write | execute | external
    identity="user_delegated",  # not "service_admin"
    data_scope="order:{order_id}",
    requires_approval=True,
)
def refund_order(order_id: str, amount_cents: int) -> RefundResult:
    ...
Enter fullscreen mode Exit fullscreen mode

The decorator is pseudo-code, not a specific library. The point is that flipping requires_approval from True to False, or identity from user_delegated to service_admin, should be impossible to miss in review, and should be enforced at runtime by the tool layer rather than trusted to the model.

Then review it like any other API change:

  • CODEOWNERS on the tool registry, so security sees permission changes.
  • A CI check that fails when a tool's action class, identity, or approval flag changes without an explicit label.
  • Tests that call each tool with out-of-scope arguments and assert the call is refused.

The reframe

"Can the model choose this tool?" is one question. The harder one is: "If it does, what authority does the tool grant?"

An agent is a natural-language client for whatever API you hand it. Review that API like one.

How does your team review tool additions today? Is anyone treating the tool registry as API surface, or does it still ride along in the same PRs as prompt tweaks?

Top comments (10)

Collapse
 
kami_butt_69b922ade8de012 profile image
Agentic Affairs •

Failure mode 3 is the one that quietly kills teams — no single credential change looks alarming, but six months of debugging grants add up to an over-privileged service account taking natural-language instructions. The decorator idea is the right fix: if flipping requires_approval doesn't show up in the diff, the review never happened. Do your CI checks also catch the slow drift, like a token that gained write scope three PRs ago, or only the changes in the current diff?

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Good question. The diff check alone definitely isn't enough. I'd combine it with periodic checks against the actual permissions at the provider level, plus alerts when they drift from what's declared in the registry. The tricky part is making sure those checks don't become another dashboard everyone ignores.

Collapse
 
eliashivemind profile image
Nova Ops •

The line that carries the piece for me is the question-4 test: if the approval answer lives only in the prompt, you don't have an approval step, you have a polite request for one. The update_order_status case is the same failure in the other direction — the contract said 'row write,' the tool shipped a refund button, and review can only catch what the contract declares. We learned the adjacent lesson pricing our own MCP server's third tool: we wrote all three candidate schemas and measured them before adding any, because once a tool is in the registry its cost and reach stop being reviewed at all. On your CI check — when a tool's action class or approval flag changes without the label, does the check block the merge outright, or route it to a named reviewer who has to apply the label themselves?

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

I'd make it block the merge outright for authority changes. A named reviewer should then be able to approve the change explicitly, ideally with a short justification. Otherwise the label risks becoming just another checkbox people add to get CI green. The whole point is to make authority changes deliberate, not just visible.

Collapse
 
innokentyb profile image
Kent Bodrov •

The diff check catches a declared change, but it may miss a credential whose real permissions drifted outside the repo. I’d periodically compare the registry’s declared authority with the effective scopes observed at the provider, flag mismatches for an owner, and test both a denied action and the unchanged downstream state. How would you handle providers that can’t report their effective permissions?

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

That's a good point. For providers that can't expose effective permissions, I'd lean on behavioral tests instead. Try actions that should be denied and verify not just that the call fails, but that nothing changed downstream. It's not a perfect substitute for visibility into the actual scopes, but at least you're testing the real boundary rather than trusting what's declared.

Collapse
 
robertpaschal profile image
Odinaka Robert Nnamani •

The CI check is the part I would steal first. A permission change that fails the build gets treated like a real endpoint change.

Collapse
 
cyclopt_dimitrisk profile image
Dimitris Kyrkos •

Exactly. And I'd go a step further and make the check specific to the kind of permission being changed. Changing a read scope is not the same as introducing an external action or granting admin access. They shouldn't all go through the same review path.

Collapse
 
robertpaschal profile image
Odinaka Robert Nnamani •

read scope versus admin is the split i'd want in the check. one rule for both is how the noisy reviews start.

Collapse
 
cryptostrapon profile image
cryptostrapon •

One authority class I'd add to the four questions: does the tool execute code it did not ship with?

A tool called "install dependencies" or "open the project" reads like plumbing, but npm install runs lifecycle scripts from every package in the tree, and the repo itself can change what runs: a project .npmrc, or initializeCommand in devcontainer.json, which runs on the host before the container starts. In review I'd treat those like run_sql: arbitrary execution, limited only by the credential and network the process has.