Self-Hosted eBPF Container Escape Detection: A Practical Guide to Falco and Tetragon for Runtime Threat Hunting
Quick Summary (TL;DR) Container escapes exploit kernel-level primitives—
setns,mount,ptrace,unshare—that userspace agents often miss. Deploy Falco (eBPF driver) for detection rules and Tetragon for process ancestry and optional enforcement. Correlate on container ID + PID, tune rules against a baseline, and wire alerts into your SIEM. Requires Linux kernel 5.8+, Helm 3, and ~2 CPU / 4GB RAM per node for the agents.
Container escapes rarely look like a single dramatic event. More often, an attacker who lands inside a pod quietly probes the boundary—mounting a host path, calling setns into PID 1’s namespace, or abusing a mounted Docker socket—and pivots to the node. Traditional host-based agents see the syscall but not the container context; container scanners see the image but not the runtime. eBPF closes that gap by capturing kernel events with container metadata attached, at near-zero overhead.
This guide walks you through a production-ready, self-hosted deployment of Falco and Tetragon on Kubernetes, then shows how to correlate their signals into a coherent threat-hunting workflow.
Introduction: Why eBPF for Container Escape Detection?
eBPF programs run inside the kernel via a verified sandbox, hooking into syscalls, tracepoints, and kprobes. For security teams, this means three advantages over userspace agents:
- Tamper resistance. A userspace agent can be killed or
ptrace-hijacked; eBPF probes attached to kernel functions continue reporting. - Context richness. Events carry PID, UID, container ID, namespace, and cgroup data—exactly what you need to distinguish a legitimate
mountinside a build pod from a malicious one. - Low overhead. No full syscall interception via
LD_PRELOADorptrace; the kernel runs the probe and only emits matching events.
The tradeoff: eBPF requires modern kernels (5.8+ for full feature parity, 5.4+ for basic ring-buffer support) and careful rule tuning to avoid alert fatigue.
Understanding the Threat Landscape: Common Container Escape Techniques
Before deploying detection, know what you’re detecting. The most common escape vectors map cleanly to syscalls eBPF can observe:
| Technique | Key Syscalls | Detection Signal |
|---|---|---|
| Privileged container abuse | mount, unshare | mount of /dev/* or host paths from a container |
| Host path mount | mount | Mounting /, /etc, /var/run inside container |
| Namespace escape | setns, unshare | setns into a PID 1 namespace from a container process |
| Docker socket exposure | connect | Unix socket connect to /var/run/docker.sock |
| Kernel exploit | ptrace, bpf, init_module | Loading modules or BPF programs from a container |
CAP_SYS_ADMIN abuse | mount, pivot_root | pivot_root or chroot outside expected paths |
Architecture Overview: Falco and Tetragon in a Self-Hosted Kubernetes Cluster
Both tools deploy as DaemonSets. Falco runs its eBPF driver (or modern eBPF probe) and evaluates rules against a stream of syscall events; Tetragon attaches its own probes and emits structured process-exec and syscall events with full ancestry. The two coexist because they attach to different probe points—no conflict.
flowchart TD
A[Container Workload] -->|syscalls| B[Linux Kernel]
B -->|eBPF probe| C[Falco DaemonSet]
B -->|eBPF probe| D[Tetragon DaemonSet]
C -->|alerts JSON| E[Falco Sidekick / Falcosidekick]
D -->|gRPC events| F[Tetragon Exporter]
E --> G[(SIEM / Loki)]
F --> G
G --> H[Threat Hunting Dashboard]
H --> I[Analyst Triage]
D -->|enforcement action| J[Kill Process / Block Syscall]
Falco does detection; Tetragon does context and optional enforcement. Keep them separate and correlate downstream.
Prerequisites and Cluster Preparation
- Kernel: 5.8+ on all nodes (verify with
uname -r). For RHEL/CentOS, ensure BTF is enabled (/sys/kernel/btf/vmlinuxexists). - Cluster: Kubernetes 1.24+, Helm 3,
kubectl. - Resources: ~2 CPU / 4GB RAM headroom per node for both agents.
- Permissions: Ability to install DaemonSets and ClusterRoles.
Verify BTF and kernel version across nodes:
kubectl get nodes -o wide
for n in $(kubectl get nodes -o name); do
kubectl debug node/${n#node/} -it --image=alpine -- \
sh -c 'uname -r; ls /sys/kernel/btf/vmlinux'
done
Deploying Falco with eBPF Support
Install Falco via Helm, explicitly selecting the modern eBPF driver to avoid kernel-module compilation on immutable nodes:
helm repo add falcosecurity https://falcosecurity.github.io/charts
helm repo update
helm install falco falcosecurity/falco \
--namespace falco --create-namespace \
--set driver.kind=modern_ebpf \
--set falcosidekick.enabled=true \
--set falcosidekick.config.slack.webhookurl="https://hooks.slack.com/services/XXX" \
--set collectors.containerd.enabled=true
Key falco.yaml tuning for container escape hunting—emit container metadata and enrich with process info:
json_output: true
json_include_output_property: true
buffered_outputs: false
syscall_event_drops:
actions: [log, alert]
rate: 0.03333
max_burst: 10
rule_matching: first
priority: debug
Confirm the driver loaded and events are flowing:
kubectl -n falco logs -l app.kubernetes.io/name=falco --tail=50 | grep -i "driver\|probe"
kubectl -n falco logs -l app.kubernetes.io/name=falco | grep -i "event"
Deploying Tetragon for Process Ancestry Tracking
Tetragon’s value is the process tree: every exec event includes parent PID, binary path, and container ID, letting you reconstruct how a suspicious process was spawned. Install via Helm:
helm repo add cilium https://helm.cilium.io
helm install tetragon cilium/tetragon \
--namespace kube-system \
--set tetragon.enableProcessCred=true \
--set tetragon.enableProcessNs=true \
--set tetragon.exportFilename=/var/run/cilium/tetragon/tetragon.log
A tracing policy to catch namespace manipulation—the classic escape pivot:
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
name: detect-setns
spec:
kprobes:
- call: "sys_setns"
syscall: true
args:
- index: 1
type: "int"
selectors:
- matchArgs:
- index: 0
operator: "NotEqual"
values: ["0"]
Apply and verify events:
kubectl apply -f detect-setns.yaml
kubectl -n kube-system exec ds/tetragon -c tetragon -- \
tetra getevents -o compact
You should see process_exec and process_kprobe events with process.pod.name and process.docker (container ID) fields populated.
Correlating Falco Rules with Tetragon Process Trees
Falco alerts include container.id and proc.pid; Tetragon events include process.docker and process.pid. Join on both in your SIEM or via a lightweight correlator:
- Falco emits JSON alerts with
output_fields.container.idandoutput_fields.proc.pid. - Tetragon exports JSON lines with
process.dockerandprocess.pidplusparentchain. - Correlator (Loki query, Splunk join, or a small Python service) matches alerts to the parent process within a 5-second window.
Example Loki LogQL join pattern:
{job="falco"} | json | line_format "{{.output_fields.container_id}}"
Then pivot to Tetragon:
{job="tetragon"} | json | process_docker = "<container_id>" | line_format "{{.process_binary}} <- {{.parent_binary}}"
The result: you see not just that setns was called, but that it was called by a shell spawned from kubectl exec inside a web pod—a high-fidelity escape signal.
Detecting Privilege Escalation and Namespace Escapes
Falco’s default ruleset already ships escape-relevant rules. Confirm and tune these:
- rule: Container Escape via setns
desc: Detect setns syscall from a container
condition: >
evt.type=setns and container.id != host
output: >
Namespace escape attempt (user=%user.name container=%container.id
pid=%proc.pid parent=%proc.pname cmd=%proc.cmdline)
priority: CRITICAL
tags: [container, escape, mitre_T1611]
For privilege escalation, watch for CAP_SYS_ADMIN grants combined with mount:
- rule: Mount from Container with SYS_ADMIN
condition: >
evt.type=mount and container.id != host and
proc.cap_effective contains CAP_SYS_ADMIN and
evt.dir=<
priority: HIGH
Pair these with Tetragon’s process_credentials events to catch UID changes (setuid(0)) inside containers—another escape precursor.
Hunting Suspicious Syscall Patterns
Beyond rule-based detection, run periodic hunts:
ptracefrom a container:evt.type=ptrace and container.id != host→ potential process injection.init_module/finit_module: kernel module loads from containers are almost always malicious.bpfsyscall from non-privileged pods: indicates BPF-based rootkit attempts.- Rapid
unshare+mountsequences: classic namespace-escape chain.
# Query Falco history (if using Falcosidekick + Loki)
logcli query '{job="falco"} |= "ptrace" | json' --since=24h
Build a dashboard that plots escape-relevant syscalls per namespace, so anomalies stand out against the baseline.
Operationalizing Alerts and Response
Detection without response is theater. Structure your workflow:
- Severity routing. CRITICAL (escape attempts) → PagerDuty + Slack; HIGH → ticket queue; MEDIUM → daily digest.
- Automated enrichment. Falcosidekick enriches alerts with pod labels, node name, and image digest.
- Response playbook. On a CRITICAL escape alert: isolate the node (
kubectl cordon), capture Tetragon process tree, snapshot the container filesystem, then evict. - Optional enforcement. Use Tetragon
TracingPolicywithaction: Sigkillonsetns/init_modulefrom containers—but only after a 2-week observation period to avoid breaking workloads.
# Tetragon enforcement example (use cautiously)
spec:
kprobes:
- call: "sys_init_module"
syscall: true
selectors:
- matchNamespaces:
- namespace: Pid
operator: NotIn
values: ["host_ns"]
actions:
- action: Sigkill
Comparison: Falco vs. Tetragon for Runtime Security
| Capability | Falco | Tetragon |
|---|---|---|
| Primary purpose | Detection rules & alerting | Observability & enforcement |
| Rule language | YAML rule DSL (rich) | TracingPolicy (kprobe/tracepoint) |
| Process ancestry | Partial (proc.pname) | Full parent chain |
| Enforcement (kill/block) | Limited | Native (Sigkill, Override) |
| Output | JSON alerts | gRPC + JSON events |
| Overhead | Low | Low |
| Best for | Security analytics, SIEM integration | Deep context, active response |
Use both: Falco for the “what,” Tetragon for the “how” and “then what.”
Conclusion and Best Practices
Container escape detection is a layered discipline. eBPF gives you the kernel visibility; Falco gives you the rules; Tetragon gives you the context and the kill switch. To make it production-grade:
- Baseline first. Run in detection-only mode for 2–4 weeks; tune out known-noisy workloads (CI runners, privileged DaemonSets).
- Correlate, don’t duplicate. Route both tools to a single SIEM and join on container ID + PID.
- Harden the pipeline. Protect Falco/Tetragon pods with
PodSecurityPolicyequivalents and restrict who can editTracingPolicyresources. - Test your rules. Use
falco --dry-runand Tetragon’stetraCLI to simulate escapes in a staging cluster. - Review quarterly. Escape techniques evolve; so should your rules.
With both tools deployed and correlated, you gain a defensible runtime posture—one that sees the syscall, understands the ancestry, and can act before the pivot completes.
FAQ
What is the difference between Falco and Tetragon? Falco is a runtime security tool that detects anomalous activity using a rich rule language and alerts on suspicious events. Tetragon focuses on eBPF-based observability and enforcement, providing deep process ancestry and kernel-level visibility. They complement each other: Falco for detection rules, Tetragon for context and enforcement.
Can I run Falco and Tetragon together in the same cluster? Yes, they can coexist. Both use eBPF, but they operate independently and attach to different probe points. Ensure you have sufficient kernel versions (5.8+ recommended) and monitor resource usage; they can share the same eBPF probes without conflict.
How does eBPF improve container escape detection compared to traditional tools? eBPF provides kernel-level visibility with minimal overhead, capturing syscalls and process events in real time without relying on userspace agents that can be bypassed. It enables detection of low-level activities like namespace manipulation and privilege escalation attempts.
What are the system requirements for deploying Falco and Tetragon? You need a Kubernetes cluster with nodes running Linux kernel 5.8 or later (for full eBPF support), Helm 3, and kubectl. Each node should have at least 2 CPU cores and 4GB RAM available for the security agents.
How do I correlate Falco alerts with Tetragon process ancestry? Use a common identifier such as container ID or process ID. Configure Falco to output container ID and process ID in its alerts, and query Tetragon’s gRPC API or logs for the process tree. You can also use a SIEM or custom script to join the data.
Can Tetragon enforce policies to block container escapes?
Yes, Tetragon supports enforcement actions like killing processes or returning errors for specific syscalls. However, enforcement should be used cautiously in production—observe for weeks before enabling Sigkill actions to avoid disrupting legitimate workloads.