<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Josselin Guarnelli</title>
    <description>The latest articles on DEV Community by Josselin Guarnelli (@josselin_guarnelli).</description>
    <link>https://dev.to/josselin_guarnelli</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3848245%2F089559f9-b364-4cb0-ac4a-478a36fe6965.jpeg</url>
      <title>DEV Community: Josselin Guarnelli</title>
      <link>https://dev.to/josselin_guarnelli</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/josselin_guarnelli"/>
    <language>en</language>
    <item>
      <title>What I found scanning 3 AI agent codebases for unguarded tool calls</title>
      <dc:creator>Josselin Guarnelli</dc:creator>
      <pubDate>Wed, 03 Jun 2026 07:55:29 +0000</pubDate>
      <link>https://dev.to/josselin_guarnelli/what-i-found-scanning-3-ai-agent-codebases-for-unguarded-tool-calls-4g9b</link>
      <guid>https://dev.to/josselin_guarnelli/what-i-found-scanning-3-ai-agent-codebases-for-unguarded-tool-calls-4g9b</guid>
      <description>&lt;p&gt;669 functions that can write to a database, delete files, charge a card, spawn a subprocess, or hand control to another agent.&lt;/p&gt;

&lt;p&gt;553 of them had no guard of any kind. No input validation, no auth check, no rate limit, no confirmation step. Nothing between the model's decision and the side effect.&lt;/p&gt;

&lt;p&gt;That is 83%. None were confirmed.&lt;/p&gt;

&lt;p&gt;I got these numbers by pointing a static analyzer at three open-source TypeScript AI agent codebases and counting. Not a pen test. Not a CVE hunt. An inventory of what each agent &lt;em&gt;can do&lt;/em&gt; and which of those capabilities have a control in the code.&lt;/p&gt;

&lt;p&gt;This is the methodology, the full table, and — the part I care about most — the false positives I had to eliminate before I trusted any of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why an unguarded tool call is a different problem in an agent
&lt;/h2&gt;

&lt;p&gt;In a normal web app, a human clicks a button. The path to a side effect runs through a form, a validation layer, a confirmation dialog, a session rate limit. The dangerous call is wrapped in UI and middleware that someone designed on purpose.&lt;/p&gt;

&lt;p&gt;In an agent, an LLM decides which function to call, with which arguments, how many times. It does not know your business rules. It can loop, hallucinate an argument, or get talked into something by injected text in a tool result.&lt;/p&gt;

&lt;p&gt;So the guard cannot live in the UI anymore. There is no UI. The guard has to live in the code, right next to the call.&lt;/p&gt;

&lt;p&gt;The interesting question is no longer "is this app secure." It is: &lt;strong&gt;for every function the model can reach that does something real, is there a control in the code — and if not, do you know?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most teams don't. Not because they're careless, but because nobody has an inventory. You cannot review what you cannot see.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I actually measured
&lt;/h2&gt;

&lt;p&gt;I wrote &lt;code&gt;diplomat-agent-ts&lt;/code&gt;, a static scanner built on &lt;code&gt;ts-morph&lt;/code&gt; (the TypeScript compiler API). It walks the AST, finds call expressions that match a catalog of side-effect patterns, and checks whether each one has a guard in the same function. Two runtime dependencies, no config file, ~9 seconds on a 7,874-file codebase.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;tool call&lt;/strong&gt; here is any call that matches one of 40+ patterns across 12 side-effect categories:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;payment&lt;/code&gt; · &lt;code&gt;database_write&lt;/code&gt; · &lt;code&gt;database_delete&lt;/code&gt; · &lt;code&gt;http_write&lt;/code&gt; · &lt;code&gt;email&lt;/code&gt; · &lt;code&gt;messaging&lt;/code&gt; · &lt;code&gt;agent_invocation&lt;/code&gt; · &lt;code&gt;llm_call&lt;/code&gt; · &lt;code&gt;publish&lt;/code&gt; · &lt;code&gt;dynamic_code&lt;/code&gt; · &lt;code&gt;file_delete&lt;/code&gt; · &lt;code&gt;destructive&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;guard&lt;/strong&gt; is an in-file control the scanner can see syntactically: input validation (Zod, Yup, class-validator), a rate limit (a &lt;code&gt;@Throttle&lt;/code&gt; decorator, a custom limiter), an auth check, a confirmation step, an idempotency key, a retry bound.&lt;/p&gt;

