Classify ScreenConnect Relays: Cloud vs Self-Hosted (KQL)
Detects: ScreenConnect relay callbacks, each labelled cloud/trial or self-hosted from the relay host and port the client dials.
ATT&CK: T1219 Remote Access Tools
Works on: Microsoft Defender for Endpoint, KQL (DeviceNetworkEvents)
Tested on: two real ScreenConnect samples I detonated: two cloud/trial relays on 443, one self-hosted on 8041
Full write-up: ScreenConnect RMM Abuse: The Cloud Client Gets In, The Self-Hosted One Stays
Read the relay model off a sample you did not build
The second sample did not drop one implant. It dropped two. The first was the vendor-signed client talking to ConnectWise’s own cloud relay. Roughly nine minutes later a second one appeared, pushed by hand through the first, dialling a relay the operator owns outright.
You can read which is which straight off the client’s launch parameters and network destination:
- Cloud / trial:
h=instance-<id>-relay.screenconnect.com, port 443, a*.screenconnect.comname and a valid ConnectWise signature. - Self-hosted / rogue: a bare IP or a foreign domain, typically on port 8041.
The query
Published verbatim from the newsletter issue.
// ScreenConnect relay callback: cloud (443, *.screenconnect.com) vs self-hosted (8041 or a foreign host)
let lookback = 30d;
DeviceNetworkEvents
| where Timestamp > ago(lookback)
| where InitiatingProcessFileName =~ "ScreenConnect.ClientService.exe"
| where ActionType == "ConnectionSuccess"
| extend RelayModel = case(RemoteUrl matches regex @"(?i)instance-[a-z0-9]+-relay\.screenconnect\.com", "cloud/trial",
isnotempty(RemoteUrl) and RemoteUrl !endswith "screenconnect.com", "self-hosted",
RemotePort == 8041, "self-hosted",
"review")
| project Timestamp, DeviceName, InitiatingProcessCommandLine, RemoteUrl, RemoteIP, RemotePort, RelayModel
![MDE results: RelayModel column reads cloud/trial for two instance relays on 443 and self-hosted for wonderxp[.]top on 8041](/images/screenconnect-relay-cloud-vs-self-hosted-kql/mde-screenconnect-relay-model.png)
What it catches
Sample 1 classified as cloud/trial from instance-fmjh7r-relay[.]screenconnect[.]com:443. Sample 2 gave one cloud implant, instance-n70ets-relay[.]screenconnect[.]com:443, and one self-hosted, wonderxp[.]top:8041. The RelayModel column is the whole classifier, and the command line carries the h= value that decided each one.
This is the only query in the set that tells the two implants apart. Everything else tells you a ScreenConnect client is present. The relay value tells you whose.
Get the next detection in your inbox
One lab-proven detection per issue: the attacker command, the telemetry it leaves, and the KQL / ES|QL that catches it.
You confirm on Substack in one tap.
No spam. Unsubscribe anytime.
Tuning note
A newly observed relay host is your high-severity signal.
Collect every relay and delivery host before you block any of them: the second sample named three hosts that look unrelated.
Did this query fire in your environment, or miss something? Email me what you saw: ayush@securityinbits.com (open in Gmail). I read every reply, and it decides what I test next.
Questions
How do I tell a cloud trial from a self-hosted ScreenConnect?
Cloud or trial dials instance-<id>-relay.screenconnect.com on port 443 with a valid ConnectWise signature. Self-hosted dials a bare IP or a foreign domain, typically on port 8041.
Why does the difference matter?
One of the two samples dropped both. Remediate the implant your alert fired on and the other one stays installed as a service, dialling a relay you have not seen yet.
Is there a built-in rule for a self-hosted ScreenConnect relay?
Elastic's Newly Observed ScreenConnect Host Server fired high on wonderxp[.]top, the only alert on either stack that flagged it.