Back to Intelligence

How to Detect and Neutralize BPFdoor Linux Malware in Telecom Networks

SA
Security Arsenal Team
April 3, 2026
7 min read

How to Detect and Neutralize BPFdoor Linux Malware in Telecom Networks

Introduction

Telecommunications networks form the backbone of global communication, acting as the central nervous system for government, industry, and personal data. A recent investigation by Rapid7 Labs has uncovered a concerning threat to this infrastructure: BPFdoor, a stealthy Linux backdoor attributed to the China-nexus threat actor Red Menshen.

Unlike typical malware that relies on constant noisy network traffic, BPFdoor acts as a "digital sleeper cell." It leverages Berkeley Packet Filter (BPF) to silently inspect network traffic at the kernel level, remaining dormant until activated by a specific "magic packet." For defenders, this poses a significant challenge: traditional intrusion detection systems (IDS) may miss the malware because it generates no traffic until an attacker decides to wake it up. This post analyzes the mechanics of BPFdoor and provides actionable detection and remediation strategies.

Technical Analysis

BPFdoor is a highly sophisticated Linux malware designed for long-term persistence and espionage within telecommunication environments.

  • Mechanism of Action: The malware typically disguises itself as a legitimate system service (e.g., systemd, cron) or replaces a common network utility like tcpdump. Its core capability lies in its use of BPF. It attaches a filter to the network interface that listens for a specific sequence in packet headers. Once detected, it opens a reverse shell or binds a shell to a specific port, granting the attacker remote access.
  • Affected Systems: While primarily targeting Linux-based servers and routers in telecom networks, the underlying techniques can affect any Linux distribution where the attacker has gained root or privileged access. The focus is often on edge routers, gateway servers, and systems with direct internet exposure.
  • Severity: Critical. The compromise of a telecom provider allows for Man-in-the-Middle (MitM) attacks, interception of SMS/VoIP traffic, and lateral movement into connected government or enterprise networks.
  • Persistence: BPFdoor often creates system services or modifies init scripts to ensure it survives reboots. Some variants hook into inetd or xinetd configurations to restart when network activity is detected.

Defensive Monitoring

Detecting BPFdoor requires looking for anomalies in process execution, file system integrity, and network behavior. Because the malware is designed to be stealthy, organizations must deploy specific hunting rules.

SIGMA Rules

These rules are designed to detect suspicious execution patterns associated with BPFdoor, specifically the use of sniffers and raw sockets by non-standard processes.

YAML
---
title: Suspicious Linux Sniffing Tool Execution
id: 8a4b3c2d-1e5f-4a6b-8c9d-0e1f2a3b4c5d
status: experimental
description: Detects the execution of network sniffing tools like tcpdump or tshark, which may be used by BPFdoor or for reconnaissance. BPFdoor often mimics or replaces these tools.
references:
  - https://attack.mitre.org/techniques/T1040/
author: Security Arsenal
date: 2024/05/21
tags:
  - attack.credential_access
  - attack.t1040
logsource:
  category: process_creation
  product: linux
detection:
  selection:
    Image|endswith:
      - '/tcpdump'
      - '/tshark'
      - '/ngrep'
      - '/tcpproxy'
  filter:
    ParentImage|endswith:
      - '/bash'
      - '/sh'
      - '/zsh'
      - '/sshd'
condition: selection and not filter
falsepositives:
  - Legitimate troubleshooting by system administrators
level: medium
---
title: Linux Process with Deleted Binary Listening on Network
id: b5c6d7e8-f9a0-1234-5678-9abcdef01234
status: experimental
description: Detects processes that are listening on the network but have a deleted executable file on disk. This is a common technique used by malware to hide its payload or persistence mechanism.
references:
  - https://attack.mitre.org/techniques/T1014/
author: Security Arsenal
date: 2024/05/21
tags:
  - attack.defense_evasion
  - attack.t1014
logsource:
  category: network_connection
  product: linux
detection:
  selection:
    Exe|contains: '(deleted)'
  condition: selection
falsepositives:
  - Short-lived update processes
  - Known software installers
level: high

KQL (Microsoft Sentinel / Defender)

Use these queries to hunt for indicators of BPFdoor activity or compromised network utilities.

KQL — Microsoft Sentinel / Defender
// Hunt for processes using raw sockets (common in sniffers)
DeviceProcessEvents
| where Timestamp > ago(7d)
| where ProcessCommandLine contains "socket(" 
   or ProcessCommandLine contains "AF_PACKET" 
   or ProcessCommandLine contains "SOCK_RAW"
| where FileName !in~ ("tcpdump", "nmap", "wireshark") // Add known allowed tools
| project Timestamp, DeviceName, InitiatingProcessFileName, ProcessCommandLine, FolderPath

