Skip to content
Code & CI · Secret guide

Leaked GitHub OAuth Access Token: what to do in the first hour

Critical severityDetected onlyLast verified · 4 min read

A GitHub OAuth access token, which starts with gho_, is issued to an application that you authorized, and it acts as you within the scopes you granted that application: reading private repositories, pushing code, or editing workflows, depending on the scopes. A refresh token, which starts with ghr_, is the long-lived companion of an expiring user token and can be exchanged for new access tokens until it is revoked or expires. Both are as sensitive as a password for what they cover. Revoke the authorization first, then investigate.

Check your GitHub account for leaked secrets — free

Provider
GitHub
Severity
Critical
Impact
Source code and build access
Checked live by LeakWatch
No
Revoke at
GitHub

What a GitHub OAuth access token looks like

Both tokens are recognizable by their prefix, followed by letters and digits:

gho_XXXX…XXXX   OAuth access token (masked, usually 36 characters after the prefix)
ghr_XXXX…XXXX   refresh token (masked, much longer body)

The gho_ family is not a personal access token. Those start with ghp_ or github_pat_, and are covered in the personal access token guide. Other GitHub prefixes include ghu_ for a GitHub App user token and ghs_ for an installation token. OAuth tokens appear in the output of the GitHub command-line tool, in files such as ~/.config/gh/hosts.yml, in GH_TOKEN or GITHUB_TOKEN variables, and in the credentials of tools that sign in with GitHub. A refresh token only exists for apps that use expiring user tokens, and it is stored by the application next to its access token.

How GitHub OAuth tokens get leaked

  • Command-line configuration. A hosts.yml or credential file from the GitHub CLI copied into a repository, a dotfiles project or a container image.
  • Third-party app databases. An application you signed into stores tokens in its own database, which is then breached or published.
  • Environment files and CI. A GH_TOKEN value committed in a .env, or printed by a debug step in a public pipeline.
  • Browser and mobile code. A client that completes the OAuth flow in the front end and writes the token into logs, local files or crash reports.
  • Logs and support threads. A request or response pasted into an issue, with the Authorization header visible.

What to do in the first hour

  1. Open your authorized applications in your GitHub account settings (see the link below) and find the application the token belongs to. If you do not know which, revoke any application you do not recognize.
  2. Revoke the authorization. Revoking an application’s access invalidates the tokens it holds for you, including a refresh token. If the token came from the GitHub CLI, sign out and sign in again afterward.
  3. Deploy any replacement if a service you run used the token: sign in again through the application so it gets a new token, and store it in a secret manager.
  4. Audit your account. Open the security log in your settings and review sign-ins, token and authorization events, SSH keys, deploy keys and repository access since the exposure.
  5. Check what the attacker could have changed. Look at recent pushes, new branches, edited workflow files, new webhooks, repository visibility changes, and secrets or variables in Actions settings.
  6. Review organizations. If you belong to organizations, ask their owners to check the audit log for activity from your account.
  7. Clean up the code and rotate other secrets from the same file. See I accidentally pushed an API key to GitHub.

Not sure what else leaked from the same repository? Run a free scan.

Not sure what else leaked? Run a free scan.

Revoke it at GitHub

OAuth authorizations are managed from the applications section of the settings of your GitHub account, after you sign in. The page lists the applications that hold access, and you can revoke each one, which cuts off its tokens. Organization owners can also review the applications approved for their organization. A person has not confirmed the exact menu wording for this guide, and the interface can change, so if the page differs from this description, look for the section where authorized OAuth applications are listed, and follow GitHub’s documentation.

How LeakWatch detects it

Two rules cover this guide.

The rule called GitHub OAuth Access Token matches gho_ followed by at least 36 letters or digits, with an upper limit of 1024. The open upper bound is deliberate: if GitHub lengthens the format, the match stays complete instead of cutting off the secret. The severity is critical.

The rule called GitHub Refresh Token matches ghr_ followed by at least 76 letters or digits, with the same upper limit. Its severity is also critical.

Neither rule needs a variable name next to the token, because the prefix is distinctive. A shorter body, or a different prefix, is not reported. Neither type is checked live: LeakWatch does not send any request to GitHub with the token it found.

LeakWatch detects this format but does not check it live: it can tell you the key is exposed, not whether it still works. Assume it does until you have revoked it.

FAQ

Is a gho_ token the same as a personal access token?

No. It is issued to an application you authorized, and revoking that application’s access invalidates it. A personal access token is created by you and revoked from its own settings page.

Does revoking the app also kill the refresh token?

Revoking the authorization removes the application’s access for your account, including tokens it can renew. Afterward, confirm by checking that the application no longer appears in your list.

Is deleting the commit enough?

No. Public commits are copied within minutes by scanners and mirrors, so treat the token as compromised and revoke it.

Get alerted next time a secret leaks — create a free account

LeakWatch is not affiliated with GitHub.