Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Tetragon: in-kernel detection and blocking with eBPF

9 min read
Improve this page

Tetragon does not stop at observing and alerting: it can block a forbidden action directly in the kernel, before it completes. That is what sets it apart from detection tools such as Tracee or Falco, which report after the fact. Built on eBPF by the Cilium team, Tetragon watches processes and network activity, and applies enforcement policies. This page shows it at work on a host, with the real output of the observation, captured on an Ubuntu 24.04 VM (kernel 6.8, Tetragon v1.7.0). For the eBPF foundations, see the eBPF hub.

What you will learn

  • Tell apart observing, detecting and blocking
  • Run Tetragon on a host and read its event stream
  • Understand TracingPolicies, which target precisely what you watch
  • Write a policy that blocks an action (enforcement)
  • Place Tetragon in Kubernetes and against the other tools

The problem: detecting is already too late

Runtime security tools alert: they spot a suspicious action and record it. That is useful, but the alert arrives after the action took place. For a read of a sensitive file or a privilege escalation, it can already be too late.

Tetragon adds the enforcement layer. By hooking into the right points of the kernel, it can not only see a forbidden action but prevent it, by terminating the offending process at the very moment it tries to perform it. Observe, detect, block: that is the continuum Tetragon covers.

Prerequisites

  • A Linux host with a recent kernel and BTF (/sys/kernel/btf/vmlinux), see CO-RE and BTF.
  • A container runtime to run the official image.
  • The privileges to load eBPF programs on the host.

Run Tetragon and observe

Like the other runtime security tools, Tetragon is distributed as a container image. You run it with access to the host, then read its stream with the tetra client:

Terminal window
sudo docker run -d --name tetragon --pid=host --cgroupns=host --privileged \
-v /sys/kernel:/sys/kernel -v /proc:/procHost \
quay.io/cilium/tetragon:v1.7.0@sha256:deda51c3f88e4d26b4d76c99ea207f2b05f9e40c210e0f04a37ca632ab7bf527
# the event stream, in compact view
sudo docker exec tetragon tetra getevents -o compact

Real output (every process start and exit, with the identifier of the originating container):

process 603c747a0f99 /usr/bin/uname -r
exit 603c747a0f99 /usr/bin/uname -r 0
process 603c747a0f99 /usr/bin/cat /etc/hostname
exit 603c747a0f99 /usr/bin/cat /etc/hostname 0

The compact view marks each start (process) and each exit (exit, followed by the return code), with the full command. By default, Tetragon already observes process executions, with no configuration. To target anything else, or to block, you write a TracingPolicy.

TracingPolicies: precise targeting

A TracingPolicy is a resource that describes what Tetragon watches and what it does about it. It hooks into a point of the kernel (a kprobe on a function, a tracepoint), filters events with selectors (by file path, by argument, by value), and attaches an action.

Without a blocking action, a policy is used to observe precisely: for example, to report only the opens of a sensitive file instead of the whole stream. That is already valuable for cutting the noise and focusing on what matters.

Block an action: enforcement

This is the core of Tetragon. You add an enforcement action to a selector, the most direct being Sigkill: Tetragon terminates the process in the kernel at the moment it triggers the targeted event. Here is an example of a policy that stops any process from opening a protected file:

apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
name: bloque-secret
spec:
kprobes:
- call: "security_file_open"
syscall: false
args:
- index: 0
type: "file"
selectors:
- matchArgs:
- index: 0
operator: "Equal"
values:
- "/etc/mon-secret"
matchActions:
- action: Sigkill

The mechanism, as documented by the project: when a process tries to open /etc/mon-secret, the selector matches, and the Sigkill action kills the process before the open completes. The difference with a detection tool is fundamental: Tracee or Falco would have reported the access; Tetragon prevents it. Beyond Sigkill, other actions exist (overriding the return value of a call, for example), but Sigkill shows the principle most clearly.

Tetragon in Kubernetes

Tetragon's main use case is the cluster. It is deployed there as a DaemonSet (one instance per node), and both the events and the policies carry the Kubernetes context: pod, namespace, labels.

Terminal window
helm repo add cilium https://helm.cilium.io
helm install tetragon cilium/tetragon -n kube-system

TracingPolicy objects then become Kubernetes resources, applied cluster-wide and targetable by namespace or by Pod label. That is what lets you forbid an action in one specific namespace without touching the rest.

Tetragon, Tracee or Falco

Three eBPF tools share the runtime security ground, with different priorities. The detailed comparison deserves its own page, Falco vs Tetragon; here are the essentials.

  • Tetragon covers observation and in-kernel blocking; it is the only one of the three that prevents an action rather than just reporting it.
  • Falco is the reference for rule-based detection, a mature CNCF project with deep integrations.
  • Tracee focuses on signature-based detection and forensics.

Security and points of attention

  • High privileges. Tetragon runs with full access to the kernel: it is a sensitive component, to be treated as such (reduced surface, updates kept current).
  • Blocking is a double-edged sword. A policy that is too broad can cause an outage. Always validate in observation mode before enabling Sigkill.
  • Volume and noise. On a busy host, observing everything is expensive and drowns the signal. Use targeted TracingPolicies rather than the raw stream.
  • Sensitive data. Events contain paths, arguments and identities. Treat them as security logs.

Troubleshooting

SymptomLikely causeSolution
No eventsBTF missing, or host mounts missingCheck /sys/kernel/btf/vmlinux and the --privileged volumes
The policy does not blockSelector that does not matchCheck the exact path/argument, test in observation mode first
Legitimate processes killedPolicy too broadNarrow the selectors, revalidate in observation mode
permission deniedNon-privileged containerAdd --privileged and the required mounts

Key points

  • Tetragon observes processes and network activity and can block an action in the kernel: that is its differentiator.
  • By default, it reports process executions (process / exit) with no configuration.
  • A TracingPolicy targets a kernel point precisely, filters with selectors, and attaches an action.
  • The Sigkill action terminates the process before the forbidden action completes, where Tracee or Falco only alert.
  • Enforcement is validated in observation mode first: a policy that is too broad can break a service.
  • In Kubernetes, Tetragon is deployed as a DaemonSet with policies targetable by pod and namespace.

Next steps