Microsoft Sentinel Analytic Rules
cloudbrothers.infoAzure Sentinel RepoToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

Power Apps - App activity from unauthorized geo

Back
Id7ec1e61d-f3b7-4f40-bb1a-357a63913c23
RulenamePower Apps - App activity from unauthorized geo
DescriptionIdentifies Power Apps activity from countries in a predefined list of unauthorized countries.
SeverityLow
TacticsInitialAccess
TechniquesT1078
Required data connectorsAzureActiveDirectory
PowerPlatformAdmin
KindScheduled
Query frequency1h
Query period14d
Trigger threshold0
Trigger operatorgt
Source Urihttps://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Microsoft Business Applications/Analytic Rules/Power Apps - App activity from unauthorized geo.yaml
Version3.2.0
Arm template7ec1e61d-f3b7-4f40-bb1a-357a63913c23.json
Deploy To Azure
let unauthorized_country_codes = dynamic([
    // Specify the disallowed two letter country codes
    // example: disallowed_country_codes = dynamic(["RU", "KP", "IR"])
    ]);
let query_frequency = 1h;
let query_lookback = 14d;
let powerapps_events = dynamic(["LaunchPowerApp", "AppDlpEvaluationResultChange", "UpdatePowerApp", "PublishPowerApp", "RecordScopesConsent", "CreatePowerApp", "PowerAppPermissionEdited", "PowerAppPermissionDeleted", "ImportExistingCanvasApp", "DeletePowerApp", "ImportNewCanvasApp", "PromotePowerAppVersion", "RemoveHeroApp", "DeletePowerAppVersion", "PublishSolutionCanvasAppVersion", "AdminModifyAppPermissions", "AdminModifyAppOwner", "AdminQuarantineApp", "AdminDeleteApp", "AdminSetAppBypassConsent", "PatchPowerApp"]);
PowerPlatformAdminActivity
| where TimeGenerated >= ago(query_frequency)
| where EventOriginalType in (powerapps_events)
| extend Properties = tostring(PropertyCollection)
| extend SrcIpAddr = extract(@'"enduser.ip_address","Value":"([^"]+)"', 1, Properties)
| extend SrcIpAddr = iif(SrcIpAddr startswith '::ffff:', replace_string(SrcIpAddr, '::ffff:', ''), SrcIpAddr)
| extend AppId = extract(@'"powerplatform.analytics.resource.power_app.id","Value":"([^"]+)"', 1, Properties)
| extend AppId = tolower(replace_string(AppId, '/providers/Microsoft.PowerApps/apps/', ''))
| extend
    AppName = extract(@'"powerplatform.analytics.resource.power_app.display_name","Value":"([^"]+)"', 1, Properties),
    EnvironmentId = extract(@'"powerplatform.analytics.resource.environment.id","Value":"([^"]+)"', 1, Properties),
    EnvironmentName = extract(@'"powerplatform.analytics.resource.environment.name","Value":"([^"]+)"', 1, Properties)
| summarize FirstEvent = min(TimeGenerated) by ActorName, SrcIpAddr, AppName, AppId, EnvironmentId, EnvironmentName
| join kind=inner (
    SigninLogs
    | where TimeGenerated >= ago(query_lookback)
    | where Location in (unauthorized_country_codes)
    | summarize by IPAddress, Location)
    on $left.SrcIpAddr == $right.IPAddress
| extend
    PowerAppsEntityId = 27593,
    DataverseId = 32780,
    AccountName = tostring(split(ActorName, '@')[0]),
    UPNSuffix = tostring(split(ActorName, '@')[1])
| project
    FirstEvent,
    ActorName,
    SrcIpAddr,
    Location,
    AppName,
    AppId,
    EnvironmentId,
    EnvironmentName,
    PowerAppsEntityId,
    AccountName,
    UPNSuffix
customDetails:
  Environment: EnvironmentId
  EnvironmentName: EnvironmentName
  App: AppId
queryPeriod: 14d
id: 7ec1e61d-f3b7-4f40-bb1a-357a63913c23
relevantTechniques:
- T1078
triggerOperator: gt
entityMappings:
- fieldMappings:
  - columnName: AccountName
    identifier: Name
  - columnName: UPNSuffix
    identifier: UPNSuffix
  entityType: Account
- fieldMappings:
  - columnName: SrcIpAddr
    identifier: Address
  entityType: IP
- fieldMappings:
  - columnName: PowerAppsEntityId
    identifier: AppId
  - columnName: AppName
    identifier: Name
  entityType: CloudApplication
