Join our Newsletter — 33% off our NHI Course
Home› Guides› How to investigate a compromised GitHub account: audit…
Guide Incident Response & Forensics

How to investigate a compromised GitHub account: audit log, tokens, keys and pushed code

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 18 November 2026 12 min read
On this page

When a single developer's GitHub account is taken over, the investigation has to answer two questions quickly: which credentials the attacker now holds, and what they changed or pushed while they had access. A personal account is rarely the attacker's final target. It is a route to the repositories, packages, workflows and organisations the developer can write to, and from there to everyone who consumes that code. Password resets alone do not close that route, because personal access tokens, SSH keys, OAuth and GitHub App authorisations and deploy keys can outlive the original sign-in.

This is an account-level runbook for a security team working with the affected developer. It covers containment, the personal security log, each credential type, pushed code and the hand-off to organisation response. If the attacker has reached organisation administration, move to the GitHub Organisation Compromise Playbook, which this guide feeds into.

Key takeaways

  • Contain first, but preserve the evidence: export the personal security log before mass revocation so the timeline survives.
  • The personal security log covers the last 90 days and can be exported as JSON or CSV, filtered by action, actor, repository and date.
  • Review every credential type separately: sessions, personal access tokens, SSH keys, OAuth apps, GitHub Apps, deploy keys and webhooks. GitHub's account settings can also revoke all credentials at once.
  • Check email addresses on the account. An address added by the attacker can be used for a later password reset.
  • Treat every commit, tag, release, workflow change and package published from the account during the exposure window as untrusted until reviewed.
  • If the account has organisation write or admin access, the organisation audit log, not the personal log, is the record of what happened inside the organisation.

Signs an account is compromised

Account takeover usually comes to light through one of these routes:

  • GitHub security emails the developer did not trigger, such as a new SSH key, a new personal access token, a new OAuth authorisation or a changed email address;
  • commits, branches or tags the developer did not create, often pushed to less watched branches or as tags pointing at modified code;
  • a workflow file change, especially one adding a new action, a new step that reads secrets, or a trigger that runs on untrusted input;
  • repositories made public, forked to unfamiliar accounts or transferred;
  • a package release from a repository the developer maintains that does not match any reviewed commit;
  • a secret scanning alert or a public report showing one of the developer's tokens;
  • the developer's machine being compromised by malware, which should be presumed to have exposed browser sessions, Git credentials and SSH keys.

The last route matters most. If the endpoint is compromised, everything stored on it is exposed, not only GitHub credentials. Coordinate with endpoint response before the developer signs in again from that machine.

First hour: contain without destroying evidence

  1. Move the developer to a clean device. Do not reset credentials from a machine that may be compromised.
  2. Export the personal security log. Do this first. GitHub's security log documentation says the log lists actions from the last 90 days and can be exported as JSON or CSV from the Export menu. Store the export with your incident records.
  3. Secure the email account linked to GitHub. GitHub's guidance on preventing unauthorised access lists verifying all email addresses, because an attacker's address could allow a password reset. If the account was restricted by GitHub, it also says to secure the linked email account.
  4. Change the password and strengthen sign-in. Enable two-factor authentication if it is not on, and add a passkey, as GitHub recommends.
  5. Revoke web and mobile sessions. Under Settings, Sessions, revoke each web session and GitHub Mobile session. GitHub notes that revoking a mobile session also removes that device as a second-factor option, so check the developer still has a working second factor.
  6. Revoke credentials. Either work through each type below, or use the account setting that revokes all authorisations and credentials at once, which GitHub suggests when an account may be compromised. Record what existed before you remove it: take screenshots or notes of token names, key titles and app names first.
  7. Tell the organisation owners. They may need to revoke the user's SSO authorisations, rotate organisation secrets the user could read, and freeze releases while the review runs.

Do not assume a password change revokes tokens. GitHub's token expiration and revocation documentation lists automatic revocation when a token expires, when it is pushed to a public repository or gist, and when an OAuth token or personal access token has gone unused for a year. Explicit revocation is the reliable step.

