Guides: eBPF for AI agent security

What is eBPF, and how does it secure AI agents at runtime?

eBPF is a Linux kernel technology that runs small, verified programs at kernel hooks such as system calls, file access and network events, without changing kernel source code or loading kernel modules. For AI agents, it shows what each agent process on a node actually does, including model calls, subprocesses and file reads that never pass through an AI gateway. Through BPF LSM hooks it can also block an action before it completes.

Key takeaways

  • The kernel verifier checks each eBPF program before it loads, which is why eBPF is used in production for networking, observability and security
  • An AI gateway sees only the calls routed through it. Direct model calls, MCP servers launched over stdio and in-cluster agent-to-agent traffic usually bypass it
  • eBPF sees process, file and connection activity on the node but not prompts or user intent, so it complements a gateway and does not replace one

In this article:

What is eBPF?

eBPF lets you run sandboxed programs in a privileged context such as the operating system kernel. In practice it is a safe way to add your own logic to a running Linux kernel.

Linux splits work into two layers. Applications run in user space with no direct access to hardware, and they ask the kernel for anything they need through system calls: opening a file, starting a process, connecting to a server.

An eBPF program is a small function attached to one of those kernel events. When the event fires, the program runs and can pass what it saw to a tool in user space.

Where did eBPF come from, and what problem does it solve?

eBPF grew out of the Berkeley Packet Filter (BPF), which Steven McCanne and Van Jacobson described in 1993 as a small in-kernel virtual machine for filtering packets for tools such as tcpdump. In 2014 Linux generalized it with a richer instruction set, maps and the bpf() system call, which first appeared in Linux 3.18.

Before eBPF, extending the kernel meant choosing between three costly options:

  • Change the kernel itself and wait for the patch to reach your distribution, which the eBPF project notes can take years
  • Load a kernel module, which runs with full privileges and no safety boundary, so one bug can crash the machine
  • Stay in user space with agents, sidecars or instrumentation, which see only the applications set up to use them

eBPF removes that trade-off. A program loads into a running kernel without a reboot, the verifier gives it a safety boundary, and it can observe workloads without any change to the application.

How does eBPF work?

An eBPF program is compiled to bytecode, loaded through the bpf() system call, checked by the kernel verifier, compiled to native code and attached to a hook. The first three steps happen in user space and the last three inside the kernel.

  1. Write: a developer writes the program in a restricted form of C, or a tool generates it
  2. Compile: a compiler such as LLVM turns the source into eBPF bytecode
  3. Load: a user-space tool passes the bytecode to the kernel with bpf(), which requires root or the CAP_BPF capability
  4. Verify: the verifier rejects the program unless it is certain to finish, stays within size limits and touches only memory it is allowed to
  5. JIT compile: the verified bytecode is translated into native machine code
  6. Attach: the program runs each time its hook fires, such as a system call, kernel function, tracepoint or network event
eBPF source is compiled to bytecode, loaded with bpf(), verified, JIT compiled and attached to a kernel hook
Figure 1. How eBPF works. Source code is compiled to bytecode, loaded with the bpf() system call, checked by the verifier, compiled to native code and attached to a kernel hook. Maps carry data back to user space.

Programs keep state and pass events to user space through maps, which are shared data structures such as hash tables and ring buffers. They can call only a fixed set of kernel helper functions.

The verifier is a safety check, not a security review. It proves a program cannot crash or hang the kernel, not that its purpose is benign, which is why loading eBPF programs is a privileged operation.

What is eBPF used for?

Most production use of eBPF falls into three areas, and the eBPF project’s landscape page lists open source projects for each.

  • Networking: routing, load balancing and filtering packets inside the kernel. Katran is a layer 4 load balancer built this way, and Calico offers an eBPF data plane for Kubernetes
  • Observability: tracing and profiling live systems without changing application code. Examples include bpftrace, Pixie and Parca
  • Security: watching process starts, file access and connections for runtime threat detection, as Falco does, and blocking actions through BPF LSM

Why can’t an AI gateway see all AI agent traffic?

A gateway is a proxy, so it sees the calls that are routed through it and no others. It can check identity, apply policy and record what it forwarded, but three kinds of agent traffic often bypass it.

  • Direct model calls: an agent configured with a provider API key calls the provider endpoint directly unless someone pointed it at the gateway
  • MCP servers launched over stdio: the client starts the server as a subprocess and talks over standard input and output, one of the two standard MCP transports, so there is no network request to intercept
  • Agent-to-agent calls inside the cluster: ordinary service-to-service traffic that passes through the gateway only if it was configured to

The root cause is that a gateway governs the agents someone registered. In a Cloud Security Alliance survey published in April 2026, 82 percent of organizations had discovered AI agents they did not know about.

A gateway sees only routed calls; direct model calls, stdio MCP and in-cluster agent calls bypass it; eBPF sees both
Figure 2. A gateway sees the calls routed through it. Direct model calls, MCP servers launched over stdio, and agent-to-agent traffic inside the cluster can bypass it. eBPF in the kernel sees both groups.

Which runtime signals reveal an AI agent?

Five kernel-visible signals, taken together, separate an AI agent from an ordinary application. The kernel also knows each process’s parent and cgroup, so events can be tied to a specific pod or host workload even if it was never issued a credential.

  • Connections to model endpoints: the destination and TLS server name are visible even though the request body is encrypted
  • Agent framework libraries mapped into the process, such as LangChain, LangGraph, CrewAI, AutoGen, the OpenAI Agents SDK or Google ADK
  • Environment variables that name a model provider or carry a provider API key
  • Child processes: MCP servers started over stdio, shells, interpreters and package installs
  • File access: mounted service account tokens, workspace directories, configuration and memory files