&lt;p&gt;Each call lands in one of three states:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;no_checks&lt;/code&gt; — a side effect with no guard at all&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;partial_checks&lt;/code&gt; — some coverage, but missing at least one expected control&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;confirmed&lt;/code&gt; — explicitly acknowledged with a &lt;code&gt;// checked:ok&lt;/code&gt; annotation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One thing to flag up front, because it matters for reading the numbers: &lt;strong&gt;&lt;code&gt;confirmed&lt;/code&gt; requires an annotation that is this scanner's own convention.&lt;/strong&gt; None of the three projects has ever heard of it. So every external codebase shows zero confirmed by construction. That number is not an accusation. It's the floor.&lt;/p&gt;

&lt;p&gt;I ran each scan against an unmodified public clone at a pinned commit, so the findings reproduce exactly. Every command is in the repo's &lt;code&gt;MANIFEST.md&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And the framing that governs all of this: &lt;strong&gt;it's an inventory, not a score.&lt;/strong&gt; A high &lt;code&gt;no_checks&lt;/code&gt; count is a map of where to look, not a grade.&lt;/p&gt;

&lt;h2&gt;
  
  
  The numbers
&lt;/h2&gt;

&lt;p&gt;Three codebases, four scopes (I split OpenAI's framework packages from its examples because they behave differently).&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Codebase (scope)&lt;/th&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;TS files&lt;/th&gt;
&lt;th&gt;Tool calls&lt;/th&gt;
&lt;th&gt;&lt;code&gt;no_checks&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;&lt;code&gt;partial&lt;/code&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;OpenClaw&lt;/strong&gt; (&lt;code&gt;src/&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Application&lt;/td&gt;
&lt;td&gt;7,874&lt;/td&gt;
&lt;td&gt;419&lt;/td&gt;
&lt;td&gt;332 (79%)&lt;/td&gt;
&lt;td&gt;87&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mastra (&lt;code&gt;packages/&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Framework&lt;/td&gt;
&lt;td&gt;2,777&lt;/td&gt;
&lt;td&gt;185&lt;/td&gt;
&lt;td&gt;162 (88%)&lt;/td&gt;
&lt;td&gt;23&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OpenAI Agents JS (&lt;code&gt;packages/&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Framework&lt;/td&gt;
&lt;td&gt;426&lt;/td&gt;
&lt;td&gt;33&lt;/td&gt;
&lt;td&gt;31 (94%)&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OpenAI Agents JS (&lt;code&gt;examples/&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Examples&lt;/td&gt;
&lt;td&gt;302&lt;/td&gt;
&lt;td&gt;32&lt;/td&gt;
&lt;td&gt;28 (88%)&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Total&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;11,379&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;669&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;553 (83%)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;116&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;confirmed&lt;/code&gt; is zero across every scope, for the reason above.&lt;/p&gt;

&lt;p&gt;The 83% is the headline, but the spread is the more honest story. The leanest, most deliberately-built codebase in the set — OpenAI's framework packages — still came out at 94% &lt;code&gt;no_checks&lt;/code&gt;. That is not because the OpenAI team is sloppy. It's because guards mostly aren't where a static scanner looks. They live in middleware, in a gateway, in the runtime the framework expects you to wire up. The scanner sees the call site. It does not see the deployment.&lt;/p&gt;

&lt;p&gt;Which is exactly the point. The gap between "what the model can reach" and "what has a visible control" is real in every one of these repos. The number just makes it countable.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the categories reveal
&lt;/h2&gt;

&lt;p&gt;Counting side effects by category across all four scopes (a single call can carry more than one):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Category&lt;/th&gt;
&lt;th&gt;Occurrences&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;destructive&lt;/code&gt; (subprocess / shell)&lt;/td&gt;
&lt;td&gt;486&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;file_delete&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;214&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;publish&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;124&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;agent_invocation&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;120&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;http_write&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;86&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;llm_call&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;database_delete&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;dynamic_code&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The shape changes with the type of codebase. The application (OpenClaw) is dominated by &lt;code&gt;destructive&lt;/code&gt; and &lt;code&gt;file_delete&lt;/code&gt; — it's a tool that runs commands and manages files, so a huge fraction of its "tool calls" are the product, not a bug. The frameworks lean toward &lt;code&gt;publish&lt;/code&gt; and &lt;code&gt;agent_invocation&lt;/code&gt; — they hand control to other agents and ship artifacts, which is what frameworks do.&lt;/p&gt;

&lt;p&gt;I'll say the uncomfortable part myself: &lt;strong&gt;&lt;code&gt;destructive&lt;/code&gt; is the biggest category and also the one most prone to "well, that's literally the app's job."&lt;/strong&gt; A shell runner runs shells. Flagging every &lt;code&gt;execSync&lt;/code&gt; in it is technically correct and contextually obvious. That's why the output is an inventory you triage, not a verdict you act on blindly.&lt;/p&gt;

&lt;p&gt;On the governance side, every finding gets tagged with OWASP Agentic codes. The distribution: &lt;code&gt;ASI-02&lt;/code&gt; (tool misuse, the baseline tag) fires on all 669; &lt;code&gt;ASI-01&lt;/code&gt; (excessive agency — a side effect with no auth check) on 576; &lt;code&gt;ASI-03&lt;/code&gt; (privilege compromise — high-stakes op with no confirmation) on 465. The runtime-only codes (supply chain, misalignment, deception) are deliberately out of scope for static analysis.&lt;/p&gt;

&lt;h2&gt;
  
  
  The hard part was not finding side effects. It was not over-counting them
&lt;/h2&gt;

&lt;p&gt;Anyone can &lt;code&gt;grep&lt;/code&gt; for &lt;code&gt;.delete(&lt;/code&gt; and &lt;code&gt;exec(&lt;/code&gt;. That gets you a number in five minutes and the number is garbage. The work is in making it not garbage.&lt;/p&gt;

&lt;p&gt;The design rule that keeps this honest: &lt;strong&gt;patterns are data, the matcher is dumb on purpose.&lt;/strong&gt; When a real-world false positive shows up, I fix the pattern catalog, never the matching logic. Every fix below is a commit with a regression test, not a tweak to a heuristic.&lt;/p&gt;

&lt;p&gt;Four that mattered:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;regex.exec()&lt;/code&gt; is not a subprocess.&lt;/strong&gt; The &lt;code&gt;destructive&lt;/code&gt; category caught &lt;code&gt;exec&lt;/code&gt; in any file that imported &lt;code&gt;child_process&lt;/code&gt;. Including &lt;code&gt;RegExp.prototype.exec()&lt;/code&gt; on inline literals like &lt;code&gt;/^extensions\/([^/]+)\//.exec(path)&lt;/code&gt;. Pure string parsing, flagged as a shell spawn. Root cause was in the AST extraction: a regex-literal receiver fell through and produced a bare &lt;code&gt;exec&lt;/code&gt; name, indistinguishable from &lt;code&gt;exec()&lt;/code&gt;. Adding a &lt;code&gt;RegularExpressionLiteral&lt;/code&gt; case dropped OpenClaw by 17 findings and removed six legitimately-innocent parsing functions from the report.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;sandbox&lt;/code&gt; contains &lt;code&gt;db&lt;/code&gt;.&lt;/strong&gt; An early &lt;code&gt;database_delete&lt;/code&gt; pattern matched objects named &lt;code&gt;db&lt;/code&gt;. The string &lt;code&gt;sandbox&lt;/code&gt; contains the substring &lt;code&gt;d-b&lt;/code&gt; (san-&lt;strong&gt;db&lt;/strong&gt;-ox), so &lt;code&gt;SANDBOX_BACKEND_FACTORIES.delete()&lt;/code&gt; got logged as a database deletion. Substring matching on short generic names is fundamentally fragile. Fix: require the canonical receiver name (&lt;code&gt;prisma&lt;/code&gt;) or an actual &lt;code&gt;drizzle-orm&lt;/code&gt; import.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;deploy&lt;/code&gt; is a verb that lives inside other words.&lt;/strong&gt; Matching &lt;code&gt;nameContains: ["deploy"]&lt;/code&gt; flagged &lt;code&gt;cancelDeploy&lt;/code&gt;, &lt;code&gt;getDeployStatus&lt;/code&gt;, &lt;code&gt;listDeployments&lt;/code&gt; — query and management operations, not publish side effects — all over Mastra's deployer package. Switching to an exact match on a bare &lt;code&gt;deploy()&lt;/code&gt; call removed 39 false positives in one commit. Manual audit confirmed all ten sampled were genuine FPs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;client.messages.create()&lt;/code&gt; is Anthropic, not Twilio.&lt;/strong&gt; Same method name, completely different side effect. This is why ambiguous patterns carry an &lt;code&gt;importContains&lt;/code&gt; condition: the pattern only fires if the disambiguating package is imported in the file. The ordering of the pattern table encodes priority — payments first, LLM calls before database writes — so &lt;code&gt;client.chat.completions.create()&lt;/code&gt; never gets misfiled as a DB write.&lt;/p&gt;

&lt;p&gt;I'd rather report 419 findings I can defend than 471 I have to apologize for. The validation pass on OpenClaw started at a 30% false-positive rate on a sampled audit. Killing that is the actual product.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this does not tell you
&lt;/h2&gt;

&lt;p&gt;The honest limitations, because a technical reader will find them anyway:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Unguarded is not the same as vulnerable.&lt;/strong&gt; A flagged call can be completely safe — the guard might live in middleware, a gateway, or a layer the scanner can't see. The output tells you where to look, not what's broken.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It's static only.&lt;/strong&gt; No runtime detection. If protection is enforced outside the file, the scanner can't know that unless you annotate it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It's intra-procedural.&lt;/strong&gt; Guard detection looks at the same function and its immediate decorators. A guard three call-frames away in another file won't be credited. Cross-function analysis is the next milestone, not a current claim.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It needs the import for ORM patterns.&lt;/strong&gt; Mongoose, Sequelize, and TypeORM use generic method names (&lt;code&gt;.save()&lt;/code&gt;, &lt;code&gt;.create()&lt;/code&gt;), so those patterns are scoped to files that import the ORM. Re-exported models get missed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;confirmed&lt;/code&gt; is zero for external repos by construction.&lt;/strong&gt; The annotation is this tool's convention. Read the zero as "nobody opted in," not "nobody bothered."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you need runtime enforcement or semantic intent analysis, this is the wrong tool. It's a scanner. It reads code and counts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run it on your own agent
&lt;/h2&gt;

&lt;p&gt;The interesting number is not mine. It's yours.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; @diplomat-ai/diplomat-agent-ts
npx diplomat-agent-ts scan &lt;span class="nb"&gt;.&lt;/span&gt;        &lt;span class="c"&gt;# or ./src, ./packages&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It prints a colored report. To get a committable inventory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx diplomat-agent-ts scan &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;--output-registry&lt;/span&gt; toolcalls.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;toolcalls.yaml&lt;/code&gt; is like &lt;code&gt;package-lock.json&lt;/code&gt;, but for what your agent can &lt;em&gt;do&lt;/em&gt; instead of what it depends on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;tool_calls&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;function&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;chargeCustomer&lt;/span&gt;
    &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;src/payments.ts&lt;/span&gt;
    &lt;span class="na"&gt;line&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;42&lt;/span&gt;
    &lt;span class="na"&gt;actions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;return&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;stripe.charges.create({&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;amount,&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;currency,&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;customer&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;})"&lt;/span&gt;
    &lt;span class="na"&gt;checks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[]&lt;/span&gt;
    &lt;span class="na"&gt;missing&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;no bounds on amount&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;no rate limit&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;no idempotency key&lt;/span&gt;
    &lt;span class="na"&gt;owasp&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;ASI-01&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;ASI-02&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;ASI-03&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;ASI-06&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Commit it. Diff it in PRs. When the agent gains a new capability, it shows up in review before it ships.&lt;/p&gt;

&lt;p&gt;When a call is intentionally unguarded — or protected somewhere the scanner can't see — say so inline, and the next scan moves it to &lt;code&gt;confirmed&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// checked:ok — protected by middleware/approval.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;chargeCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;customerId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;stripe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;charges&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;usd&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;customerId&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And to make new unguarded calls fail a build:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Diplomat governance scan&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx -y @diplomat-ai/diplomat-agent-ts scan . --fail-on-unchecked&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The scanner is Apache-2.0, two dependencies, TypeScript-only. The benchmark artifacts above reproduce exactly at the pinned commits — every command is in the repo.&lt;/p&gt;

&lt;p&gt;Repo and reproducible benchmarks: &lt;strong&gt;github.com/Diplomat-ai/diplomat-agent-ts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run it on whatever you shipped last week. The 83% was three codebases I didn't write. I'm more curious what it says about the ones I did.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>security</category>
      <category>typescript</category>
      <category>opensource</category>
    </item>
    <item>
      <title>We Scanned 16 AI Agent Repos. 76% of Tool Calls Had Zero Guards.</title>
      <dc:creator>Josselin Guarnelli</dc:creator>
      <pubDate>Sat, 28 Mar 2026 21:58:45 +0000</pubDate>
      <link>https://dev.to/josselin_guarnelli/we-scanned-16-ai-agent-repos-76-of-tool-calls-had-zero-guards-5c2h</link>
      <guid>https://dev.to/josselin_guarnelli/we-scanned-16-ai-agent-repos-76-of-tool-calls-had-zero-guards-5c2h</guid>
      <description>&lt;p&gt;We scanned 16 open-source AI agent repositories — both agent frameworks (CrewAI, PraisonAI) and production agent applications (Skyvern, Dify, Khoj, and others) that ship real business logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;76% of tool calls with real-world side effects had zero protective checks.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No rate limits. No input validation. No confirmation steps. No auth checks.&lt;/p&gt;

&lt;p&gt;An important nuance: you'd expect framework code to lack guards — it's template code, and adding guards is the implementor's job. But the same pattern holds in production agent applications with real business logic. Skyvern (browser automation, 595 files): 76% unguarded. Dify (LLM platform, 1000+ files): 75% unguarded. The frameworks aren't the problem — the problem is that nobody adds guards when they build on top of them either.&lt;/p&gt;

&lt;p&gt;This means a single prompt injection — or a simple hallucination — could trigger hundreds of unvalidated database writes, unchecked HTTP requests to arbitrary URLs, or file deletions without confirmation.&lt;/p&gt;

&lt;p&gt;Here's what we found, how we found it, and how you can audit your own agent code in 60 seconds.&lt;/p&gt;

&lt;h2&gt;
  
  
  What We Scanned
&lt;/h2&gt;

&lt;p&gt;We analyzed 16 open-source repos in two categories:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Agent applications&lt;/strong&gt; — repos that ship real business logic: browser automation agents, AI assistants, LLM platforms with tool-calling capabilities. These are the repos where guards &lt;em&gt;should&lt;/em&gt; exist because the code runs in production against real databases and APIs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Agent frameworks&lt;/strong&gt; — repos like CrewAI and PraisonAI that provide scaffolding for building agents. Framework code is intentionally generic — it exposes tool call patterns without business-specific guards, because that's the implementor's responsibility.&lt;/p&gt;

&lt;p&gt;We report findings for both categories, but the story that matters is the application layer: even when developers build on top of frameworks and add their own logic, the guards don't show up.&lt;/p&gt;

&lt;p&gt;For each repo, we asked a simple question: &lt;strong&gt;which functions can change the real world, and which ones have guards?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A "tool call with side effects" is any function that can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write to a database (&lt;code&gt;session.commit()&lt;/code&gt;, &lt;code&gt;.save()&lt;/code&gt;, &lt;code&gt;.create()&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Delete data (&lt;code&gt;session.delete()&lt;/code&gt;, &lt;code&gt;os.remove()&lt;/code&gt;, &lt;code&gt;shutil.rmtree()&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Make HTTP write requests (&lt;code&gt;requests.post()&lt;/code&gt;, &lt;code&gt;httpx.put()&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Process payments (&lt;code&gt;stripe.Charge.create()&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Send emails or messages (&lt;code&gt;smtp.sendmail()&lt;/code&gt;, &lt;code&gt;slack_client.chat_postMessage()&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Invoke another agent (&lt;code&gt;graph.ainvoke()&lt;/code&gt;, &lt;code&gt;agent.execute()&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Execute dynamic code (&lt;code&gt;exec()&lt;/code&gt;, &lt;code&gt;eval()&lt;/code&gt;, &lt;code&gt;importlib.import_module()&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A "guard" is any check that protects that call:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Input validation (&lt;code&gt;Field(le=10000)&lt;/code&gt;, &lt;code&gt;@validator&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Rate limiting (&lt;code&gt;@rate_limit&lt;/code&gt;, &lt;code&gt;@throttle&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Auth checks (&lt;code&gt;Depends()&lt;/code&gt;, &lt;code&gt;Security()&lt;/code&gt; in FastAPI)&lt;/li&gt;
&lt;li&gt;Confirmation steps (&lt;code&gt;confirm&lt;/code&gt;, &lt;code&gt;approve&lt;/code&gt; in function body)&lt;/li&gt;
&lt;li&gt;Idempotency (&lt;code&gt;idempotency_key&lt;/code&gt;, &lt;code&gt;get_or_create&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Retry bounds (&lt;code&gt;max_retries=&lt;/code&gt;, &lt;code&gt;@retry(stop=stop_after_attempt())&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Results
&lt;/h2&gt;

&lt;h3&gt;
  
  
  By repo
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Repo&lt;/th&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Files&lt;/th&gt;
&lt;th&gt;Tool calls&lt;/th&gt;
&lt;th&gt;Unguarded&lt;/th&gt;
&lt;th&gt;%&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Skyvern&lt;/td&gt;
&lt;td&gt;Application&lt;/td&gt;
&lt;td&gt;595&lt;/td&gt;
&lt;td&gt;452&lt;/td&gt;
&lt;td&gt;345&lt;/td&gt;
&lt;td&gt;76%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dify&lt;/td&gt;
&lt;td&gt;Platform&lt;/td&gt;
&lt;td&gt;1000+&lt;/td&gt;
&lt;td&gt;1,009&lt;/td&gt;
&lt;td&gt;759&lt;/td&gt;
&lt;td&gt;75%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PraisonAI&lt;/td&gt;
&lt;td&gt;Framework&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;1,028&lt;/td&gt;
&lt;td&gt;911&lt;/td&gt;
&lt;td&gt;89%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CrewAI&lt;/td&gt;
&lt;td&gt;Framework&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;348&lt;/td&gt;
&lt;td&gt;273&lt;/td&gt;
&lt;td&gt;78%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Full results for all 16 repos: &lt;a href="https://github.com/Diplomat-ai/diplomat-agent/blob/main/REALITY_CHECK_RESULTS.md" rel="noopener noreferrer"&gt;REALITY_CHECK_RESULTS.md&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What we found unguarded
&lt;/h3&gt;

&lt;p&gt;Across all repos, the most common unguarded categories were database writes, database deletes, HTTP write requests, subprocess/exec/eval calls, LLM calls, and email/messaging. The pattern is consistent: the more dangerous the action, the less likely it has guards.&lt;/p&gt;

&lt;p&gt;A note on methodology: subprocess/exec/eval calls are a different class of risk — these should generally be eliminated entirely, not guarded. The scanner also prioritizes recall over precision: we'd rather flag a function that might be fine than miss one that isn't. Based on manual review, the false positive rate is roughly 15-20% — mostly from generic &lt;code&gt;.save()&lt;/code&gt; calls that turn out to be config or file operations rather than database writes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Matters For AI Agents Specifically
&lt;/h2&gt;

&lt;p&gt;You might think: "Unguarded function calls exist in every codebase. What makes agents special?"&lt;/p&gt;

&lt;p&gt;The difference is &lt;strong&gt;who calls these functions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In a traditional web app, a human user triggers actions through a UI with built-in constraints — forms with validation, buttons with confirmation dialogs, rate limits per session.&lt;/p&gt;

&lt;p&gt;In an agent, an &lt;strong&gt;LLM decides which functions to call, with what arguments, how many times&lt;/strong&gt;. The LLM doesn't know your business rules. It doesn't understand that calling &lt;code&gt;refund()&lt;/code&gt; 200 times in a loop is catastrophic. And if an attacker crafts a prompt injection, the LLM will happily execute whatever functions it has access to — as many times as it's told.&lt;/p&gt;

&lt;p&gt;Without guards in the code, there's nothing between the LLM's decision and the real-world consequence.&lt;/p&gt;

&lt;p&gt;A concrete example from our scan: &lt;a href="https://github.com/khoj-ai/khoj" rel="noopener noreferrer"&gt;Khoj&lt;/a&gt;, an open-source AI assistant, exposes a function called &lt;code&gt;ai_update_memories&lt;/code&gt; that lets the LLM delete and replace user memories. It calls &lt;code&gt;session.delete()&lt;/code&gt; followed by &lt;code&gt;session.add()&lt;/code&gt; with no confirmation, no rate limit, and no validation on the content. A single adversarial prompt could wipe and replace a user's entire memory store.&lt;/p&gt;

&lt;h2&gt;
  
  
  How We Built the Scanner
&lt;/h2&gt;

&lt;p&gt;We built &lt;a href="https://github.com/Diplomat-ai/diplomat-agent" rel="noopener noreferrer"&gt;diplomat-agent&lt;/a&gt;, an AST-based static analyzer for Python. It uses Python's built-in &lt;code&gt;ast&lt;/code&gt; module — zero required dependencies. Optional: &lt;code&gt;rich&lt;/code&gt; for colored terminal output.&lt;/p&gt;

&lt;p&gt;Why AST and not regex?&lt;/p&gt;

&lt;p&gt;Regex pattern matching misses most real-world code patterns. A function call like &lt;code&gt;db.session.commit()&lt;/code&gt; can appear as a direct call, nested inside a try/except, called through a variable alias, or buried three levels deep in a helper function. AST understands the code structure — it parses the actual syntax tree, not text patterns.&lt;/p&gt;

&lt;p&gt;The scanner walks every Python file in your project (excluding tests, migrations, venv, examples, and other non-production directories), visits every function definition, and for each function:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Finds all calls that match side-effect patterns (DB writes, HTTP calls, deletes, payments, etc.)&lt;/li&gt;
&lt;li&gt;Finds all guards in scope (validators, rate limits, auth checks, confirmation steps)&lt;/li&gt;
&lt;li&gt;Outputs a verdict: UNGUARDED, PARTIALLY_GUARDED, GUARDED, or LOW_RISK (for read-only functions)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The default output is a terminal report showing every finding with its verdict. You can also generate a &lt;code&gt;toolcalls.yaml&lt;/code&gt; registry (with &lt;code&gt;--format registry&lt;/code&gt;) — a committable inventory of every function with side effects, the guards present or missing, and actionable hints.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It On Your Own Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;diplomat-agent
diplomat-agent &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. Zero config, zero required dependencies. Takes about 2-3 seconds on a 1000-file repo.&lt;/p&gt;

&lt;p&gt;The output looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;diplomat-agent — governance scan

Scanned: ./my-agent
Tools with side effects: 12

⚠ send_report(endpoint, payload)
  Rate limit:             NONE
  → Risk: agent could exhaust external API quota with 200 calls
  ⤷ no rate limit · no auth check
  Governance: ❌ UNGUARDED

⚠ send_notification(user_id, message)
  Rate limit:             NONE
  → Risk: agent could send 200 messages — spam risk
  ⤷ no rate limit · no auth check
  Governance: ❌ UNGUARDED

✓ process_order(order_id)
  Write protection:       Input Validation (FULL)
  Rate limit:             Rate Limit (FULL)
  Governance: ✅ GUARDED

────────────────────────────────────────────
RESULT: 8 with no checks · 3 with partial checks · 1 guarded (12 total)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What To Do When You Find Gaps
&lt;/h2&gt;

&lt;p&gt;For each unguarded tool call, you have four options:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix it&lt;/strong&gt; — add validation, rate limiting, or confirmation in code. The next scan picks it up automatically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Acknowledge it&lt;/strong&gt; — if the function is intentionally unguarded or protected elsewhere, add &lt;code&gt;# checked:ok&lt;/code&gt; as a comment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;send_alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;  &lt;span class="c1"&gt;# checked:ok — protected by API gateway
&lt;/span&gt;    &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ALERT_URL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;msg&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Add it to CI&lt;/strong&gt; — block PRs that introduce new unguarded tool calls:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;diplomat-agent &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;--fail-on-unchecked&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you commit &lt;code&gt;toolcalls.yaml&lt;/code&gt; as a baseline, only &lt;em&gt;new&lt;/em&gt; findings block — no noise on legacy code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Review the inventory&lt;/strong&gt; — the &lt;code&gt;toolcalls.yaml&lt;/code&gt; file is meant to be committed and reviewed in PRs. When someone adds a new function that can delete data, it shows up in the diff.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Bigger Picture
&lt;/h2&gt;

&lt;p&gt;We're building AI agents that can modify databases, send money, delete files, and call external APIs — and we're giving them zero guardrails in code.&lt;/p&gt;

&lt;p&gt;The OWASP Top 10 for Agentic Applications (released December 2025) explicitly recommends maintaining a complete inventory of all agentic components, their permissions, and their capabilities. The EU AI Act (enforceable August 2026) requires documenting system capabilities and human oversight measures for high-risk AI systems.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;toolcalls.yaml&lt;/code&gt; is a step toward that. It's not a complete governance solution — it's a starting point. You can't govern what you can't see.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub&lt;/strong&gt;: &lt;a href="https://github.com/Diplomat-ai/diplomat-agent" rel="noopener noreferrer"&gt;github.com/Diplomat-ai/diplomat-agent&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Install&lt;/strong&gt;: &lt;code&gt;pip install diplomat-agent &amp;amp;&amp;amp; diplomat-agent .&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;License&lt;/strong&gt;: Apache 2.0&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The scanner is open source, the findings are reproducible. Run it on your agent code and tell me what you find.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;What unguarded tool calls are hiding in your agent code? Run the scan and share your results — I'll respond to every comment.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>security</category>
      <category>ai</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
