Gait
Gait takes what workloads actually do, as the kernel sees it on every node, and turns it into a behavior graph you can query, plus an archive an attacker can’t quietly edit.
The problem
Most of an attack on a Kubernetes cluster looks like normal cluster activity. A container starts a shell, something reads the service account token, a process connects to the API server. Each of those happens every day for good reasons. The sequence is what gives an attack away: this container started a shell, that shell read the token, and then something in the same container connected to an address this workload has never talked to before.
The usual tools each see a piece of that. Image scanners and admission policies check what you deploy and stop looking once it’s running. Rule-based runtime tools judge one event at a time, so a chain of normal-looking steps passes every rule. Application logs come from the process the attacker now controls.
I wanted three things: data from somewhere the attacker doesn’t control (the kernel), the relationships between events, and a sense of what’s normal for each workload. That’s where the name comes from. You can recognize someone by how they move, even when they lie about who they are.
Constraints
- I designed it for production scale (many clusters with hundreds of nodes each), even though one person is building it.
- Collection has to run on every node, because Tetragon’s gRPC API is only exposed on a node-local Unix socket. Whatever the agent costs gets multiplied by the size of the fleet, and it sits next to a privileged socket, so it has to stay small. That’s why I wrote it in Rust.
- Nodes never write to the graph. Memgraph is in-memory and can’t absorb writes from hundreds of agents.
- The evidence is stored outside the cluster being watched. Someone who takes over the cluster shouldn’t also get the record of what they did there.
- Delivery is at-least-once, so every consumer has to be idempotent.
Approach
So far I’ve built collection and the graph. Detection only has interfaces for now. A detector is only as good as its data, and I wanted to know the data was right before I measured anything built on it.
The agent is a Rust DaemonSet that reads Tetragon’s event stream: process executions, file opens, network connections, and capability and privilege changes. It finds kprobe arguments by their label instead of their position. Kubernetes identity is attached after capture and never affects what gets captured.
The agent folds events into 5-second windows aligned to the epoch. Window ids are deterministic, so sending a window twice does no harm. Each window is numbered and sealed with a chained digest, which lets you tell a node whose collection was cut off from one that simply had nothing to report.
Under load, each event class has its own reserved budget and there’s a two-lane queue, so a flood of file opens can’t crowd out the one mount that matters. Secrets in command lines are redacted. An ordered spool on disk covers broker outages. Every dropped event is counted, and the counts travel with the data.
The agent publishes outbound to Redpanda, which runs outside the observed cluster. Observed clusters only ever make outbound connections, and cluster_id has been part of every key from day one.
The graph writer applies each window exactly once, whatever order windows arrive in. A window is identified by (node, boot_id, window_seq), and writes use MERGE, so applying the same window again changes nothing. Edges carry count, first_seen and last_seen, so the graph’s size follows the number of distinct relationships instead of the number of events. That also means “new for this workload” can be read straight off first_seen. The graph keeps seven days of data.
Every batch the agent sends is also written to Parquet in object storage. Offsets are only committed after a durable write, and object names are chosen so a replay overwrites its earlier copy and never duplicates it. Write-once storage is what makes the archive usable as evidence.
Partway through I wrote a threat model against Gait itself, with five levels of attacker access, twenty risks and sixteen decisions in response. Signed seals, per-node identity and a verifier stage came out of it, all still as designs.
Outcome
Collection, transport, the graph writer and the archive are built and have unit tests. The agent is tested against a mock Tetragon that speaks the real gRPC protocol. gait-replay runs the real pipeline and reports drops, latency and memory at each event rate.
I ran it on the laptop in a deliberate worst case, where every event is a new key and nothing aggregates. Up to 10,000 events per second, the agent dropped nothing. At 50,000 per second the agent hit its cap on distinct keys and memory stayed bounded. The same run showed that a flood could push out important events, which is why the reserved budgets exist. That flood is now a permanent test.
Several things aren’t done yet. The agent has never seen real Tetragon output. I haven’t measured CPU and memory on Linux. The Docker-backed integration tests are written but have never run. Identity, signing and the verifier exist only as designs. Nearly all of that is waiting on a dev cluster.
Detection is designed but not built. The design has five correlated layers: rules, novelty compared with the workload and its peers, behavior profiles, an Isolation Forest, and optionally a temporal GNN. An evaluation plan compares each layer at a fixed false-positive budget.