// Check for modified system binaries (Requires FileData or DeviceFileEvents)
DeviceFileEvents
| where Timestamp > ago(30d)
| where FilePath in~ ("/usr/bin/tcpdump", "/usr/sbin/tcpdump", "/sbin/tcpdump")
| where ActionType == "FileModified" or ActionType == "FileCreated"
| project Timestamp, DeviceName, InitiatingProcessAccountName, FilePath, SHA256

Velociraptor VQL

These hunts help identify suspicious binaries and active network listeners that could be BPFdoor.

VQL — Velociraptor
-- Hunt for modified tcpdump binaries or suspicious network tools
SELECT FullPath, Size, Mode.String AS Mode, Mtime, Atime, 
       hash(path=FullPath) AS Hash
FROM glob(globs='/usr/bin/tcp*', '/usr/sbin/tcp*', '/sbin/tcpdump')
WHERE Mtime < now() - 24h // Adjust based on expected maintenance windows
   AND Mode.String =~ 'rwxr-xr-x' // Looking for executable changes

-- Hunt for processes with deleted executables (Fileless/Droppers)
SELECT Pid, Ppid, Name, Exe, Cwd, Username, Cmdline
FROM pslist()
WHERE Exe =~ '(deleted)'
   AND Exe NOT IN ('/usr/bin/sudo', '/usr/bin/gdb') // Filter common false positives

-- Check for suspicious systemd services
SELECT Name, Description, ExecStart, Status
FROM systemd_services()
WHERE Status =~ 'running'
   AND (ExecStart =~ 'tcpdump' OR ExecStart =~ '/tmp/' OR ExecStart =~ '/dev/shm/')

Bash Remediation Script

Use this script to scan for common BPFdoor artifacts on Linux endpoints.

Bash / Shell
#!/bin/bash

# Security Arsenal - BPFdoor Basic Hunt Script
# This script checks for modified tcpdump binaries and suspicious network listeners

echo "[*] Checking for modified tcpdump binaries..."
TCPDUMP_PATH=$(which tcpdump 2>/dev/null)
if [ -n "$TCPDUMP_PATH" ]; then
    if [ "$TCPDUMP_PATH" != "/usr/bin/tcpdump" ] && [ "$TCPDUMP_PATH" != "/usr/sbin/tcpdump" ]; then
        echo "[!] WARNING: tcpdump found in unusual location: $TCPDUMP_PATH"
    fi
    # Check if file is a script or has weird permissions (malware often wraps binaries)
    if [ -f "$TCPDUMP_PATH" ] && file "$TCPDUMP_PATH" | grep -q "script"; then
        echo "[!] WARNING: tcpdump appears to be a script: $TCPDUMP_PATH"
    fi
else
    echo "[-] tcpdump not found in standard PATH."
fi

echo "[*] Checking for processes listening on raw sockets or with deleted binaries..."
# Using ss to list listening processes
ss -tulpen | grep -v "0.0.0.0:\*" | head -20

# Check for deleted process executables
if [ -f /proc/*/exe ]; then
    ls -l /proc/*/exe 2>/dev/null | grep '(deleted)' && echo "[!] WARNING: Found running processes with deleted binaries."
fi

echo "[*] Scan complete."

Remediation

If indicators suggest a BPFdoor infection, immediate containment and eradication are required.

  1. Isolate the Host: Disconnect the infected server or router from the network immediately to prevent command-and-control (C2) communication and lateral movement.
  2. Terminate Malicious Processes: Identify and kill the process ID (PID) associated with the backdoor. Be aware that the process may be masquerading as a legitimate service (e.g., sshd or systemd).
  3. Restore System Binaries: If BPFdoor has replaced a legitimate binary (like tcpdump or a ssh daemon), restore the original versions from the distribution's installation packages or a known good backup.
    • RHEL/CentOS: sudo yum reinstall tcpdump openssh-server
    • Debian/Ubuntu: sudo apt-get install --reinstall tcpdump openssh-server
  4. Audit Persistence Mechanisms: Review cron jobs, systemd services, and inetd/xinetd configurations. Remove any unauthorized entries that reference the malware or suspicious scripts.
  5. Rotate Credentials: Assume that all credentials (SSH keys, passwords) present on the compromised host are exfiltrated. Force a password rotation and generate new SSH keys.
  6. Patch and Harden: Ensure the operating system is fully patched. Restrict sudo access and implement kernel module signing (if applicable) to prevent unauthorized BPF loading in the future. Consider enforcing SELinux in Enforcing mode to restrict raw socket access.

Related Resources

Security Arsenal Incident Response Services AlertMonitor Platform Book a SOC Assessment incident-response Intel Hub

incident-responseransomwareforensicslinuxtelecom-securitymalwarebpfthreat-hunting

Is your security operations ready?

Get a free SOC assessment or see how AlertMonitor cuts through alert noise with automated triage.