Skip to content
Français
Account: not signed in, sync available My learning
Select theme
Français

eBPF rootkits: understand the threat and detect it

By updated

Improve this page

An eBPF rootkit is malicious software that abuses eBPF to hide, listen and persist at the heart of the kernel: this page explains what it can do, cites the documented real cases, and shows how to detect it. The angle is strictly defensive: no method to build one, but everything an administrator must know in order not to be blind. Good news demonstrated at the end: even a program designed to be discreet remains visible with the right tools. Audience: security engineer, administrator of sensitive servers. Outputs captured on an Ubuntu 24.04 VM (kernel 6.8). Prior context: the attack surface of eBPF.

What you will learn

  • Understand what an eBPF rootkit tries to accomplish
  • Know the documented real cases, in production as well as in research
  • Grasp why they are hard to spot with classic tools
  • Detect a suspicious eBPF program with bpftool
  • Link detection to the hardening measures

What does an eBPF rootkit try to do?

The power of eBPF, observing and influencing the kernel, becomes a threat in the wrong hands. Four goals come back, described here at the conceptual level.

Hiding. By interposing on the functions that system tools use to list processes, files or connections, a rootkit can filter what the administrator sees. A malicious process becomes invisible to ps, a file to ls, a connection to netstat, even though they do exist.

Opening a passive backdoor. Rather than a listening port (easy to spot), a rootkit can use a packet filter to watch for a "magic" packet in the normal traffic. On receiving it, it triggers an action (opening access). With no open port, the backdoor escapes the tools that list services.

Stealing data. By hooking the right functions, a program can read information at the moment it is in plaintext in an application's memory, before encryption or after decryption.

Altering kernel responses. Some program types can modify what a kernel function returns, to fool a check or mask an action.

Which real cases are documented?

This is not theory. Several cases are publicly documented and serve as a reference for defenders.

  • BPFDoor: a Linux backdoor observed in production, attributed by several vendors to a state-sponsored group. It uses a BPF filter to passively listen for a trigger packet, with no open port. Its discretion made it a textbook case, remaining active for years on targets.
  • Symbiote: Linux malware documented in 2022, which uses BPF to filter network traffic and conceal its command communications.
  • ebpfkit and TripleCross: research rootkits, published by security researchers (conference talks, open code for educational purposes). They demonstrate the techniques above and let defensive teams practice detecting them.

Why are they hard to spot?

An eBPF rootkit operates at the kernel level, beneath the administration tools. If it falsifies what ps or ls return, the administrator who relies on these tools sees a healthy system. That is the whole difficulty: the usual diagnostic instruments are precisely the ones the rootkit manipulates. Looking for a hidden process with ps amounts to asking the liar whether he lies.

Can they still be detected?

Here is the reassuring point, and it is decisive. An eBPF rootkit can fool system tools, but it cannot easily hide from the eBPF subsystem itself. Every loaded program is visible with bpftool, the kernel's inspection tool, which does not depend on the functions the rootkit hijacks.

First, list the active attachments: what the programs are attached to.

Terminal window
sudo bpftool link show

Real output (here a modify_return attachment, a type that can alter function returns, to be examined closely on a production machine):

1: tracing prog 2
prog_type tracing attach_type modify_return
target_obj_id 1 target_btf_id 93388

Then, inspect the code of a suspicious program. bpftool restitutes its verified bytecode, annotated:

Terminal window
sudo bpftool prog dump xlated id <number>
int deref_with_check(void * ctx):
; int deref_with_check(void *ctx) {
0: (b7) r1 = 0
; __u32 key = 0;
1: (63) *(u32 *)(r10 -4) = r1

A defender thus sees the name, the type, the attachment and even the instructions of every loaded program. A rootkit can hide a process in ps, it does not erase its own trace in bpftool prog show.

How do you detect an eBPF rootkit in practice?

The defensive approach relies on this visibility and complements the hardening measures.

  1. Establish a reference. On a healthy machine, record the list of programs (bpftool prog show) and attachments (bpftool link show, completed by bpftool perf show). This is your point of comparison, to be taken on each distribution family: the legitimate list is not the same everywhere.

  2. Compare regularly. Any kprobe, tracing or modify_return program absent from the reference is suspect. An unexplained modify_return attachment deserves particular attention. Observed on Ubuntu 24.04 (kernel 6.8, bpftool 7.4, bpftrace 0.20.2): bpftool link show does not list the probe placed on a tracepoint, whereas on AlmaLinux 10.2 (bpftool 7.7) it appears as a perf_event link. The cause of this discrepancy is not established. bpftool perf show finds the probe in both cases, with the PID of the process that holds it.

  3. Monitor the loads. The bpf() system call can itself be monitored: a runtime security tool (such as Tetragon or Tracee) raises an alert when a program is loaded. It is eBPF that monitors eBPF.

  4. Restrict upstream. With BPF LSM, loading can be allowed only to legitimate processes, cutting the ground from under a rootkit even on a compromised machine.

Key takeaways

  • An eBPF rootkit abuses eBPF to hide, open a passive backdoor, steal data or alter kernel returns.
  • It is not an entry vector: it assumes an already privileged attacker, hence the importance of upstream defense.
  • Real cases are documented: BPFDoor (in the wild), Symbiote, and the research rootkits ebpfkit / TripleCross.
  • They are hard to see with ps/ls/netstat, which they manipulate, but remain visible in bpftool (prog show, link show, perf show, prog dump).
  • Detection relies on a known reference, a regular comparison, and monitoring of loads (eBPF monitors eBPF).
  • BPF LSM makes it possible to restrict upstream who can load a program.

Knowledge check

Check that the essentials of this lesson are in place. The questions only cover what has just been explained here.

Knowledge check

Check what you have learned with this interactive quiz

6 questions
6 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer