# 0% GPU utilization: How SANSAR hides Linux cryptomining

Unauthenticated Ray job agent gave root; attacker deployed SANSAR Tor-controlled cryptominer orchestrator, ftrace rootkit, fake NVML GPU telemetry and Ethereum-C2 backdoor.

- Payout: Real-world hack
- Severity: high
- Program: Ray
- Analysis by: Salim Bitam
- Disclosed: 2026-11-12
- Write-up quality: 8/10
- Original: https://www.elastic.co/security-labs/threat-command/sansar-linux-cryptomining-malware
- Library page: https://bugbountylibrary.com/r/blog%3Aelastic-co-security-labs-threat-command-sansar-linux-cryptomining-malware
- Tags: area:cloud domain:cloud domain:infra impact:integrity impact:privesc impact:rce kind:incident platform:threat-intel sev:high tech:linux tech:python technique:reverse-engineering technique:source-review vuln:auth-bypass vuln:misconfiguration vuln:privilege-escalation vuln:rce

**Target:** Exposed Ray Jobs API job agent on Linux GPU hosts
**Root cause:** Ray's job agent accepted job submissions without authentication while only the dashboard was bound to loopback, letting remote attackers execute commands as the Ray session owner and escalate to root.
**Steps:**
1. Probe exposed Ray job agent on the internet (dashboard bound to loopback, agent reachable)
2. Submit a job running `nvidia-smi` and exfiltrate GPU inventory to an external server
3. Submit a Python reverse-shell job connecting to an external listener
4. Add SSH key to the Ray session account's authorized_keys for persistence
5. After root: stage toolkit in /opt/vadi_, build acpi_thermal_mgr.ko via DKMS, add initramfs loader
6. Replace libnvidia-ml.so.1 with NVML wrapper via `make` followed by `make install`; register netns as systemd service
7. Start miners via C2 MinerStart: tilki (SRBMiner-MULTI) for GPU, kurt (XMRig) for CPU
**How found:** Elastic Security Labs tracked intrusion REF3364 from Ray logs showing external probes Oct 22, GPU inventory exfil Oct 24, and reverse-shell job Oct 25; analyzed collected binaries, decoded the 62-byte onion C2 (ROR8 by (i%7)+1 then XOR with 32-byte mask), and reviewed recovered source for the rootkit and NVML hook.
**Exploitation:** Attacker used unauthenticated Ray job submissions to run commands, obtained a reverse shell as the Ray session user, added an SSH key, escalated to root, then deployed SANSAR (Tor C2 via Arti/Lyrebird bridges), a kernel rootkit hiding processes/files/sockets, an NVML wrapper reporting 0% GPU utilization with randomized temp/power, and netns backdoor resolving C2 IP from Ethereum contract 0x43eb291f56688c63c93e8a93c4591fc997cf6349 (selector 0x6ded96e7) then connecting on TCP 8080 for SHELL commands. Miners diverted CPU/GPU compute to external pools.
**Escalation:** Chained unauthenticated Ray job execution to reverse shell, SSH key persistence, root, then layered rootkit + fake telemetry + Tor C2 + blockchain dead-drop backdoor to sustain mining undetected.
**Insight:** Exposed Ray job agents are a direct RCE path even when the dashboard is loopback-only; check for modified libnvidia-ml.so.1 and DKMS-built modules when GPU utilization reads 0% but power draw persists.

## Proof of concept (copied exactly from the original report)

**getdents64 hook hiding directory entries**

```
offset = 0; prev = NULL;
while (offset < ret) {
    cur = (void *)kdirent + offset;
    if (should_hide_dirent(cur->d_name, strlen(cur->d_name))) {
        if (!prev) { ret -= cur->d_reclen; memmove(cur, (void *)cur + cur->d_reclen, ret - offset); continue; }
        prev->d_reclen += cur->d_reclen;
    } else { prev = cur; }
    offset += cur->d_reclen;
}
copy_to_user(udirent, kdirent, ret);
```

**openat hook returning ENOENT for hidden paths**

```
fn[PATH_MAX - 1] = '\0';
if (is_proc_path_hidden(fn)) { kfree(fn); return -ENOENT; }
bn = strrchr(fn, '/'); bn = bn ? bn + 1 : fn;
if (is_file_hidden(bn, strlen(bn))) { kfree(fn); return -ENOENT; }
kfree(fn);
return orig_openat(regs);
```

