GitHub User Access Key Created


Description

Detects when a GitHub user access key is created.

Query · python

def rule(event):

    return event.get("action") == "public_key.create"


def title(event):
    return f"User [{event.udm('actor_user')}] created a new ssh key"
Raw source GitHub User Access Key Created · Panther Python
Esc
Published by panther-labs/panther-analysis ↗, licensed under Apache 2.0 ↗. Reproduced here unmodified.
AnalysisType: rule
Filename: github_user_access_key_created.py
RuleID: "GitHub.User.AccessKeyCreated"
DisplayName: "GitHub User Access Key Created"
Enabled: true
LogTypes:
  - GitHub.Audit
Tags:
  - GitHub
  - Persistence:Valid Accounts
Reports:
  MITRE ATT&CK:
    - TA0003:T1078
Reference: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
Severity: Info
Description: Detects when a GitHub user access key is created.
Tests:
  - Name: GitHub - User Access Key Created
    ExpectedResult: true
    Log:
      {
        "actor": "cat",
        "action": "public_key.create",
        "created_at": 1621305118553,
        "p_log_type": "GitHub.Audit",
        "repo": "my-org/my-repo",
      }
  - Name: GitHub - User Access Key Deleted
    ExpectedResult: false
    Log:
      {
        "actor": "cat",
        "action": "public_key.delete",
        "created_at": 1621305118553,
        "p_log_type": "GitHub.Audit",
        "repo": "my-org/my-repo",
      }


# ------ paired body: github_user_access_key_created.py ------

def rule(event):

    return event.get("action") == "public_key.create"


def title(event):
    return f"User [{event.udm('actor_user')}] created a new ssh key"

Detection rules belong to the projects that publish them and remain under their own licenses. This site indexes and links to them; it claims no rights in them.