STUN is the most boring protocol on your network. Every video call, every browser tab that touches WebRTC, every game lobby that needs to punch through NAT fires a tiny UDP packet at a public server and asks one question: what address do I look like from out there. The server answers and everyone forgets the exchange happened.
That forgetting is the vulnerability. On November 25, NSFOCUS published a risk alert on a new variant of the Cling remote-access botnet, which CNCERT watched spread between November 9 and 20 to roughly 5,600 Linux servers and IoT devices, with up to 2,730 active on a single day. The new trick is simple and a little elegant: Cling hides its command channel inside STUN traffic and dresses the commands up as replies from Google's STUN servers.
Your firewall has been trained for years to wave that traffic through. So the hunt has to happen somewhere else: on the hosts, and in the shape of the packets.
How Cling Talks Through a Protocol Nobody Reads
The NSFOCUS write-up is specific enough to build detections from, so here is the mechanism in plain terms.
Each bot carries 13 server addresses encrypted with ChaCha20. Twelve are real public STUN servers. One belongs to the operator. The bot sends a standard STUN Binding Request to all 13 over UDP and learns its NAT-mapped public port, exactly the way a browser would.
Then it sends a malformed "registration" message to all 13. The legitimate servers discard it as junk. The operator's server reads it, records the bot's mapped port and an infection tag, and now knows where to aim.
Commands arrive at that mapped port with a spoofed source address belonging to a Google STUN server. They ride inside the 12-byte STUN Transaction ID: the first 2 bytes act as an identification marker, the remaining 10 carry encrypted task parameters. Four command types exist: run a shell command, download and execute a program (binaries are named with an alya prefix, such as alya.x86_64 and alya.mipsel), kill a task, and swap one of the 13 addresses for a new one.
The variant also shed weight. Scanning, exploitation, proxying and DDoS modules are gone. What remains is a quiet access tool built to deliver someone else's payload later. A botnet that stops doing loud things is a botnet that intends to stay.
Persistence is old school. Cling appends itself to /etc/inittab, /etc/init.d/rcS and /etc/rc.d/rc.boot, replaces the wget binary, holds a single-instance lock on port 58346, and writes -1000 into /proc/self/oom_score_adj so the kernel's out-of-memory killer never picks it.
Every one of those choices leaves a mark. A spoofed reply needs a request it can pretend to answer, and a fixed marker in a field designed to be random is a fingerprint. Persistence that edits text files can be read with grep.
Host Checks That Run on BusyBox
Start where the malware has to live. The script below is POSIX sh, so it runs on a cheap camera or router shell with BusyBox as well as on a Debian server. It checks every host-side indicator NSFOCUS listed.
#!/bin/sh # cling_check.sh: host-side checks from the NSFOCUS Cling advisory (Nov 25, 2026). IOCS="84ced85e53bc326f8b11115ae4bc24a7 65d94c9dddea41ef4690f193fbc54ec3 92533318fb6f0365eefd25090e7df146 be719987bf96fa16ac98b7c2a280cc74 e37b94dfcaa56924142c344edcb3652a 79de772daa218e25a812ecbedca08476 606f2fee6fa4b3ca556187c9ee709f3d b672e3238742504faa93d5a7cb8d0ea0 dc11a0e68e5235e36480ddf14f08afbe 76021af2d82cade790dd87d3af0f80c9 16ef618bf21a3322c6793be87d553f08 fe35c5b3cfa118fdf8e1afb9a134e084" echo "== startup files" for f in /etc/inittab /etc/init.d/rcS /etc/rc.d/rc.boot; do [ -f "$f" ] && grep -n 'alya' "$f" /dev/null done echo "== single-instance lock port 58346" (ss -lntup 2>/dev/null || netstat -lntup 2>/dev/null) | grep ':58346 ' echo "== processes pinned at oom_score_adj -1000" for f in /proc/[0-9]*/oom_score_adj; do [ "$(cat "$f" 2>/dev/null)" = "-1000" ] || continue pid=${f#/proc/}; pid=${pid%%/*} echo "$pid $(cat /proc/$pid/comm 2>/dev/null) $(readlink /proc/$pid/exe 2>/dev/null)" done echo "== wget" w=$(command -v wget) if [ -n "$w" ]; then ls -l "$w" if command -v dpkg >/dev/null 2>&1; then dpkg -V wget | grep 'bin/wget' elif command -v rpm >/dev/null 2>&1; then rpm -V wget fi fi echo "== alya* files and IOC hashes" for f in $( { find / -xdev -name 'alya*' -type f 2>/dev/null; [ -n "$w" ] && readlink -f "$w"; } ); do h=$(md5sum "$f" | cut -d' ' -f1) case "$IOCS" in *"$h"*) echo "IOC MATCH $h $f";; *) echo "seen $h $f";; esac done A clean Debian box prints mostly section headers and one seen line for the stock wget hash. Three details decide how you read the rest.
The oom_score_adj section will not come back empty on a systemd machine. systemd-udevd and a handful of other daemons legitimately pin themselves at -1000. The value of the list is the exe column: anything running from /tmp, /var/run, a deleted path or a filename that looks like an architecture suffix deserves your full attention.
The wget check depends on the platform. On a full distro, dpkg -V compares installed files against the package database, and a 5 in the third column of the output means the checksum changed. Minimal images complain about missing docs, which is why the script filters for the binary itself. On BusyBox devices, wget is normally a symlink to /bin/busybox. A regular file sitting where that symlink should be is a strong signal by itself, before any hash comparison.
The hash list will go stale. Samples rotate. The startup-file and lock-port checks age far better than MD5s because they describe behavior, so treat an IOC hit as confirmation and a miss as nothing.
Watch the Wire Where STUN Should Not Exist
Host checks assume you can get a shell. Half the devices Cling targets give you a web UI and a prayer. For those, you watch the network.
Capture from a box that sees the traffic. On a home lab that usually means a managed switch with port mirroring, such as the TP-Link TL-SG105E [AFFILIATE: TP-Link TL-SG105E], feeding a Raspberry Pi 5 [AFFILIATE: Raspberry Pi 5] sensor. A router you control works too. Then let tshark do the dissection and print exactly the fields that matter:
$ sudo tshark -i eth0 -l -f "udp port 3478 or udp port 19302" \ -T fields -E separator=, -E occurrence=f \ -e frame.time_epoch -e ip.src -e ip.dst -e udp.srcport -e udp.dstport \ -e stun.type -e stun.id -l flushes each line immediately so a downstream script sees packets as they arrive. Port 3478 is the IANA STUN port that NSFOCUS names for the registration traffic; 19302 is the port Google's public STUN servers answer on, and plenty of software hardcodes it. stun.type prints the message type (0x0001 for a Binding Request, 0x0101 for a success response) and stun.id prints the 12-byte Transaction ID as 24 hex characters.
The detection rests on a baseline. A laptop on a video call talks to one or two STUN servers, uses random Transaction IDs, and receives replies only from servers it asked. A thermostat, an NVR or a headless Debian VM should talk STUN to nobody at all. Cling breaks all three expectations at once.
A Watcher That Encodes Those Three Expectations
This script reads the tshark stream and emits one JSON alert per finding:
#!/usr/bin/env python3 """stun_watch.py: flag STUN behavior that a headless box has no business producing.""" import argparse, csv, ipaddress, json, sys from collections import Counter, defaultdict STUN_PORTS = {3478, 19302} def parse_args(): p = argparse.ArgumentParser() p.add_argument("csv", nargs="?", default="-") p.add_argument("--home", default="10.0.0.0/8,172.16.0.0/12,192.168.0.0/16") p.add_argument("--allow", default="", help="comma list of hosts allowed to speak STUN") p.add_argument("--fanout", type=int, default=4, help="distinct STUN peers per window") p.add_argument("--window", type=float, default=300.0) p.add_argument("--marker-min", type=int, default=6, help="requests before prefix test") return p.parse_args() def main(): a = parse_args() home = [ipaddress.ip_network(n) for n in a.home.split(",")] allow = set(filter(None, a.allow.split(","))) is_home = lambda ip: any(ipaddress.ip_address(ip) in n for n in home) src = sys.stdin if a.csv == "-" else open(a.csv, newline="") peers = defaultdict(dict) # host -> {peer: last outbound time} prefixes = defaultdict(Counter) # host -> Counter(first 2 bytes of txn id) fired = set() def alert(kind, host, ts, **extra): key = (kind, host, extra.get("peer")) if key not in fired: fired.add(key) print(json.dumps({"ts": ts, "alert": kind, "host": host, **extra}), flush=True) for row in csv.reader(src): if len(row) < 7: continue ts, s, d, sp, dp, mtype, tid = row[:7] ts, sp, dp = float(ts), int(sp or 0), int(dp or 0) if is_home(s) and dp in STUN_PORTS and s not in allow: peers[s][d] = ts recent = [p for p, t in peers[s].items() if ts - t <= a.window] if len(recent) >= a.fanout: alert("STUN_FANOUT", s, ts, peers=len(recent)) if mtype == "0x0001" and len(tid) == 24: prefixes[s][tid[:4]] += 1 top, n = prefixes[s].most_common(1)[0] total = sum(prefixes[s].values()) if total >= a.marker_min and n / total >= 0.8: alert("TXN_ID_MARKER", s, ts, prefix=top, share=round(n / total, 2)) elif is_home(d) and sp in STUN_PORTS and d not in allow: last = peers[d].get(s) if last is None or ts - last > 60: alert("UNSOLICITED_STUN", d, ts, peer=s, dport=dp) if __name__ == "__main__": main() STUN_FANOUT fires when one internal host talks to four or more distinct STUN peers inside five minutes. Cling hits 13. A browser rarely needs more than two.
TXN_ID_MARKER looks at the first two bytes of every Binding Request ID from a host. RFC 8489 wants those 96 bits to be random, so two shared leading bytes across 80% of requests should essentially never happen by accident. Cling's design puts a fixed marker exactly there.
UNSOLICITED_STUN catches the delivery step: a "response" from port 3478 or 19302 arriving at an internal host from an address that host never queried in the last minute. Spoofing a Google source buys the operator a pass from human eyes. It buys nothing from a script that remembers who asked whom.
Pipe it live:
$ sudo tshark -i eth0 -l -f "udp port 3478 or udp port 19302" -T fields \ -E separator=, -E occurrence=f -e frame.time_epoch -e ip.src -e ip.dst \ -e udp.srcport -e udp.dstport -e stun.type -e stun.id 2>/dev/null \ | python3 stun_watch.py --allow 192.168.1.20,192.168.1.21 >> stun_alerts.jsonl The --allow list is the machines that legitimately make calls. Everything else that speaks STUN is a question.
Prove the Detector Before You Trust It
Running real Cling samples on your bench is a bad idea, and waiting for an infection to test your alerting is a worse one. Build a fixture instead. This scapy script writes a pcap with one normal laptop and one host that behaves the way the NSFOCUS report describes, using documentation address ranges only:
#!/usr/bin/env python3 import os, struct from scapy.all import IP, UDP, Raw, wrpcap COOKIE = 0x2112A442 def stun(msg_type, tid, body=b""): return struct.pack("!HHI", msg_type, len(body), COOKIE) + tid + body pkts, t = [], 1764151200.0 def add(src, dst, sport, dport, payload, dt=0.5): global t t += dt p = IP(src=src, dst=dst) / UDP(sport=sport, dport=dport) / Raw(payload) p.time = t pkts.append(p) for server in ("203.0.113.10", "203.0.113.11"): # laptop: normal WebRTC tid = os.urandom(12) add("192.168.1.20", server, 50000, 3478, stun(0x0001, tid)) add(server, "192.168.1.20", 3478, 50000, stun(0x0101, tid), 0.05) servers = [f"198.51.100.{i}" for i in range(1, 13)] # camera: Cling-shaped for s in servers: tid = b"\xb0\x0b" + os.urandom(10) add("192.168.1.50", s, 41000, 3478, stun(0x0001, tid), 0.2) add(s, "192.168.1.50", 3478, 41000, stun(0x0101, tid), 0.05) for s in servers: # malformed "registration" add("192.168.1.50", s, 41000, 3478, stun(0x0001, b"\xb0\x0b" + os.urandom(10), b"\x00" * 3), 0.2) add("203.0.113.99", "192.168.1.50", 3478, 41000, # spoofed "reply" stun(0x0101, b"\xb0\x0b" + os.urandom(10)), 120) wrpcap("fixture.pcap", pkts) Replay it through the same pipeline with -r instead of -i:
$ tshark -r fixture.pcap -T fields -E separator=, -E occurrence=f \ -e frame.time_epoch -e ip.src -e ip.dst -e udp.srcport -e udp.dstport \ -e stun.type -e stun.id 2>/dev/null | python3 stun_watch.py {"ts": 1764151202.05, "alert": "STUN_FANOUT", "host": "192.168.1.50", "peers": 4} {"ts": 1764151202.55, "alert": "TXN_ID_MARKER", "host": "192.168.1.50", "prefix": "b00b", "share": 1.0} {"ts": 1764151326.5, "alert": "UNSOLICITED_STUN", "host": "192.168.1.50", "peer": "203.0.113.99", "dport": 41000} Three alerts on the camera, silence on the laptop. That output came from tshark 4.2.2 against this synthetic file, which is the honest limit of the claim: it proves the logic, and real Cling traffic may differ in timing or in how cleanly the malformed registration frames dissect. The fixture pattern scales, though. Every time a new report describes a command channel, you write the packets the report describes, replay them, and find out whether your sensor would have said anything. If you want that habit formalized, the Command Infrastructure Lab ($55) is built around exactly this loop: it models command-channel behavior with test fixtures and synthetic data, defines which logs a detection should produce before you write it, and walks through validating telemetry and response procedures in an isolated lab. That is the step after this section, when one fixture becomes a library of them.
If you already run Suricata, a coarse network rule covers the fan-out for hosts outside your call-making allowlist:
alert udp $HOME_NET any -> $EXTERNAL_NET 3478 (msg:"LOCAL STUN fan-out from non-WebRTC host"; threshold: type both, track by_src, count 12, seconds 60; classtype:policy-violation; sid:9003478; rev:1;) Narrow $HOME_NET for this rule to the device VLAN, or the first Zoom call trips it. Then numbpill3d/20-soc-lite, the free Suricata starter, sorts the result for you with ./triage.sh /var/log/suricata/eve.json.
Make the Box Watch Itself Every Night
A hunt you run once is a story you tell. A hunt that runs every night is a control.
The two scripts above split cleanly into a nightly job and a resident one. cling_check.sh belongs in cron on every host that has a shell, with its output saved and compared against the previous run:
$ crontab -l 17 3 * * * /usr/local/bin/cling_check.sh > /var/log/cling/$(date +\%F).txt 2>&1 $ diff /var/log/cling/2026-11-25.txt /var/log/cling/2026-11-26.txt A diff that prints nothing is the result you want. A new -1000 process, a new line in rcS or a wget that stopped being a symlink is the whole alert, and you did not need a model to tell you that.
stun_watch.py belongs on the sensor under systemd, appending JSON lines. Somebody still has to read those lines, and that is where most home-lab detection quietly dies: alerts land in a file that nobody opens until the incident is already old. OpenClaw Black: Local Log-Watching Agent with Reviewed Alerts ($40) is the build for this exact gap. It sets up a local watcher for logs and service health on a Raspberry Pi, starts with deterministic checks like the diff above before adding any model-assisted reasoning, and keeps state and memory local with alerts you review rather than actions it takes on its own. Feed it stun_alerts.jsonl and the nightly diffs and you have a sensor that tells you something in plain language the morning after.
Then do the boring part that actually closes the door. NSFOCUS ties the current spread mainly to an old Realtek SDK bug and lists half a dozen earlier CVEs from previous waves, most of them years old. Inventory every device that runs its own firmware, patch what still gets patches, and put the rest on a VLAN that cannot originate STUN at all. A camera has no reason to discover its public address. Take the question away and the channel has nothing to ride.