When it is written
GitHub writes the record when an SSH key is added to a user account or a deploy key is added to a repository. A user adds a key under Settings > SSH and GPG keys (New SSH key) as an authentication key, a signing key or, by uploading it twice, both; DSA keys have not been accepted since March 2022. In an organization that uses single sign-on, an SSH key must also be authorized for the organization before it reaches protected content (org_credential_authorization.grant).
A deploy key is an SSH key attached to one repository rather than to a person. It is read-only by default but can be given write access, which lets it do what an organization member with admin access can do on that repository; it has no expiry date and stays active when the person who added it leaves. New organizations disallow deploy keys by default, and owners or the enterprise decide whether members may create them. The record carries the key's title, fingerprint, key and read_only; GitHub's event schema lists these fields without describing them.
How to turn it on
GitHub audit log records public_key.create calls to GitHub audit log without any setup. Vendor documentation
GitHub records the audit log of every enterprise and organization without any setup. Web events stay for 180 days in the web interface, in JSON or CSV exports and through the REST API; the web interface shows the last three months unless you search with a created date range. Git events (clone, fetch, push) are kept for seven days, are not shown in the web interface and come only from a JSON export, the REST API or a stream. The enterprise audit log aggregates the events of every organization the enterprise owns. GitHub says only owners can read an organization's log; on GitHub Enterprise Cloud a custom organization role can also carry the "View organization audit log" permission.
The 180 days are not a collection point: to keep the records and send them to a SIEM, an enterprise owner sets up audit log streaming (Enterprise > Settings > Audit log > Log streaming).
- Destinations: Amazon S3, Azure Blob Storage, Azure Event Hubs, Datadog, Google Cloud Storage and Splunk (HTTP Event Collector). GitHub sends compressed JSON files and delivers at least once, so a record can arrive twice. Streaming to more than one endpoint is in public preview.
- A stream starts empty: it carries activity only from the moment it is enabled, so turning it on during an incident does not recover earlier events.
- A paused stream keeps a seven-day buffer and sends it on resume; after three weeks paused it restarts from the current time. A health check runs every 24 hours and emails the enterprise owners about a misconfigured stream, which must be fixed within six days or events are dropped. GitHub states no delivery delay.
- API request events (
api.request) exist only in a stream and only after an owner selects Enable API Request Events; they cover security-relevant endpoints, not every request. - Source IP addresses are not shown by default. An enterprise owner enables source IP disclosure for the enterprise (it applies to new and existing events in the enterprise log and in every organization's log), or an organization owner enables it for one organization. GitHub does not show an address for actions by a bot or an automated system, for events whose recorded actor differs from who acted, or for
api.requestevents without repository context. GitHub recommends turning on streaming, API request events and IP disclosure before an incident. - The audit log REST API for an organization needs GitHub Enterprise Cloud. Reading the log through the API needs the
read:audit_logscope (the enterprise endpoints accept only a personal access token (classic)), and each endpoint allows 1,750 queries per hour for one user and IP address. The lookup command below reads the enterprise log, which includes the events of its organizations; for an organization outside an enterprise, use/orgs/<org>/audit-log. - On GitHub Enterprise Server the instance keeps its audit log indefinitely unless an enterprise owner sets a retention period.
gh api /enterprises/<enterprise>/audit-log/streamsgh api --method GET /orgs/<org>/audit-log -f per_page=5gh api --method GET /enterprises/<enterprise>/audit-log -f phrase='action:public_key.create' -f include=all -f per_page=5Fields
The operation’s own fields first, then the fields every GitHub audit log record has. Field names are the JSON paths of the record as the vendor documents it.
| Field | What it holds |
|---|---|
title | Listed for this action in GitHub's event schema without a description; by its name, the label given to the key. |
fingerprint | Listed for this action in GitHub's event schema without a description; by its name, the fingerprint of the added key. |
key | Listed for this action in GitHub's event schema without a description; by its name, the public key that was added. |
read_only | Listed for this action in GitHub's event schema without its values; by its name, whether a deploy key has read-only access. |
public_repo | Listed for this action in GitHub's event schema; by its name, whether the repository is public (GitHub does not describe it). |
actor_is_agent | Whether the actor is an AI agent. When it is true, user holds the person the agent acted for. |
Fields every GitHub audit log record has (21)
| Field | What it holds |
|---|---|
@timestamp | When the event occurred, in UTC epoch milliseconds. |
created_at | When the action occurred, in UTC epoch milliseconds (the created search qualifier filters on the time of the action). GitHub's field list for a few actions, the Git events among them, has @timestamp only. |
actionRead by 1 rule | The audited action, written as <category>.<operation> (repo.create is the create operation of the repo category). The operation this page is about. |
operation_type | The kind of operation the action is: create, access, modify, remove, authentication, transfer or restore (the operation search qualifier). Not in GitHub's field list for every action (the Git events have none). |
actor | The account that initiated the action. |
actor_id | ID of the account that initiated the action. |
actor_ip | The IP address the action came from. On GitHub Enterprise Cloud it is filled only after source IP disclosure is enabled for the enterprise or the organization; GitHub never shows it for actions by a bot. |
actor_location. | Two-letter code of the country the actor was in when performing the action. |
user | The user the action affected, when there is one. When an agent performed the action, the user the agent acted for. |
user_id | ID of the user the action affected. |
business | The enterprise the action affected, when there is one. |
business_id | ID of the enterprise the action affected. |
org | The organization the action affected, when there is one. |
org_id | ID of the organization the action affected. |
repo | The repository the action affected, as owner and name (octo-org/documentation), when there is one. |
repo_id | ID of the repository the action affected. |
repository | Owner and name of the repository where the action occurred. |
hashed_token | SHA-256 hash of the token that authenticated the action (personal access token, OAuth token, GitHub App token); absent for actions taken in the web interface. Search the log by it to find everything a leaked token did. |
programmatic_access_type | The type of authentication used for the action, when it was not taken in the web interface. |
token_scopes | The scopes of the token that authenticated the action, when it has any. |
user_agent | The client's user agent string, recorded with the event (GitHub lists the field without describing it further). |
Volume and noise
Medium: developers add SSH keys for new laptops and servers, and teams add deploy keys for automation. A deploy key with write access on a sensitive repository, a key added from an unusual location, or a new key followed by Git access over SSH from a place the account has not used is the case the detection rule and its hypothesis look for.
Keeping it manageable
- Tell user keys from deploy keys by
repo(a deploy key concerns one repository) and review deploy keys whereread_onlyshows write access first. - Compare
actor_ipandactor_location.country_codewith the account's usual locations, and follow the key'sfingerprintin later Git activity. - Consider restricting deploy keys in the organization; GitHub warns that turning them off disables existing deploy keys.
Sample event
A GitHub audit log record in the vendor’s format, with made-up values.
{
"@timestamp": 1763458212000,
"created_at": 1763458212000,
"action": "public_key.create",
"actor": "ops-admin",
"actor_id": 1000001,
"actor_ip": "203.0.113.24",
"actor_location": {
"country_code": "US"
},
"business": "corp-example",
"business_id": 4001,
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0 Safari/537.36",
"org": "corp-example-eng",
"repo": "corp-example-eng/payments-api",
"repo_id": 6001,
"title": "build-server-01",
"fingerprint": "(value not documented)",
"key": "(value not documented)",
"read_only": "(value not documented)",
"public_repo": false,
"actor_is_agent": false
}Attacks this event reveals
Detection rules that read this event: