Query Details
id: 0416882f-ed2e-49f6-a89e-9b501c3a4243
name: Azure DevOps Agent Service Connection Modification
description: |
'As well as adding build agents to an existing pool to execute malicious activity within a pipeline an attacker could create a complete new agent pool and use this for execution. Azure DevOps allows for the creation of agent pools with Azure hosted infrastructure or self-hosted infrastructure. Given the additional customizability of self-hosted agents this detection focuses on the creation of new self-hosted pools. To further reduce false positive rates the detection looks for pools created and deleted relatively quickly (within 7 days by default), as an attacker is likely to remove a malicious pool once used in order to reduce/remove evidence of their activity.'
severity: Medium
requiredDataConnectors: []
queryFrequency: 7d
queryPeriod: 14d
triggerOperator: gt
triggerThreshold: 0
tactics:
- Persistence
- Impact
relevantTechniques:
- T1098
- T1496
query: |
AzureDevOpsAuditing
| where OperationName == "Security.ModifyPermission" and Data contains "Use Service Connection"
| project timestamp = TimeGenerated, AccountCustomEntity = ActorUPN, IPCustomEntity = IpAddress, OperationName
entityMappings:
- entityType: Account
fieldMappings:
- identifier: FullName
columnName: AccountCustomEntity
- entityType: IP
fieldMappings:
- identifier: Address
columnName: IPCustomEntity
version: 1.0.0This query is designed to detect any modifications made to the Azure DevOps Agent Service Connection. It looks for instances where the operation "Security.ModifyPermission" is performed and the data contains the phrase "Use Service Connection". The query also captures the timestamp, account name, IP address, and operation name associated with the modification. The query is run every 7 days for a period of 14 days. The severity of this detection is classified as medium. The relevant techniques for this query are T1098 and T1496, which are related to persistence and impact.

Thomas Naunheim
Released: August 23, 2023
Tables
Keywords
Operators