blog.rust.gay

Tetragon 1.8 makes eBPF policies remember what happened

Runtime security in complex, cloud-native environments demands more than just observing isolated, individual kernel events; it requires the ability to understand and enforce policy based on the sequence and context of those behaviors. Tetragon v1.8 represents a critical, history-making evolution in this capability by introducing stateful eBPF policies. This fundamental feature allows enforcement logic to carry and correlate state between sequential kernel hooks entirely within the kernel itself, fundamentally eliminating the latency and overhead associated with exporting events to userspace for correlation. Announced during KubeCon + CloudNativeCon North America, this release significantly enhances the precision, efficiency, and overall granularity of runtime security controls over dynamic, modern cloud workloads.

The Evolution to Stateful Policies and Kernel State

Prior to v1.8, a major operational and technical constraint in tracing was the inherent statelessness of event handling; a single selector could not retain context from a preceding event. To successfully correlate complex sequences—for example, detecting a web server initiating a shell process, and subsequently blocking a malicious attempt to modify /etc/passwd—the events were forced into userspace for correlation. This mandatory round trip introduced substantial overhead and practically ruled out real-time, sequence-dependent enforcement within the high-performance demands of cloud-native infrastructure.

Tetragon v1.8 resolves this by integrating state directly into the kernel's memory. This state is managed using a simple u64 variable defined under spec.state. Policies utilize the UpdateState action to modify this state and matchStates to check it (using Equal or NotEqual) before any prescribed actions are executed. This mechanism effectively transforms a linear, stateless event stream into an efficient, kernel-enforced "if-else" logic. For instance, if an initial event (like a shell launch following an RCE) sets a specific state flag, any subsequent event (like modifying /etc/passwd) can be instantly blocked by the policy, all without a userspace round trip or a full policy reload. This capability moves sequence enforcement from a slow userspace process into the high-speed kernel path, making real-time enforcement practical and highly efficient.

Fine-Grained Command-Line Argument Filtering

Relying solely on matching a process binary name is an overly coarse method in modern, dynamic environments, especially those using interpreted languages or versatile, multi-purpose command-line tools. A service binary, such as python3 /app/server.py, might be legitimate for the intended service, but the identical binary invoked via a suspicious one-liner from an exploited shell (python3 -c '...') represents a clear security anomaly.

Tetragon 1.8 introduces matchCmdArgs, a powerful filter available across all supported hook types. This permits policies to filter events based on the actual arguments passed to the binary, not just the binary's path. This level of granularity is critical for maintaining security while minimizing operational noise. A practical application allows the policy to permit outbound connections originating from the trusted python3 /app/server.py invocation while actively terminating other suspicious Python processes attempting connections from a compromised shell environment, thereby dramatically reducing false positives and tightening the security posture.

Uprobe Caller Function Filtering

When using Uprobes for user-space monitoring, simple detection of a function call is often insufficient; security analysis requires identifying who initiated the call. matchUserCallers allows policies to filter events only when a specific function is present within the application's call stack.

Policies can be configured to examine a specific frame position or search within the 15 most recent stack frames. This matching mechanism is robust because it works regardless of how the OS loads the application in memory, provided the application and relevant libraries were compiled with frame pointers. This critical prerequisite highlights that deep, reliable runtime visibility is fundamentally dependent on the application's specific build environment, not merely its runtime execution state.

Runtime Function Replacement and Experimental Limits

Tetragon v1.8 significantly extends the existing Override action for Uprobes. Previously limited to modifying a function's return value, the update now permits redirecting a function call entirely to a different, replacement function. This replacement function can reside either within the running application or within a separate shared library.

This capability is invaluable for targeted hotfixes and dynamic security patching—for example, redirecting an is_authorized() check to a patched is_authorized_patched() implementation in a shared library, all while the service continues running uninterrupted. However, this feature is strictly experimental. It imposes strict technical requirements: Linux 6.18 or later and dynamic linking against glibc 2.34 or later. Furthermore, the replacement function must possess the exact same function signature as the original. Tetragon cannot verify this compatibility, and a signature mismatch is a high-risk operation that can crash the process, necessitating its use only as a highly targeted, cautious, and emergency deployment mechanism.

Policy Domains and Workload-Scoped Selectors

Addressing a significant operational governance flaw, v1.8 introduces Policy Domains. Previously, a policy was identified only by its name and namespace, irrespective of its origin—be it the Kubernetes API, the gRPC API (via the tetra CLI), or static disk files. This ambiguity meant a tetra administrative command could unintentionally modify a Kubernetes-managed policy with the same name, severely eroding operator trust. Policy Domains isolate tracing policies by source. This allows same-named policies from different sources to run concurrently without interference, representing a major governance and operational improvement.