query: |
  let unauthorized_country_codes = dynamic([
      // Specify the disallowed two letter country codes
      // example: disallowed_country_codes = dynamic(["RU", "KP", "IR"])
      ]);
  let query_frequency = 1h;
  let query_lookback = 14d;
  let powerapps_events = dynamic(["LaunchPowerApp", "AppDlpEvaluationResultChange", "UpdatePowerApp", "PublishPowerApp", "RecordScopesConsent", "CreatePowerApp", "PowerAppPermissionEdited", "PowerAppPermissionDeleted", "ImportExistingCanvasApp", "DeletePowerApp", "ImportNewCanvasApp", "PromotePowerAppVersion", "RemoveHeroApp", "DeletePowerAppVersion", "PublishSolutionCanvasAppVersion", "AdminModifyAppPermissions", "AdminModifyAppOwner", "AdminQuarantineApp", "AdminDeleteApp", "AdminSetAppBypassConsent", "PatchPowerApp"]);
  PowerPlatformAdminActivity
  | where TimeGenerated >= ago(query_frequency)
  | where EventOriginalType in (powerapps_events)
  | extend Properties = tostring(PropertyCollection)
  | extend SrcIpAddr = extract(@'"enduser.ip_address","Value":"([^"]+)"', 1, Properties)
  | extend SrcIpAddr = iif(SrcIpAddr startswith '::ffff:', replace_string(SrcIpAddr, '::ffff:', ''), SrcIpAddr)
  | extend AppId = extract(@'"powerplatform.analytics.resource.power_app.id","Value":"([^"]+)"', 1, Properties)
  | extend AppId = tolower(replace_string(AppId, '/providers/Microsoft.PowerApps/apps/', ''))
  | extend
      AppName = extract(@'"powerplatform.analytics.resource.power_app.display_name","Value":"([^"]+)"', 1, Properties),
      EnvironmentId = extract(@'"powerplatform.analytics.resource.environment.id","Value":"([^"]+)"', 1, Properties),
      EnvironmentName = extract(@'"powerplatform.analytics.resource.environment.name","Value":"([^"]+)"', 1, Properties)
  | summarize FirstEvent = min(TimeGenerated) by ActorName, SrcIpAddr, AppName, AppId, EnvironmentId, EnvironmentName
  | join kind=inner (
      SigninLogs
      | where TimeGenerated >= ago(query_lookback)
      | where Location in (unauthorized_country_codes)
      | summarize by IPAddress, Location)
      on $left.SrcIpAddr == $right.IPAddress
  | extend
      PowerAppsEntityId = 27593,
      DataverseId = 32780,
      AccountName = tostring(split(ActorName, '@')[0]),
      UPNSuffix = tostring(split(ActorName, '@')[1])
  | project
      FirstEvent,
      ActorName,
      SrcIpAddr,
      Location,
      AppName,
      AppId,
      EnvironmentId,
      EnvironmentName,
      PowerAppsEntityId,
      AccountName,
      UPNSuffix  
kind: Scheduled
triggerThreshold: 0
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Microsoft Business Applications/Analytic Rules/Power Apps - App activity from unauthorized geo.yaml
queryFrequency: 1h
requiredDataConnectors:
- dataTypes:
  - PowerPlatformAdminActivity
  connectorId: PowerPlatformAdmin
- dataTypes:
  - SigninLogs
  connectorId: AzureActiveDirectory
eventGroupingSettings:
  aggregationKind: SingleAlert
name: Power Apps - App activity from unauthorized geo
version: 3.2.0
description: Identifies Power Apps activity from countries in a predefined list of unauthorized countries.
alertDetailsOverride:
  alertDisplayNameFormat: Power Apps activity from an unauthorized location
  alertDescriptionFormat: 'User {{ActorName}} activity associated with app {{AppName}} from an unauthorized geolocation: {{Location}}'
