When a stolen token or a departing insider copies an organisation's source code, the only record is usually a burst of git.clone, git.fetch and repo.download_zip events that nobody collected. These events sit outside the GitHub audit log web view, Git events are kept for only seven days on GitHub Enterprise Cloud, and the token fields that tell you which credential did the copying are easy to discard in a SIEM pipeline. This guide is for DevSecOps engineers and SOC analysts who need to detect bulk repository theft on GitHub: which events record clones and archive downloads, how to collect them before they expire, the fields that matter, the patterns that separate theft from normal automation, detection logic, and how to respond. For the full set of GitHub audit detections (control tampering, privilege changes, workflow abuse), see the GitHub Audit Log Detection Guide; this page goes deep on code copying only.
This is an independent guide from NHI Mgmt Group, based on GitHub's public documentation as of November 2026. It is not sponsored or reviewed by GitHub. Product features change, so confirm settings against GitHub's current documentation.
Key takeaways
- Three events tell the story. git.clone ("A repository was cloned"), git.fetch and repo.download_zip ("A source code archive of a repository was downloaded as a ZIP file") are the core signals for code copying, with git.push and repo.access as supporting context.
- Seven days is the deadline. On GitHub Enterprise Cloud, Git events are kept for seven days and appear only through the REST API, audit log streaming or JSON/CSV exports, never in the web interface or search results.
- Stream, do not poll occasionally. An enterprise audit log stream carries both audit and Git events for every organisation, so a SIEM can keep them well past the seven-day window.
- Attribute to the credential, not just the user. hashed_token, programmatic_access_type and token_scopes let you tie a clone burst to one personal access token, OAuth token or GitHub App, which is what you revoke.
- Breadth beats volume. The strongest theft signal is one actor or token touching many distinct repositories it rarely touches, often from a new IP address or user agent, outside its normal hours.
Which events record clones and downloads
The enterprise audit log event reference documents the following actions. Descriptions are GitHub's own wording.
| Event | GitHub description | Where it appears | Use in theft detection |
|---|---|---|---|
| git.clone | A repository was cloned. | REST API (include=git), streaming, JSON/CSV export only | Primary signal: full copy of a repository and its history |
| git.fetch | Changes were fetched from a repository. | REST API, streaming, export only | Ongoing copying from an existing clone; high volume from CI |
| git.push | Changes were pushed to a repository. | REST API, streaming, export only | Context: separates developers and CI from read-only harvesting |
| repo.download_zip | A source code archive of a repository was downloaded as a ZIP file. | Standard audit log (web view, search, API, streaming) | Copying without Git: browser or API archive downloads |
| repo.access | The visibility of a repository changed. | Standard audit log | Exposure by making private code public; carries previous_visibility |
| repo.transfer_outgoing | A repository was transferred to another repository network. | Standard audit log | Moving a whole repository out; carries new_nwo |
| business.audit_log_git_event_export | An export of the enterprise's Git events was created. | Standard audit log | Records who exported Git event data, useful for audit of the audit |
The reference lists archive downloads as ZIP. If you also need visibility of tarball archive downloads, test in a non-production organisation and confirm which event, if any, your data shows before writing a rule that depends on it. Copying with the GitHub CLI or an IDE still uses Git transport or the API, so it appears as git.* or API events rather than a separate action.
Enabling git events and streaming
Availability: the enterprise audit log, Git events, audit log streaming and source IP disclosure described here are documented for GitHub Enterprise Cloud enterprise accounts and are configured by enterprise owners. On GitHub Enterprise Server, Git events must be enabled in the audit log configuration. Check your plan documentation before designing collection.
GitHub's documentation describes three ways to get Git events out:
| Method | What GitHub documents | When to use it |
|---|---|---|
| Audit log streaming | The stream contains both audit events and Git events across the entire enterprise account. Destinations: Amazon S3, Azure Blob Storage, Azure Event Hubs, Datadog, Google Cloud Storage and Splunk. A health check runs every 24 hours; a misconfiguration must be fixed within six days to avoid dropped events. A paused stream buffers seven days. | Default for any enterprise that wants detection and long retention |
| REST API | GET /enterprises/{enterprise}/audit-log with include=git (or include=all), a token with read:audit_log, cursor pagination, 1,750 queries per hour per endpoint for each user and IP combination. Git events retained for seven days. | Teams without a SIEM connector for streaming; poll at least daily, ideally hourly |
| JSON/CSV export | Git event exports are recorded as business.audit_log_git_event_export. GitHub notes that UI and API searches by hashed_token do not return Git events, and that exported Git event data includes authentication fields. | One-off investigations inside the seven-day window |
Two related settings change what you can detect:
- Source IP disclosure: IP addresses are hidden by default. Enterprise owners enable them under Settings, Audit log, Settings, "Enable source IP disclosure", which applies to the enterprise and every organisation it owns; individual organisations can enable it separately. GitHub does not show IPs for actions by bots or automated systems, among other exceptions. Agree the decision with your privacy team first.
- API Request Events: enabled under Settings, Audit log, Settings, "Enable API Request Events". Only security-relevant endpoints are streamed. These help where a token enumerates repositories before copying.
Treat the streaming credential and any audit log polling token as privileged non-human identities. Prefer OpenID Connect to S3 over static keys where your destination supports it.
Key fields
GitHub lists the same fields for git.clone, git.fetch and git.push, and a similar set for repo.download_zip. The ones that drive detection:
| Field | Meaning | Detection use |
|---|---|---|
| @timestamp | Event time | Windowing, off-hours logic |
| actor, actor_id, user | Who performed the action; user can differ from actor where an agent or app acts for a user | Group by actor_id, not display name, because names change |
| repo, repo_id, repository_public | Target repository and whether it is public | Count distinct private repo_id values; ignore public repositories |
| org, org_id | Owning organisation | Spread across organisations in one enterprise is a strong signal |
| hashed_token | SHA-256 hash of the token used | Ties every event to one credential; join to your token register |
| programmatic_access_type | Authentication type, for example personal access token, OAuth token, GitHub App | Separate human web use, scripts and apps |
| token_id, token_scopes | Token identifier and scopes where applicable | Flag broad classic scopes such as repo |
| transport_protocol, transport_protocol_name | How Git connected (git.* events) | A user who always uses SSH suddenly cloning over HTTPS with a token |
| user_agent | Client string | New tool families such as a script library or unusual Git client |
| actor_is_bot, actor_is_agent, oauth_application_id | Bot, agent and OAuth app context (repo.* events) | Baseline automation separately from humans |
GitHub documents that token data covers personal access tokens, OAuth tokens and GitHub Apps acting as an installation or on behalf of a user, and that display of token data for deploy keys, SSH keys and Git events is in public preview, so confirm that your Git events actually carry hashed_token before relying on it. If you hold a leaked token, GitHub's documented method is a Base64-encoded SHA-256 digest of the raw token; if you do not, the enterprise credential inventory export gives hashed_token, credential_id and SSH key fingerprints to match against. See the GitHub Token Types and Prefixes Reference.
Bulk theft patterns
Normal Git traffic is dominated by CI runners and developers fetching the same few repositories all day. Theft looks different in shape rather than raw volume.
- Many repositories, one credential: a single hashed_token or actor_id cloning tens or hundreds of distinct private repositories in a short window, especially repositories it has never touched in 30 days.
- New place or tool: clones from an IP address, ASN, country or user_agent the credential has not used before, or a switch from SSH to HTTPS with a personal access token.
- Off-hours bursts: activity outside the person's working pattern or the integration's schedule, for example a weekend run by a token that normally only runs on weekday CI.
- Read without write: heavy git.clone with no git.push from the same actor over the following days, which is unusual for an active developer.
- Archive harvesting: repeated repo.download_zip across repositories, which avoids Git transport entirely.
- Leaver window: a sharp increase in breadth of cloning by a user in the weeks before their leaving date. Handle this with HR and legal; see the Insider Data Theft Guide.
- Dormant credential wakes up: a token or GitHub App installation with no activity for 60 days or more that starts cloning.
In ATT&CK terms this is collection from code repositories (T1213.003), often enabled by valid cloud accounts (T1078.004) or a stolen application access token (T1528).
Detection logic
Write rules against stable IDs (actor_id, repo_id, hashed_token, oauth_application_id) and suppress known automation by token hash or app ID, never by excluding all bots. The rules below are described as logic so they can be expressed in any SIEM.
| Rule | Logic | Severity | Tuning notes |
|---|---|---|---|
| Clone breadth spike | Count distinct private repo_id for git.clone plus repo.download_zip per hashed_token (fall back to actor_id) per hour; alert when above three times its 30-day hourly maximum and above an absolute floor such as 20 | High | Exclude registered CI token hashes; new tokens use the floor only |
| First-seen repositories | Share of repositories cloned in 24 hours that the credential never touched in 30 days exceeds 80% and count exceeds 10 | Medium | Raise to high if combined with a new IP |
| Cross-organisation spread | One credential clones repositories in three or more organisations within an hour | High | Few legitimate users span organisations this fast |
| New location or client | git.clone by a hashed_token from an ASN or user_agent family not seen for that token in 30 days | Medium | Needs source IP disclosure enabled |
| Off-hours clone | git.clone volume outside the actor's usual hours (from 30-day history) above a threshold | Low alone | Use as a risk score modifier, not a standalone page |
| Archive harvesting | repo.download_zip on more than five distinct repositories per actor per hour | Medium | Developers rarely download ZIPs at scale |
| Dormant credential | First git.clone by a hashed_token or app after 60 days without events | Medium | Join with your token register for owner context |
| Exposure after copying | repo.access to public or repo.transfer_outgoing within 24 hours of a breadth alert on the same actor | Critical | Page on-call immediately |
| Collection gap | No git.* events received from the stream for more than one hour during working hours | High | Detects silent stream failure inside the seven-day buffer |
Roll out in stages:
- Confirm collection: in a test organisation, clone a private repository over HTTPS with a fine-grained token, over SSH, and download a ZIP, then confirm each event, its hashed_token and transport fields arrive in the SIEM.
- Build a register of known token hashes, GitHub App IDs and OAuth app IDs with owners, starting with CI, backup and mirroring tools.
- Collect 30 days of baseline before switching on behavioural rules.
- Run new rules in report-only mode for two weeks, tune thresholds, then route the high-severity rules to on-call.
- Roll back a noisy rule by returning it to report-only and adding a specific suppression; never pause the stream to cut noise.
Measure it: track percentage of organisations whose Git events reach the SIEM (target 100%), Git event latency from action to SIEM, share of git.clone events with a hashed_token mapped to a known owner, stream gap hours per month, and time from alert to credential revocation in exercises.
Detection engineering patterns that apply here are covered in the Detection Engineering Guide.
Response
Bulk cloning cannot be undone: the aim is to stop further copying, find out exactly what left, and make the copied material less useful. Work in this order:
- Preserve: export the relevant audit and Git events immediately, because Git events expire after seven days on GitHub Enterprise Cloud. Record hashed_token values, IPs, user agents and the full list of repo_id values.
- Revoke the credential: for a fine-grained personal access token, organisation owners use Settings, Personal access tokens, Active tokens, select the token and Revoke (several can be revoked at once). GitHub notes that SSH keys created by a revoked token keep working and the token can still read public organisation resources, so remove those keys too. For classic tokens in organisations that require SAML SSO, revoke the credential authorisation through SAML access management or the "Remove a SAML SSO authorization" API. For an app, remove or suspend the installation, or revoke the OAuth app's access, and rotate its credentials.
- Contain the account: if a user account is involved, suspend or remove it, revoke its sessions and review its other tokens and keys. See How to investigate a compromised GitHub account.
- Scope: search every event for the same hashed_token and actor_id across the retention window, including repo.access and repo.transfer_outgoing, to confirm nothing was made public or moved.
- Rotate exposed secrets: assume every secret ever committed to a copied repository, including in history, is exposed, and rotate it. See How to revoke a leaked GitHub personal access token and check what it touched.
- Assess and notify: decide whether copied code contained personal data or customer material that triggers notification, and follow the Source Code Leak Response Playbook.
- Harden: restrict classic personal access tokens, set token expiry limits and require approval for fine-grained tokens with organisation access.
Where identity fits
Almost every bulk clone is performed by a credential, not a browser session: personal access tokens in scripts, OAuth tokens held by SaaS tools, GitHub App installation tokens and SSH or deploy keys. Treat each as a non-human identity with an owner, expected repositories and an expiry, and the detection rules above become precise because an unknown hash is itself the signal. See the GitHub Personal Access Tokens Security Guide.
Framework mapping
| Framework | Reference | How this guide supports it |
|---|---|---|
| NIST CSF 2.0 | DE.CM-03, DE.CM-09, DE.AE-02 | Monitoring personnel and software activity on repositories, analysing clone bursts |
| NIST SP 800-53 Rev. 5 | AU-6, AU-12, SI-4, AC-2, IA-5 | Audit generation and review, monitoring, account and authenticator management |
| CIS Controls v8.1 | Control 8 Audit Log Management | Collecting, centralising and retaining Git events |
| MITRE ATT&CK v20 | T1213.003, T1078.004, T1528 | Code repository collection, cloud account abuse, stolen application tokens |
Common failure patterns
- Relying on the web view: git.clone never appears there, so teams believe they have no clone data until an incident.
- Collecting after the fact: Git events expire in seven days; an alert from a third party two weeks later finds nothing to scope.
- Dropping token fields: SIEM parsers that keep only actor and repo lose hashed_token, so the credential to revoke cannot be identified.
- Suppressing all bots: excluding actor_is_bot or app traffic hides exactly the stolen integration tokens behind most bulk clones.
- Revoking the token but not the keys: SSH keys created by a revoked fine-grained token keep working.
- Silent stream failure: health check emails go to an owner mailbox nobody reads, and the seven-day buffer runs out.
Practitioner checklist
- Stream enterprise audit and Git events to the SIEM and to long-term storage, or poll the API with include=git at least daily.
- Verify in a test organisation that git.clone, git.fetch and repo.download_zip arrive with token and transport fields.
- Decide on source IP disclosure and API Request Events with your privacy team.
- Keep a register of token hashes, GitHub App IDs and OAuth app IDs with owners.
- Deploy breadth, first-seen, cross-organisation and exposure-after-copying rules after 30 days of baseline.
- Alert on gaps in Git event ingestion.
- Document revocation steps for fine-grained tokens, SAML-authorised classic tokens, apps and SSH keys.
- Exercise a bulk clone scenario and measure time from alert to revocation.
Standards and references
- GitHub Docs: Audit log events for your enterprise
- GitHub Docs: Streaming the audit log for your enterprise
- GitHub Docs: Using the audit log API for your enterprise
- GitHub Docs: Identifying audit log events performed by an access token
- GitHub Docs: Displaying IP addresses in the audit log for your enterprise
- GitHub Docs: Reviewing and revoking personal access tokens in your organization
- MITRE ATT&CK: Data from Information Repositories: Code Repositories
- NIST: SP 800-53 Rev. 5
Related NHI Mgmt Group resources: GitHub Audit Log Detection Guide · GitHub Personal Access Tokens Security Guide · Source Code Leak Response Playbook · Git Repository Security Guide