Traffic agent
The traffic agent (ctfgarden-traffic-agent) captures the network traffic of challenge instances and the ingress, stores it as pcap files and analyzes it for cheat detection. It's optional: without it, the platform works normally, but the traffic based detectors (AI provider IPs and user agents in instance traffic, access to other teams' instances, TLS fingerprints, canaries and solve_without_traffic) don't record anything.
The agent runs as a DaemonSet, so there's one agent per node. It's built from the Dockerfile in the repository (target traffic-agent).
How it works
- The agent opens an
AF_PACKETsocket (the mechanism libpcap uses) in the node's network namespace and captures packets on the pod interfaces. With Cilium, every pod has its ownlxc*interface on the node. - Every 10 seconds, it lists the challenge instance namespaces and the pods on its node from the Kubernetes API, to know which pod IP belongs to which instance, and which pods are the ingress (Traefik). It also asks the local Cilium agent which interface belongs to which pod (see attribution).
- Packets of instance pods and ingress pods on its node are written to rotating pcap files. Traffic of other pods is ignored.
- If
API_ENDPOINTandINTERNAL_API_TOKENare set, it analyzes the traffic and sends findings and client observations to the API (POST /internal/suspicion-events). Every minute, it fetches the current canary tokens fromGET /internal/canary-tokens. Without these variables, traffic is only captured.
The agent reports everything it finds for all instances. The API decides what counts, for example whether no-LLM mode applies to the actor and challenge.
Requirements
- Cilium as network plugin, or another plugin that creates one host interface per pod (set
CAPTURE_INTERFACESto its prefix). hostNetwork: true, so the agent sees the node's pod interfaces.CAP_NET_RAWto open the capture socket.NODE_NAMEset to the node's name through the downward API.- Recommended: the Cilium agent's API socket (
/var/run/cilium/cilium.sockfrom the node, read-only) for attribution by interface. - RBAC to list namespaces and pods in all namespaces.
INTERNAL_API_TOKENset on the API server to the same value as on the agent. The API's internal endpoints are disabled without it.- Traefik pods must not use
hostNetwork. Pods in the host network share the node's IP address, so the agent can't attribute their traffic. - To see the real client IP in TLS connections, the client's address must reach the Traefik pod unchanged, for example with
externalTrafficPolicy: Localon itsLoadBalancerservice.
Deployment
This example deploys the agent into the ctf-platform namespace and stores the pcap files on each node under /var/lib/ctfgarden/pcaps. Replace the image with the one you built or pulled.
apiVersion: v1
kind: ServiceAccount
metadata:
name: traffic-agent
namespace: ctf-platform
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: ctfgarden-traffic-agent
rules:
- apiGroups: [""]
resources: ["namespaces", "pods"]
verbs: ["list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: ctfgarden-traffic-agent
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: ctfgarden-traffic-agent
subjects:
- kind: ServiceAccount
name: traffic-agent
namespace: ctf-platform
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: traffic-agent
namespace: ctf-platform
spec:
selector:
matchLabels:
app: traffic-agent
template:
metadata:
labels:
app: traffic-agent
spec:
serviceAccountName: traffic-agent
hostNetwork: true
# Needed to resolve cluster DNS names (API_ENDPOINT) in the host network
dnsPolicy: ClusterFirstWithHostNet
# Give the agent time to close its pcap files
terminationGracePeriodSeconds: 30
containers:
- name: agent
image: registry.example.com/ctfgarden/traffic-agent:latest
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: API_ENDPOINT
value: http://api.ctf-platform.svc.cluster.local:3000
- name: INTERNAL_API_TOKEN
valueFrom:
secretKeyRef:
name: ctfgarden-internal
key: token
securityContext:
capabilities:
drop: ["ALL"]
add: ["NET_RAW"]
volumeMounts:
- name: pcaps
mountPath: /data/pcaps
# Cilium's API socket, for attribution by interface
- name: cilium-run
mountPath: /var/run/cilium
readOnly: true
resources:
requests:
cpu: 100m
# The capture ring (256 MiB by default) comes on top, see "Capture"
memory: 128Mi
volumes:
- name: pcaps
hostPath:
path: /var/lib/ctfgarden/pcaps
type: DirectoryOrCreate
- name: cilium-run
hostPath:
path: /var/run/cilium
type: DirectoryThe Helm chart deploys the agent like this with trafficAgent.enabled: true.
The agent must run on every node that runs challenge instances or Traefik. If these nodes have taints, add matching tolerations.
Configuration
Every option can be set as an environment variable or as a command line flag.
| Variable | Flag | Default | Description |
|---|---|---|---|
NODE_NAME | --node-name | Required. Name of the node the agent runs on | |
PCAP_DIR | --output-dir | /data/pcaps | Directory to store the pcap files in |
CAPTURE_INTERFACES | --interfaces | lxc | Comma-separated prefixes of the interfaces to capture on |
SNAPLEN | --snaplen | 65535 | Maximum number of bytes stored per packet |
CAPTURE_MODE | --capture-mode | ring | How packets are received: ring or socket, see capture |
RING_BLOCK_SIZE | --ring-block-size | 4194304 (4 MiB) | Size of a ring block in bytes. Must be a multiple of the page size |
RING_BLOCK_COUNT | --ring-block-count | 64 | Number of ring blocks |
RING_RETIRE_TIMEOUT_MS | --ring-retire-timeout-ms | 100 | Hand a ring block to the agent at the latest this many milliseconds after its first packet |
KERNEL_FILTER | --kernel-filter | exclude | Filter interfaces in the kernel: exclude, include or off, see filtering |
INTERFACE_REFRESH_SECONDS | --interface-refresh-seconds | 2 | How often to list the interfaces and update the kernel filter |
ROTATE_SECONDS | --rotate-seconds | 300 | Start a new pcap file after this many seconds |
ROTATE_BYTES | --rotate-bytes | 104857600 (100 MiB) | Start a new pcap file after this many bytes |
INGRESS_SELECTOR | --ingress-selector | app.kubernetes.io/name=traefik | Label selector of the ingress pods (key=value, comma-separated) |
API_ENDPOINT | --api-endpoint | Base URL of the API server. If unset, traffic is only captured, not analyzed | |
INTERNAL_API_TOKEN | --token | Same value as INTERNAL_API_TOKEN on the API server | |
AI_IP_RANGES_FILE | --custom-ranges | Additional AI provider IP ranges | |
NO_OPENAI_DOWNLOAD | --no-openai-download | false | Set to true (or 1, yes, on) to not download OpenAI's IP ranges |
CILIUM_SOCKET | --cilium-socket | /var/run/cilium/cilium.sock | The Cilium agent's API socket, for attribution by interface |
NO_CILIUM | --no-cilium | false | Don't use Cilium's API, attribute packets by IP address only |
PCAP_RETENTION_DAYS | --pcap-retention-days | Delete pcap files older than this many days. Kept forever if unset | |
CANARY_REFRESH_SECONDS | --canary-refresh-seconds | 60 | How often to fetch the canary tokens from the API |
Capture
The agent receives packets in one of two ways (CAPTURE_MODE):
ring(default): aTPACKET_V3ring buffer that's shared with the kernel. The kernel fills the ring's blocks with packets and hands a block to the agent when it's full, orRING_RETIRE_TIMEOUT_MSafter its first packet. There's no system call per packet, and the kernel timestamps the packets when they arrive.socket: onerecvfromsystem call per packet, with a 64 MiB receive buffer. Timestamps are taken when the agent reads the packet. If the ring can't be set up (for example on kernels older than 3.2, or if the kernel can't allocate it), the agent logs why and uses this mode.
Memory
The ring takes RING_BLOCK_SIZE × RING_BLOCK_COUNT bytes, 256 MiB with the defaults. It's allocated by the kernel when the agent starts and stays allocated while it runs, so plan for it in the node's memory. It's kernel memory, so it usually isn't counted against the container's memory limit, but it shows up in the agent's resident memory.
The ring is the buffer for bursts and for slow disks: packets are only dropped when all blocks are full. At 1 Gbit/s, 256 MiB holds about 2 seconds of traffic. A single packet must fit into one block, so RING_BLOCK_SIZE must be larger than SNAPLEN (larger packets are truncated). Smaller blocks with a short retire timeout reduce the delay before packets are analyzed, larger blocks reduce the overhead.
Filtering
Only the interfaces whose names start with one of the CAPTURE_INTERFACES prefixes are captured. To keep the kernel from copying the traffic of other interfaces to the agent at all, the agent attaches a BPF filter to its socket that checks the interface of every packet. Interfaces come and go with pods, so the agent lists the interfaces every INTERFACE_REFRESH_SECONDS and replaces the filter when they change. In ring mode, the filter also truncates packets to SNAPLEN in the kernel.
KERNEL_FILTER | Description |
|---|---|
exclude | Drop the packets of the known interfaces that don't match, accept all others. The interfaces of new pods are captured from their first packet |
include | Only accept the packets of the known matching interfaces. The first packets of a new pod are missed until the next refresh |
off | No filter in the kernel, every packet is copied to the agent and filtered there |
The kernel limits filters to 4096 instructions, which is enough for about 2000 interfaces. If there are more, the agent logs a warning and filters in the agent instead. The agent checks the interface names of all packets in any case.
Stats file
Every 5 seconds, the agent reads the kernel's counters and logs a warning if packets were dropped because it didn't keep up. It writes the counters to <PCAP_DIR>/agent-stats/<node>.json, so you can tell whether a node's captures are complete:
{
"node": "node-1",
"since": "2026-11-13T10:00:00.000Z",
"updated_at": "2026-11-13T10:05:00.000Z",
"capture_mode": "ring",
"fallback_reason": null,
"ring": { "block_size": 4194304, "block_count": 64, "retire_timeout_ms": 100, "memory_bytes": 268435456 },
"filter_mode": "kernel",
"kernel_filter": "exclude",
"interface_prefixes": ["lxc"],
"interfaces": ["lxc12ab34cd", "lxc56ef78ab"],
"snaplen": 65535,
"packets_received": 1532000,
"packets_dropped": 0,
"freeze_queue_count": 0,
"packets_captured": 1532000,
"packets_filtered_userspace": 0,
"last_drop_at": null
}| Field | Description |
|---|---|
since | When the agent started. The counters cover the time since then. Traffic before that, for example while the agent restarted, wasn't captured |
updated_at | When the counters were last read |
capture_mode | ring or socket. If ring was configured but couldn't be set up, fallback_reason says why |
ring | The ring's configuration and size, null in socket mode |
filter_mode | kernel if the BPF filter drops other interfaces, userspace if every packet is copied to the agent (KERNEL_FILTER=off, or too many interfaces) |
interfaces | The matching interfaces at the last refresh |
packets_received | Packets the kernel passed to the agent after the BPF filter, including dropped ones |
packets_dropped | Packets the kernel dropped because the ring or receive buffer was full. If it's not 0, captures since since may be incomplete |
freeze_queue_count | How often the ring was completely full (ring mode only) |
last_drop_at | When the last drop was counted (with a precision of 5 seconds) |
packets_captured | Packets of matching interfaces that were processed |
packets_filtered_userspace | Packets of other interfaces that reached the agent and were dropped there |
Attribution
Every stored packet has to be assigned to a challenge instance (or the ingress). There are two ways:
- By interface (with Cilium). The agent asks the local Cilium agent (
GET /v1/endpointonCILIUM_SOCKET) for the interface of every pod on the node, and matches the pods' IP addresses with the instances. A packet then belongs to the pod whose interface it was captured on. This is exact, and every packet is stored exactly once: a packet between two pods on the same node is seen on both interfaces, but each interface only stores it for its own pod. - By IP address (fallback). If Cilium's API isn't available (or
NO_CILIUMis set), or for an interface Cilium doesn't know yet (a pod that started in the last 10 seconds), packets are assigned to the owners of their source and destination IP addresses. Identical packets within 100 ms are stored only once per stream, because a packet between two local pods is captured twice.
The agent logs which mode it uses when it starts, and when Cilium's API becomes unavailable.
Real clients of TCP services
For TCP services (exposed with an IngressRouteTCP), Traefik terminates TLS and opens its own connection to the instance, so the instance's pcap only shows Traefik's address. The agent on Traefik's node sees both connections and pairs them:
- A client sends a TLS ClientHello to Traefik. The SNI names the instance.
- Within 5 seconds, Traefik opens a connection (SYN) to a pod of that instance. It is paired with the oldest unpaired ClientHello for the same instance and Traefik pod. ClientHellos that don't offer an HTTP ALPN (
h2,http/1.1) are preferred, because netcat-style TLS clients don't send one and browsers do. - If the first data on the connection is an HTTP request, it's dropped: Traefik reuses its connections for HTTP routes, and HTTP requests carry the client IP in
X-Real-Ipanyway. Otherwise the pairing is reported to the API.
The API stores each pairing with the client's address, the SNI and JA4 fingerprint, and the source address and port of Traefik's connection, as it appears in the instance's pcap. To find out which client a connection in a pcap belongs to, look up Traefik's source port in the instance's connections: Connections next to the instance on Administration → Instances (running instances), or the Connections tab of a team on Administration → Cheat Detection (all of the team's instances, including stopped ones).
A pairing is marked ambiguous if several clients were waiting for a connection to the same instance at the same time. Then the order of connections decides, which is usually right, but not guaranteed. This needs the agent on the node of every Traefik pod. Instances can be on any node, so the agent watches instance pods cluster-wide.
SSH services don't go through Traefik. The SSH gateway reports logins itself, with the client's IP address and SSH client version.
Pcap files
Packets are stored in one stream per challenge instance and one stream for the ingress pods of each node:
<PCAP_DIR>/instances/<challenge>/<actor>/<instance>/<start>-<sequence>-<node>.pcap
<PCAP_DIR>/instances/<challenge>/<actor>/<instance>/<start>-<sequence>-<node>.pcap.json
<PCAP_DIR>/ingress/<node>/<start>-<sequence>.pcap
<PCAP_DIR>/ingress/<node>/<start>-<sequence>.pcap.json<start> is the time the file was opened, for example 20261113T100000.000Z, and <sequence> is a counter that keeps file names unique. A packet between the ingress and an instance on the same node is stored in both streams.
A file is closed after ROTATE_SECONDS, after ROTATE_BYTES, after 60 seconds without packets, and when the agent stops. Packets are stored with the LINUX_SLL2 link type, so they can be opened with Wireshark or tcpdump.
Each pcap file has a JSON index file next to it, which is updated every 5 seconds while the file is written:
{
"stream": "instance",
"challenge_id": "web-login",
"actor": "team-gardeners",
"instance_id": "0123456789ab",
"node": "node-1",
"file": "instances/web-login/team-gardeners/0123456789ab/20261113T100000.000Z-000001-node-1.pcap",
"link_type": "LINUX_SLL2",
"started_at": "2026-11-13T10:00:00.000Z",
"ended_at": null,
"complete": false,
"packets": 1532,
"bytes": 845012
}| Field | Description |
|---|---|
stream | instance or ingress |
challenge_id, actor, instance_id | The instance, null for the ingress |
node | The node the file was captured on |
file | Path of the pcap file, relative to PCAP_DIR |
started_at, ended_at | When the file was opened and closed |
complete | false while the file is still being written |
packets, bytes | Number of packets and bytes written so far |
Retention
Pcap files can get large and contain personal data (see data protection). Set PCAP_RETENTION_DAYS to let the agent delete files (and their index files) older than that. It checks once per hour. Without it, files are kept forever.
The ingress stream only contains Traefik's traffic with clients on the internet, which is TLS-encrypted. The plaintext requests Traefik forwards to the platform itself (logins, session tokens) are not stored, and its traffic to challenge instances is stored with the instance.
Packets are stored once per stream, see attribution.
WARNING
Instance pcaps contain the plaintext traffic players send to their instances, which may include personal data. Restrict access to the pcap directory accordingly.
What's analyzed
Only TCP is analyzed. Two kinds of packets are looked at:
Plaintext traffic from the ingress to an instance. Traefik terminates TLS, so this traffic is unencrypted.
- For HTTP/1.x requests, the user agent and the client IP from
X-Real-Ip(or the last entry ofX-Forwarded-For), which Traefik sets, are checked against the AI provider IP ranges and classified as AI agent, automation tool, browser, common tool or unknown. The client IP and user agent are reported as a client observation. - Every payload, HTTP or not, is searched for the canary tokens of other actors.
Traffic between the pods of an instance (for example an admin bot with a headless browser) and responses from the instance are not analyzed.
TLS ClientHellos from clients to the ingress. The SNI identifies the instance (services are exposed as <service>-<port>-<challenge>-<instance>.<domain>), and the source address is the client. This also covers TCP services. The client IP is checked against the AI provider ranges and reported with the JA4 fingerprint of the ClientHello. ClientHellos that span several TCP segments are reassembled.
Client observations are what the API uses to detect access to other actors' instances (by comparing them with the IP addresses players log in from) and rare TLS fingerprints. Every observation also counts as traffic to the instance for solve_without_traffic.
Limitations
- Local agents can't be caught by IP. LLM agents running on a player's own machine use the player's IP address and can send any user agent.
- Canaries are only found verbatim. Each TCP segment is searched on its own, so a token split across two segments is missed. Encoded tokens (percent-encoding, base64, compressed bodies, HTTP/2 header compression) are missed too.
- Only the first segment of an HTTP request is parsed for its headers, and only HTTP/1.x.
- Source IP addresses behind a load balancer. If a load balancer or
kube-proxyreplaces the client's address (SNAT), the ClientHello source address is the load balancer's or the node's. Private addresses are ignored for IP-based detection, but the IP checks of TLS connections don't work then. - TLS fingerprint rarity needs a population. It's only evaluated once
rare_fingerprint_min_populationactors have been seen (see theanticheatconfiguration). - Packets can be dropped if the agent can't keep up for longer than the ring (or receive buffer) lasts, for example because the disk is too slow. Drops are logged and counted in the stats file, but the pcap files don't show where packets are missing. Traffic while the agent isn't running (restarts, updates) isn't captured either.
- Findings are delayed by a few seconds. While the API is unreachable, the agent keeps up to 10,000 findings, 10,000 client observations and 10,000 connection pairings and retries, anything beyond that is dropped.
- Connection pairing is based on timing. If several clients connect to the same instance at once, pairings can be swapped (they're marked as ambiguous). ClientHellos that are split across segments and only completed by the timeout aren't paired.