tactics:
- InitialAccess
severity: Low
status: Available
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workspace": {
      "type": "String"
    }
  },
  "resources": [
    {
      "apiVersion": "2024-01-01-preview",
      "id": "[concat(resourceId('Microsoft.OperationalInsights/workspaces/providers', parameters('workspace'), 'Microsoft.SecurityInsights'),'/alertRules/7ec1e61d-f3b7-4f40-bb1a-357a63913c23')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/7ec1e61d-f3b7-4f40-bb1a-357a63913c23')]",
      "properties": {
        "alertDetailsOverride": {
          "alertDescriptionFormat": "User {{ActorName}} activity associated with app {{AppName}} from an unauthorized geolocation: {{Location}}",
          "alertDisplayNameFormat": "Power Apps activity from an unauthorized location"
        },
        "alertRuleTemplateName": "7ec1e61d-f3b7-4f40-bb1a-357a63913c23",
        "customDetails": {
          "App": "AppId",
          "Environment": "EnvironmentId",
          "EnvironmentName": "EnvironmentName"
        },
        "description": "Identifies Power Apps activity from countries in a predefined list of unauthorized countries.",
        "displayName": "Power Apps - App activity from unauthorized geo",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "AccountName",
                "identifier": "Name"
              },
              {
                "columnName": "UPNSuffix",
                "identifier": "UPNSuffix"
              }
            ]
          },
          {
            "entityType": "IP",
            "fieldMappings": [
              {
                "columnName": "SrcIpAddr",
                "identifier": "Address"
              }
            ]
          },
          {
            "entityType": "CloudApplication",
            "fieldMappings": [
              {
                "columnName": "PowerAppsEntityId",
                "identifier": "AppId"
              },
              {
                "columnName": "AppName",
                "identifier": "Name"
              }
            ]
          }
        ],
        "eventGroupingSettings": {
          "aggregationKind": "SingleAlert"
        },
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Microsoft Business Applications/Analytic Rules/Power Apps - App activity from unauthorized geo.yaml",
        "query": "let unauthorized_country_codes = dynamic([\n    // Specify the disallowed two letter country codes\n    // example: disallowed_country_codes = dynamic([\"RU\", \"KP\", \"IR\"])\n    ]);\nlet query_frequency = 1h;\nlet query_lookback = 14d;\nlet powerapps_events = dynamic([\"LaunchPowerApp\", \"AppDlpEvaluationResultChange\", \"UpdatePowerApp\", \"PublishPowerApp\", \"RecordScopesConsent\", \"CreatePowerApp\", \"PowerAppPermissionEdited\", \"PowerAppPermissionDeleted\", \"ImportExistingCanvasApp\", \"DeletePowerApp\", \"ImportNewCanvasApp\", \"PromotePowerAppVersion\", \"RemoveHeroApp\", \"DeletePowerAppVersion\", \"PublishSolutionCanvasAppVersion\", \"AdminModifyAppPermissions\", \"AdminModifyAppOwner\", \"AdminQuarantineApp\", \"AdminDeleteApp\", \"AdminSetAppBypassConsent\", \"PatchPowerApp\"]);\nPowerPlatformAdminActivity\n| where TimeGenerated >= ago(query_frequency)\n| where EventOriginalType in (powerapps_events)\n| extend Properties = tostring(PropertyCollection)\n| extend SrcIpAddr = extract(@'\"enduser.ip_address\",\"Value\":\"([^\"]+)\"', 1, Properties)\n| extend SrcIpAddr = iif(SrcIpAddr startswith '::ffff:', replace_string(SrcIpAddr, '::ffff:', ''), SrcIpAddr)\n| extend AppId = extract(@'\"powerplatform.analytics.resource.power_app.id\",\"Value\":\"([^\"]+)\"', 1, Properties)\n| extend AppId = tolower(replace_string(AppId, '/providers/Microsoft.PowerApps/apps/', ''))\n| extend\n    AppName = extract(@'\"powerplatform.analytics.resource.power_app.display_name\",\"Value\":\"([^\"]+)\"', 1, Properties),\n    EnvironmentId = extract(@'\"powerplatform.analytics.resource.environment.id\",\"Value\":\"([^\"]+)\"', 1, Properties),\n    EnvironmentName = extract(@'\"powerplatform.analytics.resource.environment.name\",\"Value\":\"([^\"]+)\"', 1, Properties)\n| summarize FirstEvent = min(TimeGenerated) by ActorName, SrcIpAddr, AppName, AppId, EnvironmentId, EnvironmentName\n| join kind=inner (\n    SigninLogs\n    | where TimeGenerated >= ago(query_lookback)\n    | where Location in (unauthorized_country_codes)\n    | summarize by IPAddress, Location)\n    on $left.SrcIpAddr == $right.IPAddress\n| extend\n    PowerAppsEntityId = 27593,\n    DataverseId = 32780,\n    AccountName = tostring(split(ActorName, '@')[0]),\n    UPNSuffix = tostring(split(ActorName, '@')[1])\n| project\n    FirstEvent,\n    ActorName,\n    SrcIpAddr,\n    Location,\n    AppName,\n    AppId,\n    EnvironmentId,\n    EnvironmentName,\n    PowerAppsEntityId,\n    AccountName,\n    UPNSuffix\n",
        "queryFrequency": "PT1H",
        "queryPeriod": "P14D",
        "severity": "Low",
        "status": "Available",
        "subTechniques": [],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "InitialAccess"
        ],
        "techniques": [
          "T1078"
        ],
        "templateVersion": "3.2.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}