Detect Exfiltration to Code Repository in Elastic Security
Adversaries may exfiltrate data to a code repository rather than over their primary command and control channel. Code repositories are often accessible via an API (ex: https://api.github.com). Access to these APIs are often over HTTPS, which gives the adversary an additional level of protection. Exfiltration to a code repository can also provide a significant amount of cover to the adversary if it is a popular service already used by hosts within the network. Tools such as Empire have been observed using GitHub for data exfiltration, leveraging the GitHub API to stage and retrieve data as part of a C2 channel.
MITRE ATT&CK
- Tactic
- Exfiltration
- Technique
- T1567 Exfiltration Over Web Service
- Sub-technique
- T1567.001 Exfiltration to Code Repository
- Canonical reference
- https://attack.mitre.org/techniques/T1567/001/
Elastic Detection Query
sequence by host.name with maxspan=5m
[network where event.type == "connection" and
network.direction == "outbound" and
(
destination.domain : ("github.com", "api.github.com", "gitlab.com", "api.gitlab.com",
"bitbucket.org", "api.bitbucket.org", "dev.azure.com",
"raw.githubusercontent.com", "gist.github.com", "codeberg.org")
) and
process.name : ("git", "git.exe", "curl", "curl.exe", "wget", "wget.exe",
"python", "python.exe", "python3", "python3.exe",
"powershell.exe", "pwsh", "pwsh.exe", "node", "node.exe",
"ruby", "ruby.exe", "perl", "perl.exe") and
network.bytes_sent > 524288]
until [process where event.type == "end" and process.name : ("git", "git.exe")]
OR
any where
(
event.category == "process" and event.type == "start" and
process.name : ("git", "git.exe") and
process.args : "push" and
process.command_line : ("*github.com*", "*gitlab.com*", "*bitbucket.org*", "*dev.azure.com*", "*codeberg.org*")
) or
(
event.category == "process" and event.type == "start" and
process.name : ("curl", "curl.exe", "wget", "wget.exe", "python", "python.exe",
"python3", "python3.exe", "powershell.exe", "pwsh", "pwsh.exe",
"node", "node.exe", "ruby", "ruby.exe") and
process.command_line : ("*api.github.com*", "*api.gitlab.com*", "*api.bitbucket.org*", "*gist.github.com*") and
process.command_line : ("*-X PUT*", "*-X POST*", "*PUT*", "*POST*", "*contents*", "*gists*",
"*requests.put*", "*requests.post*", "*Invoke-RestMethod*", "*Invoke-WebRequest*", "*upload*")
) Detects potential exfiltration to code repositories (GitHub, GitLab, Bitbucket, Azure DevOps, Codeberg) via three signals: (1) large outbound network transfers (>512KB) from scripting/git tools to code repository domains, (2) explicit git push commands referencing external repository URLs, and (3) direct REST API calls using PUT/POST methods to repository APIs from non-git tooling. Maps to MITRE ATT&CK T1567.001.
Data Sources
Required Tables
False Positives & Tuning
- Legitimate CI/CD pipelines (Jenkins, GitHub Actions runners, GitLab CI runners) performing scheduled code pushes or artifact uploads to repository APIs as part of automated deployment workflows
- Developers using IDE git integrations (VS Code, IntelliJ, PyCharm, SourceTree) to push large binary assets, design files, or datasets tracked via Git LFS to hosted repositories
- Security or DevOps teams using infrastructure-as-code tools (Terraform, Ansible) that commit state files or rendered manifests back to a central repository as part of GitOps workflows
- Data science teams using DVC (Data Version Control) or similar tools to push experiment artifacts and model weights to repository storage backends
- Open-source maintainers or automated bots (Dependabot, Renovate) creating PRs with large auto-generated changelogs or dependency lock files
Other platforms for T1567.001
Testing Methodology
Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Exfiltrate Data via GitHub Contents API Using PowerShell
Expected signal: Sysmon Event ID 1: Process Create with Image=powershell.exe and CommandLine containing 'api.github.com', 'Invoke-RestMethod', 'PUT', and 'token'. Sysmon Event ID 3: Network Connection from powershell.exe to api.github.com:443. PowerShell ScriptBlock Log Event ID 4104 with full API request including the encoded content. Network proxy logs show HTTPS PUT to api.github.com with outbound payload.
- Test 2Git Push Sensitive Files to External Repository from Command Shell
Expected signal: Sysmon Event ID 1: Multiple process creates — cmd.exe, git.exe (init), git.exe (add), git.exe (commit), git.exe (push) with CommandLine containing 'github.com' and '--force'. Sysmon Event ID 3: Network Connection from git.exe to github.com:443. Sysmon Event ID 11: File Create for stolen_creds.txt in %TEMP%\df00tech-exfil. Security Event ID 4688 if command line auditing enabled.
- Test 3Exfiltrate Data via GitHub Gist API Using curl
Expected signal: Sysmon Event ID 1: Process Create with Image=powershell.exe spawning curl.exe, CommandLine containing 'api.github.com/gists', '-X POST', and the Authorization header with PAT. Sysmon Event ID 3: Network Connection from curl.exe to api.github.com:443. Proxy logs show HTTPS POST to api.github.com/gists with outbound JSON payload.
- Test 4Automated Data Exfiltration via Python GitHub API Script
Expected signal: Sysmon Event ID 1: Process Create with Image=python.exe and CommandLine containing 'api.github.com', 'PUT', 'urllib.request', and the Authorization token. Sysmon Event ID 3: Network Connection from python.exe to api.github.com:443. No PowerShell ScriptBlock logging (Python process); look for Python audit hooks or endpoint DLP alerts on the data access pattern (reading hosts file).
References (10)
- https://attack.mitre.org/techniques/T1567/001/
- https://github.com/EmpireProject/Empire
- https://docs.github.com/en/rest/repos/contents
- https://docs.github.com/en/rest/gists/gists
- https://docs.github.com/en/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/reviewing-the-audit-log-for-your-organization
- https://learn.microsoft.com/en-us/defender-endpoint/advanced-hunting-devicenetworkevents-table
- https://learn.microsoft.com/en-us/defender-endpoint/advanced-hunting-deviceprocessevents-table
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1567.001/T1567.001.md
- https://github.com/SigmaHQ/sigma/tree/master/rules/windows/network_connection
- https://www.cisa.gov/news-events/cybersecurity-advisories/aa23-347a
Unlock Pro Content
Get the full detection package for T1567.001 including response playbook, investigation guide, and atomic red team tests.