GitHub Token Activity from Unusual User Agent

Identifies the first time a GitHub token is used with a given user agent to perform a clone, push, archive download, or API request. The rule tracks new combinations of user.name and github.user_agent over a 14-day history and covers classic personal access tokens, fine-grained personal access tokens, and OAuth access tokens. A token that suddenly authenticates from a new client is a common indicator of a stolen or misused credential, since an adversary replaying a token rarely reproduces the victim's original tooling. Named credential scanners such as TruffleHog or Nord Stream are covered by a dedicated rule; this rule surfaces the broader set of first-seen clients, including generic libraries like python-requests.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2026/09/22"
  3integration = ["github"]
  4maturity = "production"
  5updated_date = "2026/09/22"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Identifies the first time a GitHub token is used with a given user agent to perform a clone, push, archive download, or
 11API request. The rule tracks new combinations of `user.name` and `github.user_agent` over a 14-day history and
 12covers classic personal access tokens, fine-grained personal access tokens, and OAuth access tokens. A token that
 13suddenly authenticates from a new client is a common indicator of a stolen or misused credential, since an adversary
 14replaying a token rarely reproduces the victim's original tooling. Named credential scanners such as TruffleHog or Nord
 15Stream are covered by a dedicated rule; this rule surfaces the broader set of first-seen clients, including generic
 16libraries like python-requests.
 17"""
 18false_positives = [
 19    """
 20    CI, git GUI, or library upgrades that change the User-Agent on an existing PAT or OAuth token. Confirm the token
 21    owner and whether the client is expected.
 22    """,
 23]
 24from = "now-9m"
 25index = ["logs-github.audit-*"]
 26language = "kuery"
 27license = "Elastic License v2"
 28name = "GitHub Token Activity from Unusual User Agent"
 29note = """## Triage and analysis
 30
 31> **Disclaimer**:
 32> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
 33
 34### Investigating GitHub Token Activity from Unusual User Agent
 35
 36This rule fires when a user (`user.name`) is observed with a `github.user_agent` that has not been seen for them in the previous 14 days while performing token-authenticated activity: a clone (`git.clone`), push (`git.push`), archive download (`repo.download_zip`), or API request (`api.request`). A new client for an established user is a strong signal that one of their tokens has been exported and replayed elsewhere, because legitimate usage tends to keep a stable toolchain. Keying novelty on the user rather than the token avoids noise from routine token creation and rotation, since a freshly minted token would otherwise always look new. Review the token owner and type (`user.name`, `github.programmatic_access_type`), the new client string (`github.user_agent`), the source address (`github.actor_ip`), and the action and resources involved (`event.action`, `github.org`, `github.repo`, `github.route`) to decide whether this is a benign client change or credential misuse. Named credential scanners are handled by a separate rule, so matches here are typically generic clients such as `python-requests`, `curl`, or custom scripts.
 37
 38### Possible investigation steps
 39
 40- Identify the token and its owner using `github.hashed_token`, `github.token_id`, `user.name`, and `github.programmatic_access_type`, and determine whether the owner recognizes the new client.
 41- Review the new `github.user_agent` value against the user agents this token and user normally present; generic libraries (for example `python-requests` or `curl`) on an interactive user's token are higher risk.
 42- Examine `github.actor_ip` and its geolocation and ASN to confirm whether the source is expected for the token owner and whether it coincides with the user's other activity.
 43- Review `event.action` and, for `api.request`, `github.route` to understand what the token accessed; for `git.clone` and `repo.download_zip`, count distinct `github.repo` values to gauge bulk collection.
 44- Pivot on the same token and actor across the surrounding window for secret-scope API calls, additional clones, or archive downloads that indicate the activity escalated to collection or exfiltration.
 45
 46### False positive analysis
 47
 48- Legitimate client or tooling changes, such as a CI image upgrade, a new git GUI, or a library bump that alters the User-Agent on an existing token. Confirm with the token owner and scope exceptions to the specific `user.name` and token where appropriate.
 49- New internal automation that reuses an existing token from a new host or runner. Validate against deployment and change-management records before dismissing.
 50
 51### Response and remediation
 52
 53- If the new client is not an approved tool for the token owner, revoke the token identified by `github.hashed_token` / `github.token_id` and require the owner to issue a new one.
 54- Review the token owner's recent GitHub audit activity for clones, archive downloads, and secret-scope API calls performed from the new user agent or IP.
 55- Rotate any secrets or deploy keys in repositories the token accessed if misuse is confirmed.
 56- Reset the owning user's credentials and review their OAuth app authorizations and PAT grants if the identity is suspected compromised.
 57- Escalate to the repository and organization owners and engage incident response per your organization's playbooks when sensitive data may have been accessed.
 58"""
 59references = [
 60    "https://securitylabs.datadoghq.com/articles/mapping-out-your-unknown-threat-hunters-guide-to-github/",
 61    "https://docs.github.com/en/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/audit-log-events-for-your-organization",
 62]
 63risk_score = 21
 64rule_id = "702f8d5d-04be-4ef6-a2be-4a3a331530ca"
 65severity = "low"
 66tags = [
 67    "Domain: Cloud",
 68    "Domain: SaaS",
 69    "Platform: GitHub",
 70    "Use Case: Threat Detection",
 71    "Tactic: Collection",
 72    "Tactic: Defense Evasion",
 73    "Tactic: Initial Access",
 74    "Data Source: Github",
 75    "Data Source: GitHub Audit Logs",
 76    "Rule Type: New Terms",
 77    "Resources: Investigation Guide",
 78]
 79timestamp_override = "event.ingested"
 80type = "new_terms"
 81
 82query = '''
 83data_stream.dataset:"github.audit" and event.category:"configuration" and user.name:* and github.user_agent:* and
 84github.hashed_token:* and
 85github.programmatic_access_type:("OAuth access token" or "Fine-grained personal access token" or "Personal access token") and
 86event.action:("git.clone" or "git.push" or "repo.download_zip" or "api.request")
 87'''
 88
 89
 90[[rule.threat]]
 91framework = "MITRE ATT&CK"
 92[[rule.threat.technique]]
 93id = "T1078"
 94name = "Valid Accounts"
 95reference = "https://attack.mitre.org/techniques/T1078/"
 96[[rule.threat.technique.subtechnique]]
 97id = "T1078.004"
 98name = "Cloud Accounts"
 99reference = "https://attack.mitre.org/techniques/T1078/004/"
100
101
102[rule.threat.tactic]
103id = "TA0001"
104name = "Initial Access"
105reference = "https://attack.mitre.org/tactics/TA0001/"
106[[rule.threat]]
107framework = "MITRE ATT&CK"
108[[rule.threat.technique]]
109id = "T1550"
110name = "Use Alternate Authentication Material"
111reference = "https://attack.mitre.org/techniques/T1550/"
112[[rule.threat.technique.subtechnique]]
113id = "T1550.001"
114name = "Application Access Token"
115reference = "https://attack.mitre.org/techniques/T1550/001/"
116
117
118[rule.threat.tactic]
119id = "TA0005"
120name = "Defense Evasion"
121reference = "https://attack.mitre.org/tactics/TA0005/"
122[[rule.threat]]
123framework = "MITRE ATT&CK"
124[[rule.threat.technique]]
125id = "T1213"
126name = "Data from Information Repositories"
127reference = "https://attack.mitre.org/techniques/T1213/"
128[[rule.threat.technique.subtechnique]]
129id = "T1213.003"
130name = "Code Repositories"
131reference = "https://attack.mitre.org/techniques/T1213/003/"
132
133
134[rule.threat.tactic]
135id = "TA0009"
136name = "Collection"
137reference = "https://attack.mitre.org/tactics/TA0009/"
138
139[rule.investigation_fields]
140field_names = [
141    "@timestamp",
142    "event.action",
143    "user.name",
144    "github.org",
145    "github.repo",
146    "github.route",
147    "github.actor_ip",
148    "github.hashed_token",
149    "github.programmatic_access_type",
150    "github.user_agent",
151    "github.token_id",
152]
153
154[rule.new_terms]
155field = "new_terms_fields"
156value = ["user.name", "github.user_agent"]
157[[rule.new_terms.history_window_start]]
158field = "history_window_start"
159value = "now-14d"

Triage and analysis

Disclaimer: This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.

Investigating GitHub Token Activity from Unusual User Agent

This rule fires when a user (user.name) is observed with a github.user_agent that has not been seen for them in the previous 14 days while performing token-authenticated activity: a clone (git.clone), push (git.push), archive download (repo.download_zip), or API request (api.request). A new client for an established user is a strong signal that one of their tokens has been exported and replayed elsewhere, because legitimate usage tends to keep a stable toolchain. Keying novelty on the user rather than the token avoids noise from routine token creation and rotation, since a freshly minted token would otherwise always look new. Review the token owner and type (user.name, github.programmatic_access_type), the new client string (github.user_agent), the source address (github.actor_ip), and the action and resources involved (event.action, github.org, github.repo, github.route) to decide whether this is a benign client change or credential misuse. Named credential scanners are handled by a separate rule, so matches here are typically generic clients such as python-requests, curl, or custom scripts.

Possible investigation steps

  • Identify the token and its owner using github.hashed_token, github.token_id, user.name, and github.programmatic_access_type, and determine whether the owner recognizes the new client.
  • Review the new github.user_agent value against the user agents this token and user normally present; generic libraries (for example python-requests or curl) on an interactive user's token are higher risk.
  • Examine github.actor_ip and its geolocation and ASN to confirm whether the source is expected for the token owner and whether it coincides with the user's other activity.
  • Review event.action and, for api.request, github.route to understand what the token accessed; for git.clone and repo.download_zip, count distinct github.repo values to gauge bulk collection.
  • Pivot on the same token and actor across the surrounding window for secret-scope API calls, additional clones, or archive downloads that indicate the activity escalated to collection or exfiltration.

False positive analysis

  • Legitimate client or tooling changes, such as a CI image upgrade, a new git GUI, or a library bump that alters the User-Agent on an existing token. Confirm with the token owner and scope exceptions to the specific user.name and token where appropriate.
  • New internal automation that reuses an existing token from a new host or runner. Validate against deployment and change-management records before dismissing.

Response and remediation

  • If the new client is not an approved tool for the token owner, revoke the token identified by github.hashed_token / github.token_id and require the owner to issue a new one.
  • Review the token owner's recent GitHub audit activity for clones, archive downloads, and secret-scope API calls performed from the new user agent or IP.
  • Rotate any secrets or deploy keys in repositories the token accessed if misuse is confirmed.
  • Reset the owning user's credentials and review their OAuth app authorizations and PAT grants if the identity is suspected compromised.
  • Escalate to the repository and organization owners and engage incident response per your organization's playbooks when sensitive data may have been accessed.

References

Related rules

to-top