No single signal is proof. A discovery system scores them into a verdict, and an agent-like workload that is missing from your inventory is a shadow agent.

Five kernel-visible runtime signals combine into a verdict that flags an unregistered workload as a shadow AI agent
Figure 3. Five runtime signals, all visible from the kernel, combine into a weighted verdict. An agent-like workload that is missing from the registry is a shadow agent.

AI gateway vs eBPF: what does each layer see?

The gateway is strong on meaning and limited in coverage. eBPF is strong on coverage and blind to meaning.

Capability AI gateway (in the path of the call) eBPF (in the kernel, under the agent)
Calls routed through the gateway Yes, with content Yes, as connections and processes
Direct model calls that skip the gateway No Yes
MCP servers launched over stdio No Yes, as a subprocess with its files and connections
Unregistered (shadow) agents No Yes, by behavior
Prompts, tool arguments and responses Yes Not at the kernel or socket, where payloads are encrypted
Which user the agent is acting for Yes, from the delegated token No
Enforcement point Before the call is forwarded At the system call or LSM hook, before the action completes

Can eBPF block an AI agent, or only observe it?

It can block. Since Linux 5.7, BPF LSM programs can attach to Linux Security Module hooks, which fire before the kernel completes a sensitive operation, and deny it. The hooks that matter for agents run before a binary executes, a file opens or a socket connects.

That enables two controls without changing the container image or restarting the pod:

  • A sandbox: a policy that declares which paths an agent may write, which executables it may launch and which destinations it may reach
  • A quarantine: a switch that stops one workload’s outbound connections, process starts and file writes while leaving it running for inspection

Kernel support is the practical constraint. Production enforcement generally means a 6.x kernel, some implementations require 6.3 or later, and enterprise distributions such as RHEL 9 backport the relevant support.

What can’t eBPF see?

eBPF at the kernel and socket level does not see prompts, tool arguments or user intent. It sees that a TLS session opened to a model endpoint, but the payload is ciphertext at the socket, and it sees the process, not the person the agent is acting for. Reading the plaintext means hooking the TLS library inside each process, which some tools do and which copies prompt content into the record.

Those gaps are what a gateway fills: content, tool names and arguments, and delegated user identity. The OWASP Top 10 for Agentic Applications lists goal hijack, tool misuse, identity abuse and rogue agents as distinct risks, and no single layer addresses all of them. For more on the kernel view, see Why eBPF is useful for watching and sandboxing AI agents.

Frequently asked questions

What is the difference between BPF and eBPF?

BPF, the Berkeley Packet Filter, dates from 1993 and filtered network packets inside the kernel for tools such as tcpdump. eBPF is the extended version introduced in Linux in 2014. It adds a richer instruction set, maps for sharing data, and hooks across the kernel, not just the network.

Is eBPF safe to run in production?

Yes, when access to it is controlled. The verifier rejects any program that could crash or hang the kernel, but it does not judge intent, so loading programs requires root or the CAP_BPF capability. Runtime overhead is low because programs run as native code and only when their hook fires.

Which Linux kernel version do I need?

Observability works on most modern kernels. Enforcement through BPF LSM has existed since Linux 5.7, but production implementations commonly require a 6.x kernel, and some need 6.3 or later. RHEL 9 backports support into its maintained kernels.

Does eBPF work for AI agents outside Kubernetes?

Yes. eBPF is a Linux kernel feature, so the same hooks apply to agents on virtual machines, bare-metal hosts and CI runners. Kubernetes adds convenient identity because each pod has its own cgroup, but it is not required.

How do I get started with eBPF?

Read the introduction at ebpf.io, then try bpftrace on a test machine, where a one-line script can print the programs a machine starts. Use libbpf or BCC when you need to write your own programs.

How Lynx approaches this

Lynx by Tigera uses eBPF for the runtime layer this guide describes. Its optional agent detector runs as a DaemonSet on each node and reads the server name in outbound TLS handshakes (or the address of an in-cluster model), the agent framework libraries loaded in a process, and the names of environment variables that point to a model provider.

The signals are weighted into a score, configuration evidence alone does not classify a workload, and variable values are not recorded. A workload that matches no registered agent gets a Shadow verdict, and with events turned on, a newly discovered agentic workload also raises an event.

The same detector enforces sandbox policies through Linux security module hooks: the paths a workload may read and write, the executables it may launch and the destinations it may reach, applied to running pods without a restart. A quarantine denies a workload’s outbound connections and process starts and leaves its file system read-only, without stopping it. Detection needs Linux 5.17 or later on amd64 nodes with cgroup v2 and BTF. Enforcement needs 6.3 or later, or a RHEL 9 family kernel with the features backported (validated on Rocky Linux 9.8).

Calls routed to the Lynx gateway are checked against identity and Cedar policy, and each decision is recorded in the Agent Trail.

Explore the AI agent security guides or learn more about Lynx by Tigera.

Previous: AI agent security (hub) | Next: Shadow AI: how to find the AI agents already running in your environment

Add Tigera as a preferred source on Google to see more of our content in your search results.

Add as a preferred source on Google
X