Complementing this, Workload-Scoped Selectors (matchWorkloads) permit a single policy to implement diverse actions across different workloads. Selectors—podSelector, containerSelector, and hostSelector—determine scope. A powerful example is a single policy that reports a shell in a critical kube-system pod while actively terminating any shell attempt in any other, non-critical pod, demonstrating comprehensive control within one definition.

Per-Node Policy Loading and Label Editor Warning

To optimize enforcement and minimize overall overhead, policies can be conditionally loaded based on the target node's labels using spec.nodeSelector. The agent dynamically checks its own node's Kubernetes labels and only loads the policy when a match is found. This is ideal for deploying policies selectively to specialized infrastructures, such as GPU node pools or nodes designated for a specific CPU architecture, thereby ensuring zero hook overhead on unrelated nodes.

Crucially, operators must understand a vital security constraint: node labels define a trust boundary for enforcement. Any entity capable of editing these node labels possesses the ability to unilaterally disable enforcement on a given node. Therefore, enforcement policies must target labels established strictly at the time of provisioning, and strict access control must be placed on label modification. If a policy is excluded by nodeSelector, it is clearly marked as skipped in tetra tracingpolicy list, providing superior operational transparency compared to previous systems where excluded policies were simply absent.

Persistent gRPC Policies and Least-Privilege Agent

For continuous, mission-critical enforcement, Persistent gRPC Policies (via the --persist-grpc-policies flag) save the full policy state—including its enabled state and enforcement mode—to disk. Upon agent restart, the state is validated and restored, effectively preventing enforcement gaps during service restarts. For complete, uninterrupted operation, this persistence flag should be used in conjunction with --keep-sensors-on-exit and --release-pinned-bpf=false.

Simultaneously, v1.8 promotes a Least-Privilege Agent model. The Helm chart now deploys the Tetragon agent with an explicit, minimal set of Linux capabilities, moving away from the historically risky pattern of a fully privileged container. A dedicated, restricted mount-bpf-fs init container handles the necessary privileged mount. Operators must ensure their admission policies are updated to correctly accommodate this specific init container.

Performance and Operational Improvements

The optimization focused on loading only the selector-filtering code required for a policy has yielded significant, measurable performance gains. Selector programs are demonstrably 41-58% smaller, and policy loading time improved by approximately 14%. In comprehensive profiling tests, CPU time in the event-handling path decreased by about 27%, which correlated to approximately 2.1 million fewer memory allocations.

Operationally, policies submitted via tetra or static files now adhere to the same schema validated by the Kubernetes API server, guaranteeing schema consistency before loading. Redaction filters offer granular customization, allowing users to define their own replacement string (e.g., <redacted:private-key>). The enhanced visibility from the skipped policy status significantly aids operational auditing and trust.

Where Tetragon Fits vs. Sandboxes

It is vital to maintain a clear distinction: Tetragon is a powerful runtime observability and kernel enforcement layer that observes kernel events. It does not replace foundational isolation mechanisms like seccomp, user namespaces, or microVMs. Sandboxes establish robust isolation boundaries; Tetragon enforces granular rules within those boundaries (e.g., "no shell after RCE"). These technologies are highly complementary, not mutually exclusive. The inherent dual nature of eBPF—its immense power for defense and its potential for misuse (eBPF rootkits)—mandates that security solutions must be deployed with a layered defense strategy and extreme operational caution.

Conclusion: A Mandate for Policy Rigor

Tetragon 1.8 delivers robust, stateful, and fine-grained kernel-level control, solving complex sequence correlation problems with minimal performance impact. However, this immense power necessitates commensurate operational rigor. Policy design must meticulously account for kernel state lifetimes, the explicitly experimental and fragile nature of Uprobe replacement, the frame pointer prerequisites for caller filtering, and the critical fact that node labels represent a mutable trust boundary, not an immutable security guarantee. Successful and safe adoption is defined not just by feature adoption, but by careful policy design, thorough testing against verified facts, and a deep understanding of these technical and operational limits.

Sources

  • https://isovalent.com/blog/post/tetragon-v1.8-release
  • [Tetragon v1.8 release notes and documentation] (Referencing secondary sources in fact sheet)
  • [Tetragon documentation link] (Referencing secondary sources in fact sheet)
  • [KubeCon + CloudNativeCon North America announcement] (Referencing primary announcement)

← back to posts