SIRT Triage Agent Workshop
~15 min

Sandbox SDK -- let an agent run a CLI process

Give the Network sub-agent a Sandbox to run real CLI enrichment commands like dig and whois, with the command and output surfaced in the UI.

Steps0 / 4
~15 min
  1. Navigate to the lesson-13-sandbox directory

    Run `cd ..\lesson-13-sandbox` from your current lesson directory.

  2. Replace REPLACE_WITH_YOUR_DATABASE_ID in wrangler.jsonc

    Open `wrangler.jsonc` and replace `REPLACE_WITH_YOUR_DATABASE_ID` with your D1 database_id from lesson 06.

  3. Redeploy the app

    Run `npm run deploy`.

  4. See the Sandbox CLI-enrichment panel

    Investigate the Malware incident. During triage, the Network Analyzer lane shows a Sandbox CLI-enrichment panel with `dig`/`whois` commands and their output.

OpenCode shortcut

Paste this prompt into the OpenCode TUI to let your AI agent walk you through this lesson:

 

Step 0: Navigate to the lesson directory

Open your terminal and navigate to the lesson-13-sandbox directory:

cd ..\lesson-13-sandbox

This directory’s wrangler.jsonc already sets STATE to state-6-sandbox, which turns on the Sandbox CLI-enrichment panel in the analyst console. The panel is a faithful simulation in this workshop build, so you can complete the lesson on any account without Containers access.

Why CLI enrichment matters

In lessons 11-12, the Network Analyzer assessed destination reputation and infrastructure signals — but it was working entirely from what the LLM already knows. Ask a model “is 203.0.113.88 a known-bad IP?” and you’ll get a plausible-sounding answer that may be completely fabricated. The model has no live view of DNS records, WHOIS registrations, or current infrastructure.

Real security triage needs ground truth. A dig command returns actual DNS records. A whois lookup returns the real registrant, registration date, and hosting provider. These are facts, not inferences — and they dramatically change the quality of the network analysis.

The Sandbox SDK lets you run arbitrary CLI commands inside an isolated, ephemeral container on Cloudflare’s network. The sandbox starts on demand, executes the command, returns stdout/stderr, and can be destroyed immediately after. It’s designed for exactly this pattern: give an agent access to real tools without exposing your Worker’s runtime to untrusted processes.

How it works

The flow for the enhanced Network Analyzer:

Incident data ── Network Analyzer ─┬─ Create Sandbox
                                    ├─ sandbox.exec("dig example.com")
                                    ├─ sandbox.exec("whois 203.0.113.88")
                                    ├─ Capture stdout from each command
                                    ├─ Destroy Sandbox
                                    └─ Feed real CLI output into analysis prompt

The analyzer creates a sandbox, runs one or two enrichment commands based on the incident’s network indicators, captures the output, then includes that raw output in the prompt to Workers AI. The model now has real data to analyze instead of guessing.

Step 1: Replace your database ID and redeploy

This lesson is a STATE change — the directory is already at state-6-sandbox, which switches on the Sandbox CLI-enrichment panel. No new binding is required for the workshop build.

Replace REPLACE_WITH_YOUR_DATABASE_ID in lesson-13-sandbox\wrangler.jsonc with your D1 database_id from lesson 06, then redeploy:

npm run deploy

Step 2: See the CLI enrichment

Open your app and investigate the Malware + C2 Beacon incident. During triage, the Network Analyzer lane now shows a Sandbox CLI enrichment panel with:

  • The commands that were run (dig +short, whois)
  • Their output (resolved IP, origin ASN, registration age, reputation)

The panel is built from the incident’s network indicators. It demonstrates the pattern: give the agent real tool output instead of asking the model to guess DNS or WHOIS facts. Compare this to the generic network analysis from lesson 11 — “WHOIS shows this IP was registered 3 days ago” is a fact, not an inference.

Wiring it live (optional, beyond the workshop)

A live integration adds the Sandbox binding to wrangler.jsonc:

"containers": [{ "class_name": "Sandbox", "image": "./Dockerfile", "instance_type": "lite", "max_instances": 1 }],
"durable_objects": { "bindings": [{ "class_name": "Sandbox", "name": "SANDBOX" }] },
"migrations": [{ "new_sqlite_classes": ["Sandbox"], "tag": "v2" }]

re-exports the Sandbox class from the Worker entry (export { Sandbox } from '@cloudflare/sandbox'), and calls it from the Network Analyzer:

import { getSandbox } from "@cloudflare/sandbox";

const sandbox = getSandbox(env.SANDBOX, `network-${incident.id}`);
const digResult = await sandbox.exec(`dig ${domain} +short`);
const whoisResult = await sandbox.exec(`whois ${ip}`);
await sandbox.destroy();

The raw stdout then feeds the analysis prompt — real DNS/WHOIS data instead of guesses. Each sandbox runs in its own ephemeral container with no access to your Worker’s bindings or secrets — the container is the trust boundary.

What comes next

In lesson 14, the Response Agent gains a similar execution capability — but instead of running existing CLI tools, it will generate and execute custom Worker code using Dynamic Workers. The agent writes a purpose-built IOC scoring function, deploys it on the fly, runs it, and returns the result — all within the triage flow.

Key takeaways

Before moving on, make sure these ideas land. They are the reason this lesson matters in the larger triage system.

  1. 1

    Tool output gives the model ground truth

    An LLM may sound confident about DNS or WHOIS data it does not actually know. Running real CLI commands provides facts the Network Analyzer can reason from.

  2. 2

    Sandbox SDK isolates arbitrary command execution

    Commands run in an ephemeral container without access to the Worker's bindings or secrets. The sandbox is the trust boundary for tool-augmented agents.

  3. 3

    Evidence-backed analysis beats plausible analysis

    Combining model reasoning with live command output makes the triage result more defensible. The UI can show both the command and the evidence behind the conclusion.

Knowledge checkRequired to continue