XWorm (Linux ELF Backdoor) — A Different Malware Family
A distinct Linux ELF backdoor shares the name 'XWorm' with the Windows .NET RAT this site primarily covers. This page disambiguates the two and documents the Linux variant.
This page describes a different malware family than the XWorm Windows .NET RAT documented across this site. They share the name "XWorm" but are otherwise unrelated:
| Attribute | XWorm (Windows RAT) | XWorm (Linux ELF) |
|---|---|---|
| Platform | Microsoft Windows | Linux (x86_64) |
| Binary format | .NET (managed PE) | Stripped PIE ELF |
| Primary targets | Endpoints / users | Cloud servers / Kubernetes |
| Distribution | MaaS, phishing, ClickFix | SSH / webshell deployment |
| C2 transport | TCP, AES-encrypted | HTTPS 443, AES-256-CBC |
| Developer alias | XCoder / EvilCoder | Unconfirmed |
For the Windows .NET RAT, see What Is XWorm?. The remainder of this page covers the Linux ELF backdoor only.
XWorm (Linux ELF) is a sophisticated Linux ELF binary backdoor designed primarily to target cloud servers and Kubernetes clusters. It is notable for its anti-forensics capabilities, advanced persistence mechanisms, and ability to operate stealthily within cloud environments.
1. Core Architecture & Technical Design
Typically distributed as a stripped, position-independent executable (PIE) compiled for x86_64. PIE allows injection into various processes without immediate suspicion based on memory addresses.
Uses AES-256-CBC for encrypting communication payloads. The key is derived from the SHA256 hash of the CPU Serial Number (CPUID.1.EAX / CPUID.1.EBX) concatenated with a hardcoded XOR key. This lets the C2 server identify which host is communicating without storing a unique static ID per host in the binary.
Uses a custom memory allocator and maps configuration structures into mmap'd anonymous regions rather than the standard .bss or .data segments, to avoid detection by standard memory scanners.
2. Execution & Anti-Forensics
Upon successful execution, attempts to delete its own binary from disk using unlink(2) while keeping the file descriptor open. The file becomes invisible in standard directory listings (ls) and prevents casual forensics from grabbing the original file.
Checks for a debugger by inspecting the PTRACE_TRACEME flag in the kernel's process table. Monitors /proc/self/exe to ensure the path matches the expected location; if modified or missing (due to unlink), it may drop into a dormant state.
Periodically modifies its comm field in /proc/[pid]/comm to masquerade as a standard system process (e.g., kworker/u4:2 or kswapd0).
After executing a command or establishing a connection, actively clears /var/log/messages, /var/log/syslog, and journalctl entries related to its specific PID to remove traces of its activity.
3. Persistence Mechanisms
- › Cron Jobs — Creates a root-owned cron entry (/etc/cron.d/xworm) with a wildcard or short interval to re-inject the payload.
- › Systemd Units — Drops a malicious service file (e.g., /etc/systemd/system/monitor.service) pointing to a hidden directory or a memory-resident script.
- › Kubernetes CronJobs — Inside a K8s pod, attempts to interact with the local API server (if permissions allow) or mounts to create a CronJob resource that restarts the malicious container.
- › LD_PRELOAD — In some variants, drops a shared object (.so) and modifies the system-wide LD_PRELOAD environment variable to hijack common library calls, ensuring its code executes even if the main binary is killed.
4. Command and Control (C2) Protocol
Uses standard HTTPS over port 443 to blend in with typical web traffic. The User-Agent string is spoofed to match a legitimate browser (e.g., Mozilla/5.0 (Windows NT 10.0; Win64; x64)).
5. Offsets & Memory Layout (Technical Forensics)
For reverse engineering, the following offsets in the standard XWorm ELF binary are critical:
6. Detection Strategies for Blue Teams
- › Fileless Activity — Monitor for processes running from [deleted] in /proc/[pid]/exe.
- › CPUID Hashing — Look for excessive use of CPUID instructions in userspace binaries, especially those performing cryptographic operations.
- › Cron/Systemd Integrity — Regularly audit /etc/cron.d/ and /etc/systemd/system/ for recently created or modified files that point to obscure paths.
- › Network Signatures — While the traffic is HTTPS, the frequency of the 15-second heartbeat to a single IP can be detected via Zeek/Suricata.
rule Xworm_Core {
meta:
author = "CyberNeurova"
description = "Detects Xworm ELF binary"
strings:
$a = "libcrypto.so.3" ascii
$b = "/etc/cron.d/" ascii
$c = "AES-256-CBC" ascii wide
$d = "kworker/u" ascii
condition:
uint32(0) == 0x7f454c46 and all of them
}7. Operational Playbook for Red Teamers
- › Initial Access — Deploy XWorm to a compromised host via an SSH session or a webshell.
- › Environment Check — XWorm checks if it is in a Docker container or bare metal. If in Docker, it may wait for a K8s credential mount before attempting to pivot to the master node.
- › Credential Harvesting — Scans /root/.kube/config, /var/run/secrets/kubernetes.io/serviceaccount/, and /root/.ssh/id_rsa immediately upon installation.
- › Lateral Movement — If K8s credentials are found, uses curl (via the EXEC C2 command) to create a new Pod on the kube-system namespace using hostPID: true to escape the container and access the host network.
8. Advanced Evasion Techniques
- › Time Gaps — Does not execute continuously. Uses a 'sleep-wake' cycle, remaining dormant for 5-10 minutes before executing a batch of commands to reduce the chance of being caught by real-time monitoring.
- › Environment Spoofing — Can spoof the output of uname -a and cat /etc/os-release if the C2 issues a specific 'camouflage' command, allowing it to masquerade as a different OS version.
- › Memory Decryption — Keeps the bulk of its logic encrypted in memory and only decrypts the specific function block it needs to execute into a temporary executable memory page, then wipes the plaintext after the jump.
Advanced Linux Threat Telemetry & IOC Reference
A definitive observability guide for Security Engineers. Each profile maps a sophisticated post-exploitation behavior to the telemetry artifacts a Blue Team should capture in their SIEM, EDR, or flow logs. Tone is clinical and detection-focused.
Cloud-Native Credential Artifacts (K8s Context)
Leveraging Kubernetes Service Account tokens to pivot to higher-privilege workloads. A process inside a pod reads the mounted service-account token and uses it against the cluster API to create or modify Pod objects with host-level namespace access.
- ›Monitor for unauthorized reads of /var/run/secrets/kubernetes.io/serviceaccount/token and the ca.crt / namespace files. Any read by a process outside the kubelet, kube-proxy, or a known CNI daemon is a high-severity signal.
- ›Correlate token reads with subsequent outbound connections to the in-cluster API server (tcp/443 or tcp/6443 to the service IP 10.0.0.1 or KUBERNETES_SERVICE_HOST).
- ›Watch the HostPID telemetry signal: alert on any Pod create/update where spec.hostPID, spec.hostNetwork, or spec.hostIPC transitions to true, or where nodeSelector targets a control-plane node. This is the moment a pod's namespace is expanded to host level.
- ›Flag privileged: true and hostPath mounts of / or /var/run/docker.sock as privilege-escalation precursors.
- ▸file.path = /var/run/secrets/kubernetes.io/serviceaccount/*
- ▸process.name NOT IN (kubelet, kube-proxy, cilium, calico)
- ▸destination.service.name = kubernetes.default.svc
- ▸k8s.pod.spec.hostPID = true | hostNetwork = true
- ▸k8s.audit.verb IN (create, update) AND k8s.audit.resource = pods
Dynamic Library Interception Patterns
Processes manipulating environment variables to hook standard library calls. A global LD_PRELOAD change forces every subsequently launched binary to load an attacker-controlled shared object, enabling shadow system calls that hide files, processes, or spoof command output.
- ›Treat any write to the global LD_PRELOAD path (/etc/ld.so.preload) as a critical alert — this file affects every dynamic binary on the host.
- ›Watch for per-process LD_PRELOAD set on long-lived daemons that were not started with it; a sudden environment change on a running process is anomalous.
- ›Detect libc function hooking by monitoring for dlopen/dlsym resolution of common hijack targets (open, read, readdir, stat, uname, ptrace) from unexpected shared objects.
- ›Correlate LD_PRELOAD tampering with subsequent spoofed outputs — e.g. a uname syscall returning a value inconsistent with the host's known kernel.
- ▸file.path = /etc/ld.so.preload (write/create)
- ▸process.env.LD_PRELOAD IS SET on non-launcher processes
- ▸library.load.name NOT IN (libc.so, libpthread.so) AND target = open|readdir|uname
- ▸syscall.uname.return_value != host.kernel_version
- ▸process.executable = [deleted] AND process.env.LD_PRELOAD IS SET
In-Memory Code Shadowing
Modifying code execution without touching the physical disk file. A secondary memory region is allocated, the target's code is copied and patched there, and execution is redirected to the shadowed copy — leaving the on-disk binary and its primary .text section untouched.
- ›Flag the specific sequence: mmap(PROT_READ|PROT_WRITE|PROT_EXEC) on an anonymous region, immediately followed by a ptrace(PTRACE_POKETEXT) or PTRACE_SETREGS redirect of the target's instruction pointer into that region.
- ›Contrast with standard file-based injection: a clean process maps its code from a file-backed VMA (device/inode populated). A shadowed process has an anonymous executable VMA with no backing inode — the key discriminator.
- ›Alert when a process's instruction pointer (RIP) is observed executing inside an anonymous mmap region rather than a file-backed mapping.
- ›Correlate with the unlink-after-open pattern: the binary's /proc/[pid]/exe shows [deleted] while the process keeps running — the file was removed from disk but the descriptor remains open.
- ▸mmap.prot = RWX AND mmap.flags = MAP_ANONYMOUS|MAP_PRIVATE
- ▸ptrace.request IN (POKETEXT, SETREGS) AND target.rip IN anonymous_region
- ▸process.vmarea.flags = executable AND process.vmarea.inode = 0
- ▸process.exe_path = [deleted] AND process.state = running
- ▸edir.memory.exec_region = anonymous (no backing file)
Steganographic Network Exfiltration
Data leakage that hides within the padding of standard protocols or benign file formats. Sensitive data is encoded into DNS query subdomains or embedded into the trailing bytes of PNG/JPEG images before egress.
- ›Detect Anomalous DNS Query Entropy: alert on subdomain labels exceeding ~30 characters with high Shannon entropy (>3.5 bits/char), or a single domain with a burst of unique subdomains never seen in baseline resolution.
- ›Flag the long-subdomain pattern: a TXT or A query whose leftmost label is a long base32/base64-looking string — characteristic of DNS tunneling (iodine, dnscat2, and custom variants).
- ›Identify stuffed image files: alert when a PNG/JPEG header indicates small dimensions (e.g. 100x100) but the observed flow payload size is disproportionately large (e.g. >500 KB). Compare Content-Length / image dimensions ratio against baseline.
- ›Correlate sustained high-volume DNS (queries/sec) from a single host with low actual HTTP egress — a host talking mostly DNS is a tunneling candidate.
- ▸dns.query.subdomain.length > 30 AND dns.query.entropy > 3.5
- ▸dns.query.type IN (TXT, NULL) AND count(unique subdomain) > 50/min
- ▸http.content_type IN (image/png, image/jpeg) AND content_length > 500000 AND image.dimensions < 200x200
- ▸flow.bytes_out / flow.dns_queries > baseline.p95
- ▸dns.response.length > 200 (TXT records carrying data)
Binary Polymorphism & 'Salted' Payloads
Attackers use unique 'salting' so every dropped binary has a different hash — instruction reordering, variable renaming, and key XOR-ing defeat static signature matching.
- ›Recognize Hash Fatigue: a SHA256 denylist generates one new IOC per salted sample, producing unmanageable signature volume with near-zero overlap. Static hash detection alone is insufficient.
- ›Adopt Behavioral Clustering: group binaries by their API call sequences and instruction-ordering fingerprints rather than their final byte signature. Two salted samples share syscall-graph structure even when their hashes diverge.
- ›Build a feature vector per binary (imported symbols, syscall sequence, control-flow graph hash, string entropy distribution) and cluster — salted variants land in the same cluster as their parent builder output.
- ›Alert on the cluster, not the hash: when a new sample clusters with a known-bad family, treat it as malicious regardless of its unique SHA256.
- ▸binary.sha256 = unique (no denylist hit) BUT binary.behavioral_cluster = known-bad
- ▸binary.import_table.signature matches family template
- ▸binary.syscall_graph_hash = <known family hash>
- ▸binary.string_entropy_distribution matches builder fingerprint
- ▸binary.cfg_hash clustered with prior campaign samples
The highest-fidelity detections arise from cross-profile correlation. A service-account token read (Profile 1) followed by an anonymous RWX mmap with a ptrace redirect (Profile 3) and a burst of high-entropy DNS queries (Profile 4) is a near-certain cloud-native compromise. Engineer your detection rules to chain these signals with a short time window rather than evaluating each in isolation.




