BPFDoor
- Type
- Backdoor
- Capabilities
- PersistencePost exploitationDefense evasionLateral movementExfiltration
- Platforms
- LinuxNetwork device
BPFDoor is a stealthy backdoor for Linux and Solaris systems designed to maintain long-term access to previously compromised environments. Identified in 2021 and publicly documented in 2022, it is associated with the China-linked threat actor Red Menshen, also tracked as Earth Bluecrow, DecisiveArchitect, and Red Dev 18. Observed targets include telecommunications, government, education, logistics, financial services, and retail organizations, particularly across Asia and the Middle East, with additional activity in Africa and the United States. Deployments include servers, mail-security gateways, and other network-edge appliances.
BPFDoor attaches classic Berkeley Packet Filter programs to raw packet sockets and passively inspects incoming TCP, UDP, or ICMP traffic for specially crafted activation packets. It does not require continuous beaconing or a conventional listening port before activation. Packet inspection occurs before host firewall filtering, allowing activation by traffic that would otherwise be blocked. Authenticated commands can initiate reverse shells or bind shells; some variants also provide a presence-check response. Bind-shell operation can temporarily manipulate firewall and network-address-translation rules to redirect traffic from a legitimate service to the implant, removing those rules after connection establishment. Analyzed variants support encrypted shell sessions, and newer implementations incorporate TinyShell functionality for interactive access and file uploads and downloads.
Its evasion techniques include process masquerading, execution from shared-memory filesystems, deletion of executable files while their processes remain active, string obfuscation, and shell-history suppression. Startup-script modification has been used for persistence. Newer variants imitate regional software such as the South Korean SpamSniper anti-spam product or processes associated with telecommunications platforms. Controllers can wrap activation traffic in HTTPS POST requests and take advantage of SSL offloading to reach implants behind edge proxies. Operators use BPFDoor to maintain access, transfer data, and reach additional compromised systems within victim networks. Initial intrusion methods are not established for several investigated campaigns. Public leakage of its source code in 2022 complicates attribution of individual deployments.
Associated vulnerabilities
4 CVEs Mallory has correlated with this family across public research and vendor advisories. Each card links to the full Mallory page for that vulnerability.
Associated threat actors
4 distinct threat actors Mallory has associated with this family across public reporting. Open in Mallory to see the full evidence chain and overlapping campaigns.
The BPFDoor sample Elastic analyzed used a classic BPF socket filter to recognize specially crafted TCP, UDP, or ICMP packets. Once triggered, it could open a reverse shell or redirect traffic to the implant.
BPFDoor opens a SOCK_RAW or AF_PACKET socket and attaches a BPF filter. This looks for marked traffic.
The stealthy rootkit-like malware known as BPFDoor (detected as Backdoor.Linux.BPFDOOR) is a backdoor with strong stealth capabilities, most of them related to its use of Berkeley Packet Filtering (BPF).
Dubbed "BPFdoor," the backdoor operates without opening ports or generating typical beaconing activity, which the cybersecurity firm said allowed the Chinese-linked actors to avoid detection across traditional endpoint and network monitoring tools.
Techniques & procedures
52 distinct techniques documented for this family, organized by ATT&CK tactic.
Initial Access
3 techniques
Initial Access
Attacks usually begin at the network edge by exploiting exposed services or valid accounts on devices like VPNs, firewalls, and virtualization hosts.
Based on the password or existence of a password sent in the “magic packet” the backdoor provides a reverse shell, establishes a bind shell, or sends back a ping.
in March 2024, a hacker infiltrated the network by exploiting a vulnerability on the KT Roaming Rental Service website
Execution
4 techniques
Execution
Persistence would need to be initiated by the attacker in some other way such as rc or init scripts or scheduled tasks such as with crontab.
The newer variant analyzed by Deep Instinct features static library encryption, reverse shell communication, and all commands are sent by the C2 server.
[BPFDoor](https://attack.mitre.org/software/S1161) can create a reverse shell and supports vt100 emulator formatting.(Citation: Sandfly BPFDoor 2022)
The malware creates a raw network socket and sets BPF filters on it to inspect incoming traffic.
Persistence
10 techniques
Persistence
Persistence would need to be initiated by the attacker in some other way such as rc or init scripts... The initial report referenced above indicates that persistence scripts have been found.
Persistence would need to be initiated by the attacker in some other way such as rc or init scripts or scheduled tasks such as with crontab.
Attacks usually begin at the network edge by exploiting exposed services or valid accounts on devices like VPNs, firewalls, and virtualization hosts.
Based on the password or existence of a password sent in the “magic packet” the backdoor provides a reverse shell, establishes a bind shell, or sends back a ping.
BPFDoor and Rekoobe samples wait for a magic packet before opening interactive access.
If a packet is observed that matches the BPF filters and contains the required data it is passed to the backdoor for processing... [it] looks for a so-called magic packet.
[BPFDoor](https://attack.mitre.org/software/S1161) uses BPF bytecode to attach a filter to a network socket to view ICMP, UDP, or TCP packets coming through ports 22 (ssh), 80 (http), and 443 (https). When [BPFDoor](https://attack.mitre.org/software/S1161) finds a packet containing its “magic” bytes, it parses out two fields and forks itself. The parent process continues to monitor filtered traffic while the child process executes the instructions from the parsed fields.(Citation: Sandfly BPFDoor 2022)(Citation: Deep Instinct BPFDoor 2023)
It allows a threat actor to backdoor a system for remote code execution, without opening any new network ports or firewall rules.
When an adversary implants a persistent backdoor at the kernel level within these environments, they are not simply compromising a server, they are positioning themselves adjacent to subscriber data, signaling flows, and the mechanisms that authenticate and route national and international communications.
The campaign is characterized by the use of kernel-level implants, passive backdoors, credential-harvesting utilities, and cross-platform command frameworks, giving the threat actor the ability to persistently inhabit networks of interest.
Privilege Escalation
5 techniques
Privilege Escalation
Persistence would need to be initiated by the attacker in some other way such as rc or init scripts... The initial report referenced above indicates that persistence scripts have been found.
Persistence would need to be initiated by the attacker in some other way such as rc or init scripts or scheduled tasks such as with crontab.
Attacks usually begin at the network edge by exploiting exposed services or valid accounts on devices like VPNs, firewalls, and virtualization hosts.
The campaign is characterized by the use of kernel-level implants, passive backdoors, credential-harvesting utilities, and cross-platform command frameworks, giving the threat actor the ability to persistently inhabit networks of interest.
The following MITRE ATT&CK... sub-techniques have been observed with the BPFDoor malware... Abuse Elevation Control Mechanism: Setuid and Setgid.
Stealth
23 techniques
Stealth
Description Generated datasets for Linux Evidence of BPFdoor implant - creation of known lockfiles in attack range.
[BPFDoor](https://attack.mitre.org/software/S1161) can require a password to activate the backdoor and uses RC4 encryption or static library encryption `libtomcrypt`.(Citation: Sandfly BPFDoor 2022)
Renames its process to kdmtmpflush... [then] removes the old one setting (spoofing) a new process name.
The common thread is regionalized disguise: each sample is aware of the vendor’s software running on the targeted systems and implements process spoofing accordingly.
The SpamSniper /var/run/spamsniper.pid mutex, together with the sample provenance, ties this build to the South Korean cluster.
After initial execution, [BPFDoor](https://attack.mitre.org/software/S1161) forks itself and runs the fork with the `--init` flag, which allows it to execute secondary clean up operations. The parent process terminates leaving the forked process to be inherited by the legitimate process init.(Citation: Sandfly BPFDoor 2022)
[BPFDoor](https://attack.mitre.org/software/S1161) overwrites the `argv[0]` value used by the Linux `/proc` filesystem to determine the command line and command name to display for each process. [BPFDoor](https://attack.mitre.org/software/S1161) selects a name from 10 hardcoded names that resemble Linux system daemons, such as; `/sbin/udevd -d`, `dbus-daemon --system`, `avahi-daemon: chroot helper`, `/sbin/auditd -n`, and `/usr/lib/systemd/systemd-journald`.(Citation: Sandfly BPFDoor 2022)
[BPFDoor](https://attack.mitre.org/software/S1161) clears the file location `/proc/<PID>/environ` removing all environment variables for the process.(Citation: Sandfly BPFDoor 2022)
VIMINIT="set viminfo=", HISTFILE=/dev/null, HISTSIZE=0, and HISTFILESIZE=0.
After initial setup, [BPFDoor](https://attack.mitre.org/software/S1161)'s original execution process deletes the dropped binary and exits.(Citation: Sandfly BPFDoor 2022)
[BPFDoor](https://attack.mitre.org/software/S1161) uses the `utimes()` function to change the executable's timestamp.(Citation: Sandfly BPFDoor 2022)
Attacks usually begin at the network edge by exploiting exposed services or valid accounts on devices like VPNs, firewalls, and virtualization hosts.
That key seeds RC4's key-scheduling algorithm, and the resulting S-box is used directly as a keystream.
BPFDoor and Rekoobe samples wait for a magic packet before opening interactive access.
If a packet is observed that matches the BPF filters and contains the required data it is passed to the backdoor for processing... [it] looks for a so-called magic packet.
[BPFDoor](https://attack.mitre.org/software/S1161) uses BPF bytecode to attach a filter to a network socket to view ICMP, UDP, or TCP packets coming through ports 22 (ssh), 80 (http), and 443 (https). When [BPFDoor](https://attack.mitre.org/software/S1161) finds a packet containing its “magic” bytes, it parses out two fields and forks itself. The parent process continues to monitor filtered traffic while the child process executes the instructions from the parsed fields.(Citation: Sandfly BPFDoor 2022)(Citation: Deep Instinct BPFDoor 2023)
another execve syscall was invoked, passing the arguments /bin/rm -f /dev/shm/kdmtmpflush to /bin/sh ... execve("/bin/cp", ["/bin/cp", "./BPFDoor", "/dev/shm/kdmtmpflush"] ... ) ... execve("/bin/chmod", ["/bin/chmod", "755", "/dev/shm/kdmtmpflush"]
[BPFDoor](https://attack.mitre.org/software/S1161) creates a zero byte PID file at `/var/run/haldrund.pid`. [BPFDoor](https://attack.mitre.org/software/S1161) uses this file to determine if it is already running on a system to ensure only one instance is executing at a time.(Citation: Sandfly BPFDoor 2022)
When executed, [BPFDoor](https://attack.mitre.org/software/S1161) attempts to create and lock a runtime file, `/var/run/initd.lock`, and exits if it fails using the specified file, resulting in a makeshift mutex.(Citation: Deep Instinct BPFDoor 2023)
When an adversary implants a persistent backdoor at the kernel level within these environments, they are not simply compromising a server, they are positioning themselves adjacent to subscriber data, signaling flows, and the mechanisms that authenticate and route national and international communications.
BPFDoor... takes great care to be as efficient and stealthy as possible... [and] creates a PID file in /var/run, another temporary file storage facility.
The attacker took special attention to make the lock’s filename appears legitimate, and used several of these filenames across the samples.
[BPFDoor](https://attack.mitre.org/software/S1161) sets its process to ignore the following signals; `SIGHUP`, `SIGINT`, `SIGQUIT`, `SIGPIPE`, `SIGCHLD`, `SIGTTIN`, and `SIGTTOU`.(Citation: Deep Instinct BPFDoor 2023)
Defense Impairment
3 techniques
Defense Impairment
BPFDoor is equipped with stealthy defense evasion techniques.
[BPFDoor](https://attack.mitre.org/software/S1161) starts a shell on a high TCP port starting at 42391 up to 43391, then changes the local `iptables` rules to redirect all packets from the attacker to the shell port.(Citation: Sandfly BPFDoor 2022)
[BPFDoor](https://attack.mitre.org/software/S1161) sets the `MYSQL_HISTFILE` and `HISTFILE` to `/dev/null` preventing the shell and MySQL from logging history in `/proc/<PID>/environ`.(Citation: Sandfly BPFDoor 2022)
Credential Access
2 techniques
Credential Access
Next, the malware allocates a memory buffer and creates a packet sniffing socket that it'll use for monitoring incoming traffic for a "magic" byte sequence.
We found custom sniffers, custom tooling to intercept usernames and passwords — very highly sophisticated operations.
Discovery
3 techniques
Discovery
Next, the malware allocates a memory buffer and creates a packet sniffing socket that it'll use for monitoring incoming traffic for a "magic" byte sequence.
From the compromised OSS application, the operators abused trust relationships between network segments to pivot from the transport network into the mobile Core network.
Here, the attackers gained privileged access to a Kubernetes container where BPFdoor was deployed.
Lateral Movement
2 techniques
Lateral Movement
“Reverse shell (TCP/UDP/ICMP) leveraged as a pivot point to access and laterally move to additional systems within the network.”
The threat actor then moved laterally to an unpatched VMware ESXi server and exploited CVE-2021–21972 and CVE-2021–21974 to achieve remote code execution on multiple ESXi hosts
Command and Control
12 techniques
Command and Control
For example, if a webapp exists on port 443, it can listen and react on the existing port 443, and the implant can be reached over the webapp port (even with the webapp running).
After establishing a connection with the C2, the malware sets up a reverse shell and waits for a command from the server.
When the magic packet is received by the host, the implant will spawn a new instance and change the local iptables rules to do a redirect from the requesting host to the shell port... traffic will look like TLS/SSL traffic but in fact the attacker is interacting with a remote root shell.
“C2 communication established over raw TCP, UDP, or ICMP packets, using ‘magic bytes’ to maintain stealth and evade traditional application-layer inspection.”
22 Upload a file to the host in chunks, appending on resume.
BPFDoor and Rekoobe samples wait for a magic packet before opening interactive access.
If a packet is observed that matches the BPF filters and contains the required data it is passed to the backdoor for processing... [it] looks for a so-called magic packet.
[BPFDoor](https://attack.mitre.org/software/S1161) uses BPF bytecode to attach a filter to a network socket to view ICMP, UDP, or TCP packets coming through ports 22 (ssh), 80 (http), and 443 (https). When [BPFDoor](https://attack.mitre.org/software/S1161) finds a packet containing its “magic” bytes, it parses out two fields and forks itself. The parent process continues to monitor filtered traffic while the child process executes the instructions from the parsed fields.(Citation: Sandfly BPFDoor 2022)(Citation: Deep Instinct BPFDoor 2023)
this backdoor provided the attackers with simple yet powerful capabilities, such as a remote access to the infected systems.
It opens a new listening socket on an inconspicuous port (42391 - 43391).
We can deduce from this that the backdoor can be triggered by three different means: 1) An UDP packet starting with the bytes 0x7255 2) An ICMP packet also starting with the bytes 0x7255 3) A TCP packet starting with the bytes 0x5293.
The implant uses RC4 as the encryption layer... The real implant would require the correct password and RC4 encryption layer to see these results.
Exfiltration
1 technique
Exfiltration
21 Download a file from the host, with resume support.
Observables
160 indicators attributed across vendor reports, sandbox runs, and researcher write-ups. Values are masked here and available in full in Mallory.
Recent activity
88 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.