Detection rules › YARA-L
GitHub High Number Of Non Public GitHub Repositories Cloned
Detects when a user clones a high number of non-public GitHub repositories. An adversary may attempt to steal the contents of several GitHub repositories after compromising a user account.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Collection |
References
Telemetry coverage
| Platform | Record / event type |
|---|---|
| GitHub | Audit log action git.clone: Repository cloned |
Rules detecting the same action
These rules filter on the same operation.
- GitHub Access Granted To Personal Access Token Followed By High Number Of Cloned Non Public Repositories (YARA-L)
- Github Activity on a Private Repository from an Unusual IP (Elastic)
- GitHub Exfiltration via High Number of Repository Clones by User (Elastic)
- GitHub User Initial Access to Private Repo (Panther)
- High Number of Cloned GitHub Repos From PAT (Elastic)
Rule body
// Copyright 2024 Google LLC. Licensed under Apache-2.0.
rule github_high_number_of_non_public_github_repositories_cloned {
meta:
author = "Google Cloud Security"
description = "Detects when a user clones a high number of non-public GitHub repositories. An adversary may attempt to steal the contents of several GitHub repositories after compromising a user account."
rule_id = "mr_9063e681-ac7b-4fad-8bcf-08ed1ae367da"
rule_name = "GitHub High Number Of Non Public GitHub Repositories Cloned"
assumption = "Your GitHub enterprise audit log settings are configured to log the source IP address for events. Reference: https://docs.github.com/en/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/displaying-ip-addresses-in-the-audit-log-for-your-organization"
type = "alert"
severity = "High"
priority = "High"
platform = "GitHub"
data_source = "github"
mitre_attack_tactic = "Collection"
mitre_attack_technique = "Data from Information Repositories: Code Repositories"
mitre_attack_url = "https://attack.mitre.org/versions/v14/techniques/T1213/003/"
mitre_attack_version = "v14"
reference = "https://docs.github.com/en/enterprise-cloud@latest/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/audit-log-events-for-your-enterprise"
events:
$github.metadata.vendor_name = "GITHUB" nocase
$github.metadata.product_name = "GITHUB"
$github.metadata.product_event_type = "git.clone"
$github.extracted.fields["repository_public"] = "false"
$github.principal.user.userid = $user_id
$github.target.resource.name = $github_repo_name
match:
$user_id over 30m
outcome:
$github_repo_name_distinct_count = count_distinct($github_repo_name)
$risk_score = max(85)
$mitre_attack_tactic = "Collection"
$mitre_attack_technique = "Data from Information Repositories: Code Repositories"
$mitre_attack_technique_id = "T1213.003"
$event_count = count_distinct($github.metadata.id)
$principal_ip = array_distinct($github.principal.ip)
$principal_user_userid = array_distinct($github.principal.user.userid)
$principal_ip_country = array_distinct($github.principal.ip_geo_artifact.location.country_or_region)
$principal_ip_state = array_distinct($github.principal.ip_geo_artifact.location.state)
$principal_ip_city = array_distinct($github.principal.location.city)
$security_result_summary = array_distinct($github.security_result.summary)
condition:
// Customize GitHub repo count to fit your environment
$github and $github_repo_name_distinct_count > 5
}
YARA-L rule structure
Condition
Fires when at least one $github event in the 30m window and $github_repo_name_distinct_count > 5.
Events
$github
metadata.product_event_type = "git.clone"extracted.fields["repository_public"] = "false"
Match and correlation
Outcome
Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.
| Field | Expression |
|---|---|
github_repo_name_distinct_count | count_distinct($github_repo_name) |
risk_score | max(85) |
event_count | count_distinct($github.metadata.id) |
principal_ip | array_distinct($github.principal.ip) |
principal_user_userid | array_distinct($github.principal.user.userid) |
principal_ip_country | array_distinct($github.principal.ip_geo_artifact.location.country_or_region) |
principal_ip_state | array_distinct($github.principal.ip_geo_artifact.location.state) |
principal_ip_city | array_distinct($github.principal.location.city) |
security_result_summary | array_distinct($github.security_result.summary) |