Query Details
# List external applications with highly privileged permissions ## Query Information #### Description The query below lists the external applications with highly privileged permissions. It is highly recommended to periodicly review the high priviliged external applications. #### Risk A third party application can be abused to steal information from your organization. ## Defender XDR ```KQL OAuthAppInfo | where AppOrigin == "External" | where PrivilegeLevel == "High" | summarize arg_max(Timestamp, *) by OAuthAppId | extend PublisherName = tostring(VerifiedPublisher.displayName), DateAdded = todatetime(VerifiedPublisher.addedDateTime) | project AppName, OAuthAppId, ServicePrincipalId, AddedOnTime, PublisherName, AppOwnerTenantId ``` ## Sentinel ```KQL OAuthAppInfo | where AppOrigin == "External" | where PrivilegeLevel == "High" | summarize arg_max(TimeGenerated, *) by OAuthAppId | extend PublisherName = tostring(VerifiedPublisher.displayName), DateAdded = todatetime(VerifiedPublisher.addedDateTime) | project AppName, OAuthAppId, ServicePrincipalId, AddedOnTime, PublisherName, AppOwnerTenantId ```
The provided KQL queries are designed to identify and list external applications that have been granted high-level permissions within an organization's environment. These applications are considered high-risk because they have significant access privileges, which could potentially be exploited by third parties to access or steal sensitive information from the organization.
Here's a simplified breakdown of what each part of the query does:
Data Source: The queries pull data from a table called OAuthAppInfo, which contains information about OAuth applications.
Filter Criteria:
AppOrigin is "External", meaning the applications are not developed internally by the organization.PrivilegeLevel of "High", indicating these applications have significant access rights.Data Aggregation:
summarize arg_max() function is used to group the data by OAuthAppId, ensuring that only the most recent entry for each application is considered based on the timestamp (Timestamp in Defender XDR and TimeGenerated in Sentinel).Data Transformation:
extend function is used to add additional information about the application's publisher, such as the publisher's name and the date the publisher was verified.Data Projection:
project function selects specific columns to display in the output: the application's name (AppName), its unique identifier (OAuthAppId), the service principal ID (ServicePrincipalId), the time it was added (AddedOnTime), the publisher's name (PublisherName), and the tenant ID of the application's owner (AppOwnerTenantId).Overall, the queries are intended to help security teams regularly review and monitor external applications with high privileges to mitigate potential security risks.

Bert-Jan Pals
Released: April 14, 2025
Tables
Keywords
Operators