Reading the personal security log

The personal security log is under Settings, Archives, Security log. It does not support free-text search. Instead, GitHub documents qualifiers such as operation, repo (which must include the account name, for example my-org/our-repo) and actor, with operations including access, authentication, create, modify, remove, restore and transfer. Exports include fields such as action, actor, user, actor_location.country_code, org, repo and created_at, the last in Unix epoch milliseconds.

Focus on these event categories, all listed in GitHub's documentation:

CategoryWhat it showsWhy it matters in a takeover
userAccount activitySign-ins, email and password changes, and settings changes that may mark the start of attacker control
two_factor_authentication, passkeySecond factor and passkey activityDisabling 2FA or adding a new factor gives the attacker durable access
personal_access_tokenFine-grained personal access token activityNew tokens are the most common persistence mechanism
oauth_access, oauth_authorizationOAuth tokens and app authorisationsAn authorised malicious app keeps access after a password reset
public_keySSH keys on the accountA new key allows Git pushes without the password
repoActivity on repositories you ownVisibility changes, transfers and other repository actions
codespaces, copilot, billing, payment_methodFeature and billing activityAbuse of compute or billing on the account

Build a timeline. The earliest event the developer cannot explain is your provisional start of exposure. Look for changes in actor_location.country_code around that point. Then work forwards, listing every credential created and every repository touched. Because the log covers only 90 days, an intrusion discovered late may have started before the earliest record; note that limit in your report.

Reviewing each credential type

Personal access tokens

List both fine-grained tokens and classic tokens in developer settings. For each, record name, creation date, expiry, scopes or repository access and last use, then revoke anything the developer does not recognise or did not create before the exposure window. For tokens the developer does recognise but which were stored on a compromised machine, revoke and reissue them too. Our guide How to revoke a leaked GitHub personal access token and check what it touched covers tracing what a token accessed.

SSH keys

GitHub's SSH key review page describes listing keys under Settings, SSH and GPG keys. To check which keys are genuinely the developer's, run ssh-add -l -E sha256 on a trusted machine and compare fingerprints; the keys on GitHub should match the keys on the developer's computer. GitHub's guidance is to delete any key you do not recognise immediately and contact GitHub Support. Review signing keys on the same page: an attacker-added signing key can make malicious commits appear verified. The SSH Key Compromise Response Playbook covers keys that were also used outside GitHub.

OAuth apps and GitHub Apps

Under Applications settings, review authorised OAuth apps, authorised GitHub Apps and installed GitHub Apps. GitHub recommends revoking unauthorised or unfamiliar access. Revoking an authorisation revokes its associated tokens. Pay attention to apps authorised during the exposure window with broad repository or organisation scopes.

Deploy keys and webhooks

For repositories the developer owns or administers, GitHub's guidance says to confirm no new deploy keys were created, since they could give outside servers access to the project, and to review webhooks, because they could let an attacker intercept pushes. Check repository collaborators for additions too.

Credentials the account could read

The attacker may also have obtained secrets the developer could see: Actions secrets in repositories the developer administers, Codespaces secrets, package registry tokens and cloud credentials in local Git configuration or environment files. Rotate any of these the developer had access to, prioritising credentials with production or publishing rights.

Reviewing pushed code and releases

The supply chain risk sits here. For every repository the account can write to, review activity in the exposure window:

  • Commits and branches. List commits authored or pushed by the account across all branches, not only the default branch. GitHub's guidance includes reviewing recent commits and collaborators on each repository.
  • Tags and releases. Check whether any tag was created or moved, and whether release assets were added or replaced. Consumers who pin to tags will pull a moved tag without warning.
  • Workflow files. Diff everything under .github/workflows and any composite actions. Look for new third-party actions, unpinned references, steps that print or send secrets, and new triggers such as pull_request_target.
  • Branch protection and rulesets. Check whether protections were weakened, then restored, during the window.
  • Packages. Compare published package versions on npm, PyPI, container registries or GitHub Packages against reviewed commits. A release that does not trace to a reviewed commit should be withdrawn and consumers notified.
  • Repository visibility and transfers. GitHub's guidance highlights private repositories made public and repositories transferred.

