Detect RDP lateral movement (KQL)
Once inside, attackers often pivot over RDP from a foothold to multiple internal servers and workstations. This DeviceNetworkEvents query counts successful connections on TCP 3389 to private (internal) addresses per source host and hour, flagging hosts that reach several distinct internal targets — a fan-out pattern normal users rarely produce.
It focuses on internal RDP spread; a companion filter on public targets would instead surface RDP to or from the internet.
The query
DeviceNetworkEvents
| where Timestamp > ago(24h)
| where RemotePort == 3389 and ActionType == "ConnectionSuccess"
| where ipv4_is_private(RemoteIP)
| summarize
Targets = dcount(RemoteIP),
RemoteIPs = make_set(RemoteIP, 100),
Connections = count()
by DeviceName, InitiatingProcessAccountName, InitiatingProcessFileName, bin(Timestamp, 1h)
| where Targets >= 3
| sort by Targets descLine-by-line explanation
| where RemotePort == 3389 and ActionType == "ConnectionSuccess"Keeps only successful RDP connections. RemotePort 3389 is the RDP port and ConnectionSuccess confirms the session was established.
| where ipv4_is_private(RemoteIP)Restricts to internal destinations, the signature of lateral movement rather than remote administration from outside.
Targets = dcount(RemoteIP) ... | where Targets >= 3Counts distinct internal hosts reached per source and hour; three or more is an unusual fan-out worth investigating.
Required tables and columns
RemotePortDestination port; 3389 is RDP.RemoteIPDestination address; counted distinctly to measure fan-out.ActionTypeConnection outcome; ConnectionSuccess means a session was established.InitiatingProcessAccountNameThe account initiating the RDP connections — the pivoting identity.
MITRE ATT&CK mapping
Tuning and false positives
- Exclude jump hosts, admin bastions and monitoring servers that legitimately RDP to many systems.
- Lower the Targets threshold for sensitive segments, or add a swap to public RemoteIP to hunt internet-facing RDP instead.
Limitations
- A patient attacker who connects to one host at a time stays under the fan-out threshold; combine with DeviceLogonEvents RemoteInteractive logons.
- RDP tunnelled over a non-standard port will not match RemotePort 3389.
Related queries
References
Last reviewed 2026-11-18.