← Back to SOC feed Coverage →

Code Repo Exfiltration

kql MEDIUM Azure-Sentinel
CloudAppEvents
backdoorhuntingmicrosoftofficial
This rule was pulled from an open-source repository and enriched with AI. Validate in a test environment before deploying to production.
View original rule at Azure-Sentinel →
Retrieved: 2026-05-21T11:00:00Z · Confidence: medium

Hunt Hypothesis

Accounts uploading multiple code repositories to external web domains may indicate adversarial exfiltration of sensitive data, as such behavior could be used to stealthily transfer malicious or confidential code outside the organization. SOC teams should proactively hunt for this behavior in Azure Sentinel to identify potential data exfiltration attempts and mitigate risk before data is compromised.

KQL Query

let filesThreshold = 10;
let lookback = 1d;
let sourceDomainList = pack_array("github", "visualstudio", "gitlab", "bitbucket", "osdn"); //code repo url's
let excludeTargetDomainList = pack_array("office.net","visualstudio","github","gitlab","azure","dynamics","teams","sharepoint"); //exclude list for the target domain
CloudAppEvents
| where Timestamp > ago(lookback)
| where ApplicationId == 11161
| where  ActionType =~ "FileUploadedToCloud"
| project Timestamp, AccountObjectId, AccountDisplayName, extension = RawEventData.FileExtension, origin = RawEventData.OriginatingDomain, target = RawEventData.TargetDomain, file = RawEventData.ObjectId
| extend file = tostring(parse_path(tostring(file)).Filename)
| where extension =~ "zip" //filterting for zipped repos
| where origin has_any (sourceDomainList)
| where not(target has_any(excludeTargetDomainList))
| summarize uploadedFiles = dcount(file), files = make_set(file, 128) by AccountObjectId, AccountDisplayName
| where uploadedFiles > filesThreshold

Analytic Rule Definition

id: 11b8daa5-fe15-4664-b332-8f26d3c0b3a7
name: Code Repo Exfiltration
description: |
  Looks for accounts that uploaded multiple code repositories to external web domain.  
requiredDataConnectors:
- connectorId: MicrosoftThreatProtection
  dataTypes:
  - CloudAppEvents
tactics:
- Exfiltration
query: |
  let filesThreshold = 10;
  let lookback = 1d;
  let sourceDomainList = pack_array("github", "visualstudio", "gitlab", "bitbucket", "osdn"); //code repo url's
  let excludeTargetDomainList = pack_array("office.net","visualstudio","github","gitlab","azure","dynamics","teams","sharepoint"); //exclude list for the target domain
  CloudAppEvents
  | where Timestamp > ago(lookback)
  | where ApplicationId == 11161
  | where  ActionType =~ "FileUploadedToCloud"
  | project Timestamp, AccountObjectId, AccountDisplayName, extension = RawEventData.FileExtension, origin = RawEventData.OriginatingDomain, target = RawEventData.TargetDomain, file = RawEventData.ObjectId
  | extend file = tostring(parse_path(tostring(file)).Filename)
  | where extension =~ "zip" //filterting for zipped repos
  | where origin has_any (sourceDomainList)
  | where not(target has_any(excludeTargetDomainList))
  | summarize uploadedFiles = dcount(file), files = make_set(file, 128) by AccountObjectId, AccountDisplayName
  | where uploadedFiles > filesThreshold

Required Data Sources

Sentinel TableNotes
CloudAppEventsEnsure this data connector is enabled

MITRE ATT&CK Context

References

False Positive Guidance

Original source: https://github.com/Azure/Azure-Sentinel/blob/main/Hunting Queries/Microsoft 365 Defender/Exfiltration/codeRepoExfil.yaml