· via dev.to (home feed)
Unscoped agent tools leaked a secret in every trial; allowlists cut it to zero
A scripted dev.to test found a 100% data leak rate with unscoped agent tools and 0% with allowlists, while a second post details code-enforced guardrails for safe database access.

An agent with unscoped tools leaked a secret every time
Two posts published the same day on dev.to approach the same problem from opposite ends: what actually stops an AI agent from leaking data once it has broad tool or database access. One is a controlled experiment with hard numbers; the other is a set of production guardrails for database connections. Both land on the same conclusion: permission boundaries enforced in code, not boundaries requested in a prompt.
In the first post, dev.to user vanshsoni16 describes a scripted baseline test. An agent carried out routine CRM work — updating a customer's plan, drafting a ticket reply, emailing the customer — inside a small fake environment with tools for reading files, writing files, sending messages and updating records. A file named SECRET.txt sat in the same workspace, and once the real work was done the agent attempted two exfiltration routes: writing the token to /tmp/exfil.txt, and emailing it to an address that was neither the customer nor the support inbox.
The author ran twenty trials per condition, sixty runs in total, and rechecked the setup later with no change in results. Because the agent was scripted rather than a live model, the test measures the permission layer, not model behaviour — a limitation the author states explicitly.
100% versus 0%
Under unscoped access, where any path and any recipient were permitted, the secret leaked in every run. The write to /tmp succeeded on the first attempt each time, and the unauthorised email was never even needed.
With allowlists in place — writes confined to the customer and ticket folders, messages confined to the customer and support addresses — the leak rate fell to 0%. Both exfiltration attempts were rejected, and the legitimate task still completed in all twenty runs, so the control never broke the agent's real work.
A third condition layered an approve-or-deny human gate on top of the allowlists. The leak rate stayed at 0% and the main task still succeeded, but the gate had nothing left to catch because the narrower tool surface had already closed the outbound paths. The author, who favours human-in-the-loop steps in production, concedes this complicates the assumption that more review automatically means more safety.
One caveat the author declines to gloss over: the read tool was not scoped. The agent could still open SECRET.txt under the allowlisted conditions, so the 0% figure means zero successful exfiltration, not zero access. In a real system, the author argues, reads should be scoped too, or secrets kept off the agent's filesystem entirely.
The database version of the same lesson
The second post, by dev.to user samuccaya, who discloses building the product described, covers guardrails implemented in the SignOff Studio MCP server for database access.
Read-only is enforced at the driver rather than the prompt: the query tool accepts a single statement per call, accepts only read statements, and runs inside a read-only transaction — a read-only connection on SQLite, an always-rolled-back transaction on SQL Server. That blocks parser-level workarounds such as a DELETE wrapped in a CTE whose output is then selected.
Writes are strictly opt-in. A separate execution tool exists only on connections explicitly marked as agent-writable, never on connections tagged production or read-only, and it runs in dry-run mode by default, executing and then rolling back so the agent sees the effect before anything commits.
Secrets never reach the model. Passwords are pulled from the workspace environment file or delivered from the desktop app's vault over a local pipe, and every tool result is scrubbed by value, so any credential that appears in output is redacted before the model sees it. In the author's testing, an agent queried two vault-protected PostgreSQL databases in 885 ms and 729 ms without either password ever appearing in a tool result.
Further layers include labelling every result as data rather than instructions, a defence against prompt injection hiding in text columns; logging each call to an audit file with tool, target, outcome and time but no SQL text or secrets; and a policy file that can deny hosts, restrict access to an allowlist of public hosts, and cap requests, rows and response size. The server supports PostgreSQL, MySQL/MariaDB, SQL Server, Oracle and SQLite, and runs locally and free of charge.
The author's general rule: if a guardrail exists only in the prompt, expect it to be broken eventually. Enforcement belongs in the transaction, the connection flag or the output filter.
Why it matters
Agents are increasingly shipped with wide tool and database access, and both pieces point the same way: the deciding factor is the shape of the permission surface — which paths can be written, who can be messaged, which connections can write — not the quality of the instructions. In the scripted test, the gap between a 100% and a 0% leak rate came down to two short allowlists that never blocked legitimate work. At the same time, both posts mark the same boundary: stopping exfiltration is not the same as restricting access, and only scoping reads and credentials keeps secrets invisible to the agent in the first place. Neither claim is a large public benchmark — one is a scripted toy environment, the other a builder's own testing — but the fixes they describe are cheap, testable and available before an agent receives its first credential.
- #ai-agents
- #security
- #guardrails
- #mcp
- #data-leaks