T1593.003

Code Repositories

Adversaries may search public code repositories for information about victims that can be used during targeting. Victims may store code in repositories on various third-party websites such as GitHub, GitLab, SourceForge, and BitBucket. Adversaries search these repositories for sensitive data including accidentally leaked credentials, API keys, internal hostnames, technology stack details, and employee names. Groups such as LAPSUS$, HAFNIUM, and Contagious Interview have actively exploited public repository leaks to discover valid credentials and identify victims for targeting.

Microsoft Sentinel / Defender
kusto
let RepoReconTools = dynamic([
  "trufflehog", "gitleaks", "gitrob", "git-secrets", "repo-supervisor",
  "gitguardian", "detect-secrets", "noseyparker", "secretscanner",
  "git-hound", "gitallsecrets", "github-dorks", "github-search"
]);
let GitHubAPIEndpoints = dynamic([
  "api.github.com", "github.com/search", "raw.githubusercontent.com",
  "gitlab.com/api", "api.bitbucket.org"
]);
let LegitBrowsers = dynamic([
  "chrome.exe", "firefox.exe", "msedge.exe", "iexplore.exe",
  "safari", "opera.exe", "brave.exe"
]);
// Branch 1: OSINT/repo-scraping tools executed on internal endpoints
let ReconToolExecution = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName has_any (RepoReconTools)
    or ProcessCommandLine has_any (RepoReconTools)
    or ProcessCommandLine has_any ("trufflehog", "gitleaks", "gitrob", "github-dorks", "gitallsecrets")
| extend DetectionBranch = "ReconToolExecution"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
          InitiatingProcessFileName, InitiatingProcessCommandLine, DetectionBranch;
// Branch 2: Non-browser processes making bulk API calls to code repository APIs
let BulkRepoAPIAccess = DeviceNetworkEvents
| where Timestamp > ago(24h)
| where RemoteUrl has_any (GitHubAPIEndpoints)
    or RemoteIPType == "Public" and (RemoteUrl has "github" or RemoteUrl has "gitlab" or RemoteUrl has "bitbucket")
| where not (InitiatingProcessFileName has_any (LegitBrowsers))
| where InitiatingProcessFileName !in~ ("git.exe", "gh.exe", "code.exe", "devenv.exe", "rider64.exe", "idea64.exe")
| summarize RequestCount = count(),
            UniqueURLs = dcount(RemoteUrl),
            SampleURLs = make_set(RemoteUrl, 5),
            Earliest = min(Timestamp),
            Latest = max(Timestamp)
    by DeviceName, AccountName, InitiatingProcessFileName, InitiatingProcessCommandLine
| where RequestCount > 10 or UniqueURLs > 3
| extend DetectionBranch = "BulkRepoAPIAccess"
| extend Timestamp = Earliest;
// Branch 3: PowerShell or scripting engines querying GitHub search/API
let ScriptRepoQuery = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("powershell.exe", "pwsh.exe", "python.exe", "python3", "curl.exe", "wget.exe")
| where ProcessCommandLine has "github.com" or ProcessCommandLine has "api.github.com"
    or ProcessCommandLine has "gitlab.com" or ProcessCommandLine has "bitbucket.org"
| where ProcessCommandLine has_any ("search", "code", "token", "secret", "password", "api_key", "credential", "leak")
| extend DetectionBranch = "ScriptRepoQuery"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
          InitiatingProcessFileName, InitiatingProcessCommandLine, DetectionBranch;
union ReconToolExecution, ScriptRepoQuery
| sort by Timestamp desc
medium severity low confidence

Data Sources

Process: Process Creation Network Traffic: Network Connection Creation Command: Command Execution Microsoft Defender for Endpoint

Required Tables

DeviceProcessEvents DeviceNetworkEvents

False Positives

  • Security teams running authorized secret scanning tools (truffleHog, gitleaks) as part of internal security audits or CI/CD pipeline security checks
  • Developers using GitHub CLI (gh.exe) or IDE integrations (VS Code, JetBrains) that make legitimate API calls to GitHub — covered by the exclusion list but new IDE tools may need to be added
  • DevSecOps automation pipelines running repository scanning tools on build agents — these would generate bulk API calls from CI runner processes
  • Penetration testers with written authorization conducting red team exercises against the organization's own GitHub repositories
  • GitHub Actions or GitLab CI runners executing on self-hosted agents that connect to GitHub APIs as part of normal pipeline operations

Unlock Pro Content

Get the full detection package for T1593.003 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections