GitHub Token Activity from Unusual User Agent
editGitHub Token Activity from Unusual User Agent
editIdentifies 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.
Rule type: new_terms
Rule indices:
- logs-github.audit-*
Severity: low
Risk score: 21
Runs every: 5m
Searches indices from: now-9m (Date Math format, see also Additional look-back time)
Maximum alerts per execution: 100
References:
Tags:
- Domain: Cloud
- Domain: SaaS
- Platform: GitHub
- Use Case: Threat Detection
- Tactic: Collection
- Tactic: Defense Evasion
- Tactic: Initial Access
- Data Source: Github
- Data Source: GitHub Audit Logs
- Rule Type: New Terms
- Resources: Investigation Guide
Version: 1
Rule authors:
- Elastic
Rule license: Elastic License v2
Investigation guide
editTriage 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, andgithub.programmatic_access_type, and determine whether the owner recognizes the new client. -
Review the new
github.user_agentvalue against the user agents this token and user normally present; generic libraries (for examplepython-requestsorcurl) on an interactive user’s token are higher risk. -
Examine
github.actor_ipand 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.actionand, forapi.request,github.routeto understand what the token accessed; forgit.cloneandrepo.download_zip, count distinctgithub.repovalues 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.nameand 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_idand 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.
Rule query
editdata_stream.dataset:"github.audit" and event.category:"configuration" and user.name:* and github.user_agent:* and
github.hashed_token:* and
github.programmatic_access_type:("OAuth access token" or "Fine-grained personal access token" or "Personal access token") and
event.action:("git.clone" or "git.push" or "repo.download_zip" or "api.request")
Framework: MITRE ATT&CKTM
-
Tactic:
- Name: Initial Access
- ID: TA0001
- Reference URL: https://attack.mitre.org/tactics/TA0001/
-
Technique:
- Name: Valid Accounts
- ID: T1078
- Reference URL: https://attack.mitre.org/techniques/T1078/
-
Sub-technique:
- Name: Cloud Accounts
- ID: T1078.004
- Reference URL: https://attack.mitre.org/techniques/T1078/004/
-
Tactic:
- Name: Defense Evasion
- ID: TA0005
- Reference URL: https://attack.mitre.org/tactics/TA0005/
-
Technique:
- Name: Use Alternate Authentication Material
- ID: T1550
- Reference URL: https://attack.mitre.org/techniques/T1550/
-
Sub-technique:
- Name: Application Access Token
- ID: T1550.001
- Reference URL: https://attack.mitre.org/techniques/T1550/001/
-
Tactic:
- Name: Collection
- ID: TA0009
- Reference URL: https://attack.mitre.org/tactics/TA0009/
-
Technique:
- Name: Data from Information Repositories
- ID: T1213
- Reference URL: https://attack.mitre.org/techniques/T1213/
-
Sub-technique:
- Name: Code Repositories
- ID: T1213.003
- Reference URL: https://attack.mitre.org/techniques/T1213/003/