github_enterprise_or_organization_recovery_codes_activity
Description
Detects when the Single Sign-On (SSO) recovery codes are accessed for a GitHub enterprise or organization. An adversary may attempt to access or steal SSO recovery codes in order to maintain access to their target's GitHub environment.
Query · yara_l
events:
$github.metadata.vendor_name = "GITHUB" nocase
$github.metadata.product_name = "GITHUB"
(
// GitHub enterprise events
$github.metadata.product_event_type = "business.recovery_codes_downloaded" or
$github.metadata.product_event_type = "business.recovery_codes_generated" or
$github.metadata.product_event_type = "business.recovery_codes_printed" or
$github.metadata.product_event_type = "business.recovery_codes_viewed" or
// GitHub organization events
$github.metadata.product_event_type = "org.recovery_codes_downloaded" or
$github.metadata.product_event_type = "org.recovery_codes_generated" or
$github.metadata.product_event_type = "org.recovery_codes_printed" or
$github.metadata.product_event_type = "org.recovery_codes_viewed"
)
$github.principal.user.userid = $user_id
match:
$user_id over 30m
outcome:
$risk_score = max(65)
$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:
$github