Detect ScreenConnect Installer Origin in Defender (KQL)
Detects: a ScreenConnect installer arriving from the internet, with the attacker’s cloud tenant and the lure page that sent the user there.
ATT&CK: T1219 Remote Access Tools
Works on: Microsoft Defender for Endpoint, KQL (DeviceFileEvents)
Tested on: two real ScreenConnect samples I detonated: both download origins recovered before either file ran
Full write-up: ScreenConnect RMM Abuse: The Cloud Client Gets In, The Self-Hosted One Stays
Why provenance is the first anchor
Attackers do not need to repack anything. They sign up for a ScreenConnect cloud instance, build a client, wrap it in a lure and let ConnectWise sign it for them. The binary is the vendor’s own file, so the maliciousness is in who owns the instance.
Defender’s FileOriginUrl carries the full download URL, captured at write time, before anything executes, and it survives a rename. Earliest, rename-proof and unique to one stack is what makes it the first anchor.
The query
Published verbatim from the newsletter issue.
// ScreenConnect installer arriving from the internet, with its download origin
let lookback = 30d;
DeviceFileEvents
| where Timestamp > ago(lookback)
| where FileName has "ScreenConnect" or FileOriginUrl has "screenconnect.com"
| where isnotempty(FileOriginUrl)
| project Timestamp, DeviceName, FileName, FolderPath, FileOriginUrl, FileOriginReferrerUrl, SHA256

What it catches
Two samples, two different attacker tenants, both recovered before either file executed: westville[.]screenconnect[.]com served the MSI, screamingacresmi[.]screenconnect[.]com the EXE. Three origin fields sit on each row, and they are not equal:
FileOriginUrl: the attacker’s tenant. The anchor.FileOriginReferrerUrl: the page the user was on when the download fired, hxxps://eventvenue[.]ink/ and hxxps://parvellainsurance[.]com/. Together with the first, it is the whole delivery chain from one file event.FileOriginIP: empty on every one of the 22 rows in my tenant with a populatedFileOriginUrl. It looks like a free extra column and is not one.
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
The origin fields catch stage one and are structurally blind to stage two.
The second sample’s operator pushed a second implant through the first; that one never touched a browser and has no origin to find.
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
Does a valid ConnectWise signature mean the installer is safe?
No. Both samples were validly signed by ConnectWise LLC, DigiCert Trusted G4. A filter on an untrusted signature would have dropped both outright.
Can I run this in Elastic?
Not as is. Elastic recorded the file event but has no download-origin field at all, so this anchor is Defender-only.
What does it miss?
A renamed installer pulled from a self-hosted server, and any second implant pushed through the first, which never touches a browser and so has no FileOriginUrl.