Tetragon Documentation

repository·main·Indexed 26 days ago

https://github.com/cilium/tetragon

Tetragon is an eBPF-based security observability and runtime enforcement tool providing deep visibility into process lifecycles, system calls, and I/O activity with native Kubernetes metadata integration. This documentation covers the Tetragon API defined via Protocol Buffers, including schemas for processes, containers, pods, and kprobe events, as well as configuration for event logs and process metadata flags.

Tokens
137.3K
Snippets
208
Records
730
Agent score
88%

What's inside Tetragon

  1. Overview of Cilium Tetragon capabilities

    main

    Cilium Tetragon is a security observability and runtime enforcement tool powered by eBPF. It provides real-time detection and reaction to security-significant events directly in the Linux kernel.

    Key capabilities include:

    • Event Detection: Monitors process execution, system call activity, and I/O activity (including network and file access).
    • Kubernetes Awareness: In Kubernetes environments, Tetragon understands identities such as namespaces and pods, allowing security policies to be configured relative to specific workloads.
    • Kernel-Level Enforcement: Performs filtering, blocking, and reacting directly in the kernel to minimize overhead and prevent attackers from bypassing security by manipulating user-space data.
    • Deep Hooking: Can hook into any Linux kernel function and filter based on arguments, return values, and metadata (e.g., executable names, files, sockets, or capabilities).
  2. Overview of Kubernetes Identity Aware Policies

    main

    Tetragon provides Kubernetes Identity Aware Policies designed for dynamic, ephemeral container environments. Instead of applying uniform policies to static infrastructure, Tetragon uses eBPF for in-kernel filtering based on Kubernetes-specific constructs. This allows for precise security observability and runtime enforcement that targets specific workloads, reducing noise and performance overhead.

    Key capabilities include:

    • In-kernel filtering: Enforce policies using Kubernetes constructs like namespaces, pod labels, and container fields.
    • Precise Workload Control: Focus monitoring and enforcement on specific high-risk namespaces or critical workloads.
    • Dynamic Enforcement: Adapt to changing workloads in ephemeral environments.
    • Broad Runtime Support: Compatible with both containerd and CRI-O runtimes.
  3. Understand TracingPolicy Custom Resources

    main

    A TracingPolicy is a Kubernetes Custom Resource (CR) used to define how Tetragon observes kernel and userspace events via eBPF. It allows you to specify hook points, in-kernel filtering via selectors, and actions to take when events match.

    Supported hook points include:

    • kprobes
    • uprobes
    • tracepoints
    • LSM hooks
    • USDTs

    Policies can be managed in Kubernetes using kubectl or GitOps tools like Argo CD. For non-Kubernetes environments, policies can be applied via the tetra-cli or through Tetragon daemon configuration flags.

  4. Understand Tetragon Runtime Hooks

    main

    Tetragon Runtime Hooks address the delay between container start and Kubernetes (K8s) identity application. While Tetragon can fetch pod information (namespaces, labels) from the K8s API server, this can lead to a window where enforcement policies are not yet active.

    Runtime hooks solve this by 'hooking' into the container runtime to ensure the Tetragon agent sets up necessary filtering state before the container starts. This is achieved using the tetragon-oci-hook binary, which communicates with the Tetragon agent via a gRPC UNIX socket (tetragon.sock).

  5. Understand the Tetragon Threat Model

    main

    Tetragon's threat model helps users and operators understand security implications, identify attack vectors, and implement defensive controls. Tetragon uses eBPF for runtime security enforcement and observability.

    Key considerations for security posture include:

    • Deployment Scenarios: Kubernetes (DaemonSet), standalone containerized agents, or systemd-managed services.
    • Attacker Profiles: The model evaluates threats from Kubernetes workloads, limited privilege host attackers, Kubernetes API server attackers, and root-equivalent host attackers.
    • Policy Validation: When writing tracing policies, ensure chosen hook points are carefully validated to meet security/visibility objectives, as incorrect hook points can lead to visibility risks.
  6. Reference the Tetragon Protocol Documentation

    main

    The Tetragon API is defined using Protocol Buffers (protobuf). The documentation is organized into several key proto files that define the communication between Tetragon and its clients:

    • tetragon/bpf.proto: Defines BPF-related commands and program types.
    • tetragon/capabilities.proto: Defines capability types and process privilege changes.
    • tetragon/eventlogservice.proto: Defines the EventLogService for managing and retrieving event logs.
    • tetragon/tetragon.proto: The core schema containing primary data structures like Process, Container, Pod, Namespace, and various Kprobe event types.
    • tetragon/events.proto: Defines event streaming, filtering (e.g., FieldFilter, RedactionFilter), and aggregation options.
    • tetragon/sensors.proto: Defines the sensor management API, including enabling/disabling sensors and managing tracing policies.
  7. Understand Tetragon Tracing Policy Modes

    main

    Tetragon tracing policies operate in three distinct modes that determine how enforcement actions are handled:

    • monitoring: Enforcement operations are elided (ignored).
    • enforcement: Enforcement operations are respected and performed.
    • monitor_only: The policy contains no enforcement actions and therefore cannot be switched to enforcement mode.

    You can inspect the current mode of your policies using the tetra CLI.

  8. Leverage Tetragon for Network Observability

    main

    Tetragon provides deep insights into network events by linking network activity directly to the processes and workloads driving them. This allows for process-aware monitoring and socket lifecycle tracking in cloud-native environments.

    Key capabilities include:

    • Process-Aware Network Monitoring: Links every network event to specific processes and workloads for full context.
    • Socket Lifecycle Insights: Tracks the entire lifecycle of sockets, including connections, sent/received bytes, and specific socket events.
    • Kubernetes-Enriched Metadata: Automatically enhances network observability with Kubernetes identities, such as pod labels and namespaces.
    • Comprehensive Visibility: Provides a holistic view of network activity to facilitate faster troubleshooting and improved security posture.
  9. Ways to contribute to Tetragon

    main

    Contributions to Tetragon are not limited to code. You can support the project by:

    • Writing content: Write blog posts about Tetragon or its use cases. These can be added to the project [resources]({{< ref "/docs/resources" >}}).
    • Speaking: Present Tetragon at conferences or meetups. Video recordings can be added to [resources]({{< ref "/docs/resources" >}}).
    • Community engagement: Share usage on social platforms and add yourself to the Cilium project user list.
    • Issue tracking: Raise issues regarding bugs or feature enhancements via the GitHub issue tracker.
    • Code review: Review existing pull requests to provide fresh perspectives on patches.
    • Technical contributions: Submit patches for code or documentation improvements.
  10. Monitor Kernel Modules and eBPF Subsystem Activity

    main

    Tetragon provides real-time observability into operating system integrity by monitoring critical kernel-level operations. You can use Tetragon to:

    • Audit Kernel Modules: Track the loading and unloading of kernel modules. Tetragon identifies the specific processes or containers responsible for these actions and captures whether the kernel module is signed, which helps ensure only verified code is integrated into the kernel.
    • Observe eBPF Subsystem Interactions: Monitor eBPF program loads and interactions to detect suspicious activity or unauthorized modifications to the eBPF subsystem.
  11. Understand TracingPolicy Custom Resource

    main

    Tetragon's TracingPolicy is a Kubernetes custom resource (CR) used to trace arbitrary kernel events. A policy defines a hook point (supporting kprobes, tracepoints, and uprobes) and uses selectors for in-kernel filtering and specifying actions to take upon a match.

    Warning: TracingPolicy provides low-level configuration. Users should have Linux kernel and container knowledge to avoid issues like TOCTOU (Time-of-Check to Time-of-Use) bugs.

  12. Understand Tetragon Selectors

    main

    Selectors enable in-kernel BPF filtering and actions for Tetragon hooks. Each hook can contain up to 5 selectors.

    Matching Logic:

    • AND logic: For a single selector to match, all its defined filters must match.
    • OR logic (Short-circuiting): If multiple selectors are defined in a hook, only the action of the first matching selector is applied.
    • Default Action: If no selectors are defined, the default action is Post (post an event). If a selector matches but defines no action, the default action Post is applied.

    Available Filters:

    • matchArgs: Filter on function argument values.
    • matchData: Filter on kernel data structure fields (e.g., UID, PID).
    • matchReturnArgs: Filter on the function's return value.
    • matchPIDs: Filter on host PIDs.
    • matchBinaries: Filter on binary paths.
    • matchParentBinaries: Filter on parent binary paths.
    • matchNamespaces: Filter on Linux namespaces.
    • matchCapabilities: Filter on Linux capabilities.
    • matchNamespaceChanges: Filter on Linux namespace changes.
    • matchCapabilityChanges: Filter on Linux capability changes.
    • matchWorkloads: Filter on Kubernetes workloads.

    Available Actions:

    • matchActions: Apply an action on selector matching.
    • matchReturnActions: Apply an action on return selector matching.
    apiVersion: cilium.io/v1alpha1
    kind: TracingPolicy
    metadata:
      name: "mount-example"
    spec:
      kprobes:
      - call: "sys_mount"
        syscall: true
        selectors:
          # first selector: if binary is /usr/bin/mount, do nothing (NoPost)
          - matchBinaries:
            - operator: In
              values:
              - "/usr/bin/mount"
            matchActions:
            - action: NoPost
          # second selector: for everything else, Post the event
          - matchActions:
            - action: Post