Commit signature status is a useful filter but not proof. If signing keys may have been exposed, verified commits from the window still need review.

Organisation impact and hand-off

The personal security log records the user's own account and owned repositories. Actions inside organisations are recorded in each organisation's audit log, which organisation owners can search by the user as actor. Ask owners to search for repository creation and deletion, permission changes, secret access, workflow runs triggered by the account, new apps installed and changes to organisation settings. The GitHub Audit Log Detection Guide lists the events worth alerting on.

Organisation owners can also act on their side: enterprise and organisation owners can revoke the user's SSO authorisations, and for Enterprise Managed Users can delete credentials, as GitHub's revocation documentation notes. If any finding shows organisation-level change, such as new owners, app installations or ruleset changes, escalate to the organisation compromise playbook rather than continuing at account level.

Recovery and closing the incident

  1. Confirm every credential on the account was either created after containment on a clean device or reviewed and kept with a reason.
  2. Reissue tokens as fine-grained, short-lived and limited to the repositories needed. See the GitHub Personal Access Tokens Security Guide.
  3. Generate new SSH and signing keys on the clean device, protected with a passphrase or hardware key.
  4. Revert or rebuild anything pushed by the attacker, and republish clean package versions with a clear advisory.
  5. Check the email account, password manager and any single sign-on identity for the same intrusion.
  6. Write up the timeline, the exposure window, the 90-day log limit if relevant, and what was rotated.
  7. Feed lessons into controls: phishing-resistant sign-in, token expiry policies, push protection and release protections.

Preparing before the next takeover

Most of the time lost in account investigations goes on finding out what normal looked like. A little preparation shortens that work considerably:

  • Keep an inventory of the personal access tokens, SSH keys and app authorisations that developers with release or admin rights are expected to hold, so unexpected entries stand out.
  • Stream organisation audit logs to your SIEM, because the personal security log is only kept for 90 days and is held in each user's own settings.
  • Require two-factor authentication or passkeys for organisation members, and prefer fine-grained tokens with expiry dates.
  • Protect release tags and default branches with rulesets, so a single compromised account cannot move a tag or bypass review on its own.
  • Write down who in the organisation can revoke SSO authorisations and freeze releases out of hours.

Common failure patterns

  • Revoking everything before exporting the log. The timeline is harder to rebuild once tokens and keys are gone and nobody recorded them.
  • Resetting the password and stopping. Tokens, SSH keys and app authorisations continue to work.
  • Ignoring the email account. An attacker address or a compromised mailbox allows a second takeover by password reset.
  • Reviewing only the default branch. Malicious code is pushed to a tag or a feature branch that a workflow or package build uses.
  • Trusting verified commits. An attacker-added signing key makes malicious commits show as verified.
  • Not rotating secrets the developer could read. The attacker keeps cloud or registry access after GitHub access is cut.
  • Letting the developer back in from the same machine. Malware on the endpoint steals the new credentials.

Practitioner checklist

  • Move the developer to a clean device before any reset.
  • Export the personal security log as JSON or CSV and store it with the incident.
  • Verify and secure all email addresses on the account.
  • Change the password, enable 2FA and add a passkey.
  • Revoke web and mobile sessions.
  • Record, then revoke, unrecognised personal access tokens, SSH keys, signing keys and app authorisations.
  • Check deploy keys, webhooks and collaborators on owned repositories.
  • Review commits, tags, releases, workflows and packages in the exposure window.
  • Rotate secrets the account could read.
  • Ask organisation owners to search their audit logs and revoke SSO authorisations.
  • Escalate to the organisation playbook if any organisation-level change is found.

Standards and references

Related NHI Mgmt Group resources: GitHub Organisation Compromise Playbook · GitHub Audit Log Detection Guide · How to revoke a leaked GitHub personal access token and check what it touched · GitHub Personal Access Tokens Security Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.