Query Details
**Identifying File Exfiltration via RDP Sessions** **Description:** The following KQL query focuses on detecting cases where files are created, modified, or otherwise accessed via RDP from another computer. Its main objective is to verify whether, during an RDP session, the connection has mapped a local disk or other redirected device — allowing us to easily identify potential cases of data exfiltration through RDP file transfer. ``` DeviceFileEvents | where FolderPath startswith "\\\\tsclient" and isnotempty(InitiatingProcessRemoteSessionIP) | extend geo_info= tostring(geo_info_from_ip_address(InitiatingProcessRemoteSessionIP).country) | project Timestamp,RemoteIP=InitiatingProcessRemoteSessionIP,geo_info,External_Device=InitiatingProcessRemoteSessionDeviceName,DeviceId,Connected_to=DeviceName, ActionType, FileName, FolderPath,InitiatingProcessVersionInfoFileDescription,RequestAccountName, RequestAccountDomain, IsInitiatingProcessRemoteSession, InitiatingProcessSessionId,ReportId ```
This KQL query is designed to detect potential data exfiltration activities during Remote Desktop Protocol (RDP) sessions. Here's a simplified explanation of what it does:
Data Source: It looks at events related to file activities on devices (DeviceFileEvents).
Filter Criteria: It specifically filters for file activities occurring in folders that start with \\tsclient, which indicates that the files are being accessed through a redirected local disk during an RDP session. Additionally, it checks that there is an IP address associated with the initiating process, confirming that the action is happening over a remote session.
Geo-Location: The query extracts geographical information (country) from the IP address of the initiating process to provide context about where the remote session is originating from.
Data Projection: It selects and displays specific details about each event, including:
Timestamp).RemoteIP).geo_info).External_Device).DeviceId).Connected_to).ActionType).FileName, FolderPath).InitiatingProcessVersionInfoFileDescription).RequestAccountName, RequestAccountDomain).IsInitiatingProcessRemoteSession, InitiatingProcessSessionId).ReportId).Overall, this query helps identify suspicious file activities that could indicate data being transferred out of a network via RDP, which is a common method for data exfiltration.

Sergio Albea
Released: October 15, 2025
Tables
Keywords
Operators