By Sebastian Maniak
The first finding this project produced was about my own sandbox, and it was wrong.
I had a pentest agent running in a gVisor sandbox with default-deny egress. HTTP to the outside world came back blocked, which was what I expected. Raw TCP did not. Every connect_ex from inside the sandbox returned 0. I wrote it up as a possible enforcement gap: HTTP filtered, raw TCP getting out.
Then I pointed the same connect at 240.0.0.1 and 192.0.2.1. Nothing on earth answers on those addresses. Both returned 0 anyway. The packets never left. The sandbox’s own network stack was accepting the connection locally and handing it to the egress layer, which denied it one step later.
So my “bypass” was a false positive, written with confidence, from a measurement that really did return success. That is exactly the mistake I want a pentest agent to never make. It’s also the reason this project exists.
This post is the whole build: a team of pentest agents on kagent 1.0.1 and Agent Substrate, in kind on my Mac, talking to a model on my DGX Spark. The roles come from ARTEX, and so does the rule I hold them to: prove what is exploitable, and don’t report anything you can’t show a transcript for. Everything is in sebbycorp/kagent-pentest-agents.
Everything below runs against a lab I own, with a written scope. Don’t point these agents at anything you’re not explicitly allowed to test. The agents are built to refuse an unscoped engagement. Don’t make them the only thing standing between you and a bad day.
What I built
ARTEX is a Go and Next.js platform with eight LLM roles sitting on top of two graphs. One graph is the assets: companies, hosts, what’s in scope. The other is the exploration: hypotheses, what was tried, what’s covered. The roles port to kagent cleanly. The graphs don’t, and I’ll come back to that.
Here’s the shape on kagent:
The operator talks to one agent, chief-of-pentesting. The chief has no execution tools. It delegates to specialists and judges what comes back. Every command that touches a network is run by exactly one named specialist, so every artifact traces back to one role. Between the sandbox and the target sits an EgressPolicy. That policy, not the prompt, decides what the agents can reach.
| ARTEX role | kagent template | What it’s held to |
|---|---|---|
| 1 Goal Decomposer | pentest-goal-decomposer | Refuses to invent scope |
| 2 Planner | pentest-planner | Keeps the exploration graph as prompt state |
| 3 Main / operator | pentest-chief → Agent/chief-of-pentesting | Never runs tools |
| 4 Worker | pentest-worker | One action, raw output, no interpretation |
| 6 Penetration Testing | pentest-executor | Proof, or it’s a lead |
| 7 Report writer | pentest-report-writer | Reports coverage gaps |
| 8 Vulnerability Retest | pentest-retester | FIXED, NOT FIXED, or INCONCLUSIVE |
| Asset-graph side | pentest-recon-chief | Read-only, owns the inventory |
The cluster
The lab is kind v0.33.0 on Docker Desktop, arm64, kagent 1.0.1 from Helm. The sandbox class is gVisor. gVisor needs no KVM, and that’s what makes this run on a Mac at all. The microVM path doesn’t.
kind create cluster --name pentest --config kind/kind-pentest.yaml
kubectl config use-context kind-pentest
helm upgrade --install kagent oci://ghcr.io/kagent-dev/kagent/helm/kagent \
--version 1.0.1 -n kagent --create-namespace \
-f values/kagent.yaml --set-file providers.openAI.apiKey=/path/to/keyfile
The API key goes in with --set-file. It’s not in the values file, and it’s not in the repo.
The model needs a name, not an address
The model is qwen3.8-flash-next behind an OpenAI-compatible gateway on my DGX Spark, at 172.16.10.240:4000. My first values file used that IP for baseUrl. Every Agent went to Compatible=False.
Substrate’s egress layer rejects IP literals:
invalid egress origin ...: expected a DNS name or leftmost-label wildcard
That rule covers the model endpoint too, because the model is just another place the Actor has to reach. The fix is a Service with no selector plus an Endpoints object. Together they give a LAN box a cluster DNS name:
apiVersion: v1
kind: Service
metadata:
name: dgx-spark
namespace: kagent
spec:
type: ClusterIP
ports:
- name: http
port: 4000
targetPort: 4000
---
apiVersion: v1
kind: Endpoints
metadata:
name: dgx-spark
namespace: kagent
subsets:
- addresses:
- ip: 172.16.10.240
ports:
- name: http
port: 4000
Then the provider points at the name:
providers:
openAI:
enabled: true
baseUrl: http://dgx-spark.kagent.svc.cluster.local:4000/v1
apiFormat: chatCompletions
model: qwen3.8-flash-next
The same values file sets config.sandboxes.guestImage, pinned by digest. Without it, sandbox preparation fails.
Two places a command can run
A pentest agent needs tools: nmap, curl, dig, python. kagent gives you two places to put them, and they aren’t the same machine.
The Harness is how an agent runs. I build my own runtime image from the kagent 1.0.1 ADK image, pinned by digest so the runtime stays in step with the controller, and add the tools with apk:
FROM ghcr.io/kagent-dev/kagent/golang-adk@sha256:d3b1151d39c5...
USER root
RUN apk add --no-cache nmap curl wget python3 jq bind-tools socat \
netcat-openbsd tcpdump iproute2 procps ripgrep git
USER 65532:65532
Forget that last USER line and the agent crash-loops. The ADK registers bash, read_file, write_file, edit_file, list_files and grep_file for the root agent and for every subagent. So every role gets a real shell, inside gVisor, with nmap already on it.
apiVersion: api.kagent.dev/v1alpha3
kind: Harness
metadata:
name: pentest-runtime
namespace: kagent
spec:
kagent: {}
workload:
image: pentest-registry:5000/pentest-adk@sha256:dfd3b8d7ee1a...
substrate:
workerPoolRef:
name: kagent-default
snapshotPolicy:
location: s3://ate-snapshots/kagent/
The SandboxTemplate is a separate box with its own lifecycle. You drive it with kagent sandbox create and kagent sandbox exec, and it’s gone when its TTL runs out, roughly an hour here.
kagent sandbox create pentest-tools --name recon-01 -n kagent
kagent sandbox exec <ID> -n kagent -- nmap --version
The difference matters more than I expected. The agent’s own bash runs as uid 65532 in the runtime that holds the model credential and talks to the control plane. The sandbox runs as root in a box that holds neither. “The agent ran a command” is ambiguous until you say which one. A pentest harness should record which machine produced every artifact.
If you want tool execution quarantined from the process that holds the credentials, don’t lean on built-in bash. Route the risky tools through a SandboxTemplate, and keep the agent’s own shell for file work.
Four image traps
These cost me the most time:
Harness.spec.workload.imageonly takesrepo@sha256:<64 hex>. Tags are rejected by the CRD.- The node agent,
atelet, only pulls over HTTPS. A local registry needs a CA, a Secret inate-system, a mount into theateletDaemonSet, andSSL_CERT_FILE. - Pin the manifest-list digest from the push output, not a child manifest. The child digest gives
mismatched image rootfs and manifest layers, which shows up asGoldenActorCrashed. It looks like a broken image. It’s a wrong digest. config.sandboxes.guestImagehas to be set and digest-pinned, as above.
tools/build-images.sh in the repo builds both images and tells you which digest to paste.
The org has to be a star
My first design was a tree. The chief would hand recon to a recon chief, and the recon chief would hand single commands to a worker. kagent rejected it:
Compatible=False reason=UnsupportedConfiguration
msg=consecutive Shared AgentTemplate tools exceed the kagent runtime boundary
I first wrote that down as “more than six subagents is rejected.” That was wrong too. My first failing case happened to be nested. So I changed one thing at a time:
| Shape | Result |
|---|---|
| 7 flat subagents | Compatible=True |
| 8 flat subagents | Compatible=True |
| 5 flat, one of which binds its own subagent | Compatible=False |
| Exactly 1 subagent, which binds its own | Compatible=False |
The last row is the one that settles it. One subagent can’t be too many. It’s depth, not count.
Shared subagent bindings compile into the parent’s single runtime. A specialist can’t delegate further. So every specialist is a leaf, and each one uses its own sandboxed bash instead of calling a worker. If you really need a middle manager, it has to be a separate Agent reached over A2A.
Here’s how the chief binds its specialists. Each one is a subAgent with a name, a description the chief routes on, and a templateRef:
apiVersion: api.kagent.dev/v1alpha3
kind: AgentTemplate
metadata:
name: pentest-chief
namespace: kagent
spec:
modelConfig:
name: default-model-config
systemPrompt: |
You are the Chief of Pentesting. You never run tools yourself. You delegate
and you judge.
1. Send the engagement request to goal-decomposer. Do not proceed until scope
is explicit. No target list means no testing.
2. Send the agreed scope to recon-chief to build the asset inventory.
3. Get intents from planner, then assign each intent one at a time to worker
or executor. One concrete action per assignment.
4. Judge the evidence yourself before it becomes a finding:
- Is the command recorded verbatim?
- Does the output demonstrate the impact claimed, or merely suggest it?
- Is the target inside the agreed scope?
Anything failing those three goes back, not forward.
5. Send accepted evidence to vuln-writer, one finding at a time.
6. Send the finding records to report-writer.
7. Use retester when a fix is claimed remediated.
You are accountable for false positives.
tools:
- subAgent:
name: goal-decomposer
description: "Turns an engagement request into a scoped, falsifiable goal set."
templateRef:
name: pentest-goal-decomposer
- subAgent:
name: executor
description: "Proof-driven exploitation; establishes exploitability with reproducible evidence."
templateRef:
name: pentest-executor
# ...recon-chief, planner, worker, vuln-writer, report-writer, retester
---
apiVersion: api.kagent.dev/v1alpha3
kind: Agent
metadata:
name: chief-of-pentesting
namespace: kagent
spec:
harnessRef:
name: pentest-runtime
template:
ref:
name: pentest-chief
The executor’s prompt is where the standard lives:
A finding is only reported when you can reproduce it. For every finding:
1. State the prerequisite.
2. Show the exact request or command.
3. Show the exact response or output that demonstrates the impact.
4. Separate what you OBSERVED from what you INFER.
A scanner verdict, a version banner, or a missing header is not a finding.
It is a lead. Leads get worked or become dead ends.
Stop after first blood on a given host and report it.
If a target is not listed, do not touch it, even if it is reachable.
You can’t talk to a subagent directly
A subagent has no session of its own. It lives inside the chief’s runtime. Sometimes I want to re-run one retest or re-cut one report section without the whole chain. So four of the templates also get their own Agent: chief-of-recon, vuln-report-writer, engagement-reporter, and vuln-retester. Same templates, different front doors.
kubectl apply -f k8s/00-model-and-targets.yaml \
-f k8s/10-harness-pentest-runtime.yaml \
-f k8s/20-agents-artex-roles.yaml \
-f k8s/30-standalone-agents.yaml
kubectl get agents -n kagent -w # every Agent should reach Ready=True
The prompt is a request. Egress is the wall.
ARTEX gates tool calls in code, in its guard/ and intercept/ packages. I went looking for the kagent equivalent and found requireApproval: true. It’s real, and I use it in my FortiGate agent. But it belongs to an MCP tool group. Built-in bash doesn’t have one.
So for these agents there’s no approval step between the model deciding to run a command and the command running. What constrains them is the EgressPolicy. The prompts are defense in depth on top of that. If you get those two backwards, you have an agent that will touch whatever the model decides to touch.
Egress on Substrate is default deny. A grant is an EgressPolicy in the agent’s namespace, selected by label, with DNS-name origins. No IP literals, same rule as the model. I walked through the policy UI in kagent has a Policies page now.
TCP connects lie
Back to the false positive from the top. This is the measurement that killed it:
connect_ex(240.0.0.1:443) = 0
connect_ex(192.0.2.1:443) = 0 # TEST-NET-1, reserved, cannot answer
connect_ex(1.1.1.1:443) = 0
connect_ex(172.16.10.80:8787) = 0
And this is where the denial actually lands:
| Layer | Without a grant | What you see |
|---|---|---|
| TCP connect | Succeeds, always | connect_ex returns 0, even for unroutable addresses |
| DNS | Fails | curl: (6) Could not resolve host, for public and cluster names |
| TLS handshake | Fails | SSLEOFError [SSL: UNEXPECTED_EOF_WHILE_READING] |
| HTTP | 403 | Body: actor egress policy denied |
The docs say unrestricted raw TCP egress isn’t supported, and they’re right. What they don’t say is that a TCP connect returns success before the denial happens.
For a pentest agent that’s a trap. An agent that reports “port open” from a connect result inside a gVisor actor is reporting a false positive, and it will keep reporting it with confidence, because the connect really did return 0. Left alone, an agent here will build a convincing asset inventory out of its own proxy saying yes.
So the worker and recon prompts say it outright. A bare connect result is not evidence about the target. Assert on the handshake or the response, never on the connect.
The first engagement: it wouldn’t start
With the cluster up, I gave the chief a deliberately tiny job. One lab host, one port.
Engagement: prove your sandbox can perform recon, under a strictly limited scope.
AUTHORISED SCOPE (exactly this, nothing else): target 172.16.10.80, TCP port 8787 only.
Tasks:
1) Confirm which recon tools exist in your runtime and their versions: nmap, dig, curl, python3.
2) Check whether 172.16.10.80:8787/TCP is reachable, and report the HTTP status line from GET /api/health.
Show the exact commands you ran and their raw output.
Here’s how I drive it from the CLI:
SID=$(kagent agent session create --agent chief-of-pentesting -n kagent -o json \
| python3 -c "import sys,json;print(json.load(sys.stdin)['session']['id'])")
kagent agent invoke --session "$SID" --file engagement.txt -n kagent --timeout 900s
Two CLI notes: the task goes in --task or --file, because positional text is an error, and session create -o json nests the id under session.
The chief didn’t run anything. It sent the request to the goal decomposer, which came back with a frozen rules-of-engagement contract and nine questions. The budget it set for itself:
Budget: at most 2 TCP connection attempts to
172.16.10.80:8787and exactly 1 HTTP request. Zero retries, zero redirects, zero parallelism, no re-runs to “get a nicer result”.
It asked whether nmap was allowed to touch the target at all, and recommended no. And it asked who had authorized this:
No client name, authoriser, contract/permission reference, or engagement ID accompanied the scope. I will not proceed on an unattributed scope — supply the authorisation reference for the report.
A generic “you are a pentester” prompt doesn’t do that. I answered the nine questions as the operator, and it ran.
$ nmap --version 2>&1 | head -n 3
Nmap version 7.99 ( https://nmap.org )
$ python3 -c 'import socket; s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);
s.settimeout(5); print(s.connect_ex(("172.16.10.80",8787))); s.close()'
0
$ curl --noproxy '*' -4 --retry 0 --max-redirs 0 --connect-timeout 5 --max-time 10 \
-i -X GET http://172.16.10.80:8787/api/health 2>&1
HTTP/1.1 403 Forbidden
content-type: text/plain
content-length: 26
actor egress policy denied
No EgressPolicy granted 172.16.10.80:8787, so that 403 came from the sandbox, not the lab service. The agent couldn’t be told that. It worked it out from the body text, the all-lowercase header names, and the missing Server: header. Then it refused to promote its own correct guess:
I saw a completed TCP handshake and a verbatim
403with that body. I guessed that the responder is the sandbox’s own enforcement layer rather than the lab service. That guess is what makes C2 INCONCLUSIVE rather than TRUE, and I have labelled it inferred so it stays a lead until something confirms it.
The rest of its report was the same:
- Tools: 3 of 4.
digis installed, butdig --versionexits 1. It didn’t trydig -v, because that wasn’t in the allowlist it had written itself. It logged a coverage gap instead. - Reachability: INCONCLUSIVE, for the reason above.
- Budget: spent. It wouldn’t probe again without a fresh authorization.
- A gap it couldn’t close. The clean way to tell “target closed” from “egress not granted” is a control request to a blackholed address. That address isn’t in scope, so it said so and stopped. That’s the same trap from the section above, found on its own.
It ended with a NOT CLAIMED section:
This proves: four binaries inventoried, one socket completed, one status line captured faithfully. It is not a security assessment, not a vulnerability finding, not a health finding for
/api/health.
That’s the behavior the whole schema is built to get. The full record is ENG-LOCAL-LAB-001.
The second engagement: it looked at itself
The second run sent no traffic at all. I asked chief-of-recon for a capability baseline: what tools it has, and what it can see from where it sits. It used PATH lookups, version banners, and local socket tables.
The tool list is short. nmap, curl, dig, python3, tcpdump, socat, OpenBSD netcat. No masscan, no ffuf, no nuclei, no sqlmap, no subdomain tooling. Enumeration here is nmap, curl and python loops. Name discovery also needs an egress grant, not just a tool, because DNS is default deny.
The interesting part was what it said about its own runtime:
pid 1
applistening on*:80and*:8081, with established sessions to10.96.31.183:8083and10.96.239.133:4000; own address169.254.17.2, resolver169.254.17.1, search domains*.kagent.svc.cluster.local— i.e. a Kubernetes-podised actor.observed, high confidence, from local/proc-equivalent state only. Those two10.96.x.xpeers are leads, not scoped targets — I touched none of them.
Those two peers are the kagent controller and the model gateway. The agent runtime is a networked asset in its own right. It holds the model credential, it talks to the control plane, and it sits on the cluster service CIDR. The agent found that and touched nothing, which is right.
It also flagged that tcpdump being installed doesn’t mean capture works: unprivileged uid, no CAP_NET_RAW, gVisor. Its words were inferred, untested, confidence low, treat as a lead. I’d take that over a confident wrong answer every time.
The record is ENG-LOCAL-LAB-002.
Reading the transcript back
Every turn is durable in Postgres, which is what you want for a pentest. The catch is that kagent.session_task_event.data is protobuf bytea, not JSON. ::text gives you \x…, and that table has no session_id. Join through kagent.session.history_id, decode the hex, and pull out long printable runs:
POD=$(kubectl get pods -n kagent -o name | grep postgres | head -1 | cut -d/ -f2)
kubectl exec -n kagent $POD -- psql -U postgres -d kagent -At \
-c "select data::text from kagent.session_task_event order by created_at desc limit 50;" \
| python3 -c "
import sys,re
for l in sys.stdin:
l=l.strip()
if l.startswith('\\\\x'):
for m in re.findall(rb'[\x20-\x7e\n]{600,}', bytes.fromhex(l[2:])):
print(m.decode('utf8','replace')[:400])
"
Message text is split across protobuf fields, so don’t expect one clean blob per message.
Opening the UI on kind
kagent-ui and kagent-controller are ClusterIP services with no NodePort, so localhost:30080 just hangs. With cloud-provider-kind running, flip them to LoadBalancer:
kubectl patch svc kagent-ui -n kagent --type merge -p '{"spec":{"type":"LoadBalancer"}}'
kubectl patch svc kagent-controller -n kagent --type merge -p '{"spec":{"type":"LoadBalancer"}}'
kubectl get svc -n kagent kagent-ui kagent-controller
Use the EXTERNAL-IP, not <node-ip>:<nodePort>, which returned nothing here. Those IPs change when the LB provider restarts, so read them from kubectl get svc each time. Without cloud-provider-kind, port-forward 8080 for the UI and 8083 for the controller.
What isn’t done
Skills crash the agents. I copied the 11 ARTEX skills into one OCI image and attached them to the templates. The image pulled. The skill mounted. Every Agent then went to Ready=False:
GoldenActorCrashed: ... wakeup probe for "kagent" never returned 200 within 30s
I ruled out permissions by checking inside a live actor: /skills is owned by uid 65532 and writable. Reverting the skills brought everything back. The next experiment is one trivial hand-written skill on one agent. If that crashes, the mechanism is the problem. If it doesn’t, the content is, and api-recon/scripts/ with its package-lock.json is the first suspect.
Two traps from that work are worth knowing. kubectl patch --type merge addresses the whole resource, not /spec. My first patch wrote skills at the top level, said ok, and did nothing. Only metadata.generation staying at 1 gave it away. And Ready=True isn’t proof either, because the old snapshot keeps serving while the new revision fails underneath.
No HTTPS egress grant has passed end to end yet. Every HTTPS attempt so far failed at the handshake or at DNS. Until one passes cleanly, I don’t build recon on it.
DNS for in-cluster names is blocked from the sandbox too. A sandbox couldn’t resolve dgx-spark.kagent.svc.cluster.local. I haven’t worked out yet whether there’s a supported grant for that.
The graphs. ARTEX’s asset graph and exploration graph, plus its traffic capture and intercept, aren’t something kagent gives you. Right now the planner keeps the exploration graph in its prompt, and evidence is a file convention under reports/. That’s the real porting work still ahead.
Gateable tools. The fix for the missing approval gate is to move the risky tools out of bash and into MCP servers, where requireApproval exists.
What I will not automate
I’ll automate the decomposition, the recon, the planning, and the write-up. I’ll let an executor run one command it can tie to an agreed objective, inside a scope a person wrote down. I won’t let an agent infer scope, escalate past the objective, or turn a banner into a finding.
These are the standing rules for every agent in the repo. They’re there because they measurably changed what came back:
- No target list, no testing. Scope is never inferred.
- A banner, a version, a missing header, or a scanner verdict is a lead, never a finding.
- Separate observed from inferred, in the artifact, always.
- Stop at first blood. Don’t escalate past the objective.
- Report what wasn’t tested as plainly as what was.
The prompt asks for all of that. The sandbox and the EgressPolicy are what enforce it. That’s the order I trust them in.
Related reading:
- sebbycorp/kagent-pentest-agents, including the measured findings in
docs/FINDINGS-egress-and-scope.md - ARTEX
- Delegate work to another agent
- How To: Install kagent locally with one command
- kagent has a Policies page now
- Give Claude Code and Pi a sandbox: kagent sandbox templates on Agent Substrate
- AI-driven, sandboxed security response for FortiGate with kagent and Agent Substrate
- How To: Build a CVE agent with kagent and Agent Substrate in a secure sandbox