Tools and side effects
Understand automatic tool discovery, complete schemas, execution traces, approvals, and safe scan environments.
Runtime integrations include every configured tool by default. ZeroLeaks receives serializable definitions, while executable functions and provider credentials remain in your SDK process.
Tool definitions
interface AgentTool {
name: string;
description?: string;
inputSchema?: unknown;
outputSchema?: unknown;
strict?: boolean;
type?: string;
providerOptions?: unknown;
definition?: unknown;
}The AI SDK adapter converts flexible schemas to JSON Schema automatically. OpenAI adapters preserve the original native tool object in definition and expose function parameters through inputSchema.
If tools are selected dynamically, put the selection logic inside the wrapped production handler or AI SDK agent. The scan then observes the same per-step availability, approval rules, and execution behavior as normal traffic.
Tool traces
For each tool call, a report can include the tool name and call ID, parsed arguments, returned value, thrown or returned errors, whether the provider executed the tool, and the attack prompt and isolated scan session that produced the call.
Tool containment
From version 0.5.0, the OpenAI adapters and the AI SDK tool-loop adapter contain tool calls during a runtime scan. Before a tool runs, the SDK checks the call:
- a tool whose name changes something (for example
delete_user,sendEmail,issue_refund,run_shell,write_file) returns a simulated result instead of running; - a call with a URL or email address for a host outside
allowedHostsreturns a simulated result too, so an exploit can't send data anywhere; - names that start with a read verb (
get,list,lookup,search, and similar) and calls that stay on loopback, the.invalidcanary sinks, or your allowed hosts run normally.
A contained call still appears in the trace with its arguments and contained: true, so a probe that talked the agent into a destructive action is still reported. The agent receives { status: "ok", simulated: true, tool, note } and carries on as if the call had worked.
Containment never removes a tool from the agent, because that would hide tool-hijacking vulnerabilities. The agent still sees every tool and can still call it. Only the effect is simulated.
Pass a policy to change what runs:
const target = openAI.responses({
client: openai,
request,
toolExecutors,
containment: {
allowTools: ["update_draft"], // always run for real
simulateTools: ["lookup_billing"], // always simulate
allowedHosts: ["api.internal.acme.com"], // egress allowed here
},
});The name check is a heuristic. If a tool's name hides what it does, list it in simulateTools.
| Target | Containment |
|---|---|
| OpenAI adapters, AI SDK tool-loop adapter | On by default. Pass containment: false to run every tool for real, for example against a staging environment with scan-safe dependencies. |
| Your own AI SDK agent | Wrap its tools with containTools(tools) before you construct it, and pass aiSdk({ agent, containedTools: true }) so the report shows the scan ran contained |
Custom createRuntimeTarget handler | Call runContainedTool(name, args, execute, resolveToolContainment(true)) around each tool |
Use scan-safe dependencies
Use the same agent configuration and tool-control logic as production. With containment off, or for tools you list in allowTools, inject scan-safe dependencies whenever a tool can cause irreversible effects:
- point database tools at an ephemeral database;
- use test tenants and credentials;
- route email, messaging, payments, and webhooks to sinks;
- preserve authorization and approval code paths;
- record intended side effects even when the final external action is intercepted;
- clean up state between scan runs.
Payload containment
Before any probe reaches your agent, ZeroLeaks rewrites real external destinations in the payload (URLs, email addresses, and reverse-shell targets) to a canary sink on the reserved .invalid domain, canary.zeroleaks.invalid. If an exploit works and your agent calls a tool with the attacker's destination, the request goes to a host that cannot resolve, and the tool call is still recorded as evidence. The containment field on agent reports counts how many payloads were rewritten.
Loopback and cloud-metadata addresses (localhost, 127.0.0.1, 169.254.x.x) are left in place, because an SSRF probe against them tests your own infrastructure.
For endpoint scans, tools run behind your endpoint, out of ZeroLeaks' reach. Payload containment keeps attacker destinations on the canary sink, but a tool that writes to your own systems will write. Point endpoint scans at a staging deployment, contain tools behind your endpoint, or use a runtime scan to get tool containment.