A GitHub fine-grained personal access token lets a program act on GitHub for the account that created it, limited to the repositories and permissions chosen when the token was made. Its scope can be narrow, such as reading one repository, or wide, such as pushing code, managing workflows and reading secrets of several organizations. A leaked token can clone private code, push changes that run in your pipelines, and open or merge pull requests. Revoke the token first, then check the repositories it could reach.
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 fine-grained token looks like
Fine-grained tokens start with the fixed text github_pat_, followed by a long run of letters, digits and underscores. The total length is fixed at more than 80 characters after the prefix, so a value that looks like this is easy to recognize in a search:
github_pat_… (fine-grained token, masked)
Older GitHub tokens use different prefixes, such as the ones for classic personal access tokens and OAuth tokens. They are covered by their own guides. The fine-grained form is the one issued with a named scope and an expiry date, and GitHub’s documentation describes it as the recommended token for most automation. A token with a long lifetime, or with no expiry, deserves extra attention, because it stays valid for longer after a leak.
How GitHub tokens get leaked
- Committed configuration. A
.envfile, a Git configuration or a script that holds the token, pushed to a repository, including a public one. - Workflow files. A GitHub Actions file that writes the token into a file, prints it or passes it to a step that logs its arguments.
- Shared scripts. A deployment or backup script copied between projects with the token still inside.
- Logs and screenshots. A terminal session or a debug output that displays the token, shared in a ticket or a chat.
- Remote URLs. A Git clone address that includes the token in the URL, which is then saved in a local configuration file or a shell history.
What to do in the first hour
- Revoke the token. Sign in to GitHub and open your developer settings, then the personal access tokens area. Find the fine-grained token and delete it, or regenerate it if you need the same permissions for a replacement. GitHub’s documentation says that deleting or revoking a credential removes all access that came with it. Do this before you clean the repository.
- Create a replacement with the smallest set of repositories and permissions the job needs, and an expiry date that suits the task. Store it in an encrypted secret of the repository or organization, not in the code.
- Review the audit log. Check the security log of your account and organizations for the period since the token may have been exposed. Look for clones, pushes, workflow runs, new deploy keys, changed settings and access from addresses you do not recognize.
- Check the repositories. Look for commits you did not make, new branches, changed workflow files and new releases. A token that can push can also change the code that runs in your pipelines, so review those files first.
- Check the other secrets. A leaked token often sits beside cloud keys or registry logins. Rotate them, and check whether any workflow used the token to read other secrets.
- Clean the repository after the rotation: remove the token from the files and from history if you can, and add the file to
.gitignore. A deleted commit remains in clones until they are removed, so the rotation is the real fix. For a wider search, see deep-scan your whole git history.
Not sure what else leaked from the same repository? Run a free scan.
Revoke it at GitHub
Open the account settings for your developer settings, then the fine-grained personal access tokens list. Select the token and delete it, or regenerate it if you need to keep the same permissions. Organization owners can also review and revoke fine-grained tokens that were given access to their organization, from the organization’s settings. GitHub’s documentation on credential types explains that a token pushed to a public repository or gist is revoked automatically, but do not rely on that: remove it yourself. If the token is associated with single sign-on, administrators can also revoke its access to an organization without deleting it.
How LeakWatch detects it
The rule is called GitHub Fine Grained PAT. It looks for the fixed github_pat_ prefix followed by a run of exactly 82 letters, digits or underscores, which matches the length GitHub uses for these tokens. A value that is shorter, or that uses another prefix such as the one for classic personal access tokens, is handled by a different rule. The severity is critical, with the impact class for identity and code access. This type is not checked live: LeakWatch does not send the token to GitHub.
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 fine-grained token safer than a classic token?
Usually, yes, because it can be limited to chosen repositories and permissions, and it can have an expiry date. A leaked one is still serious, because it grants whatever scope it was given.
Will revoking the token break my CI?
Yes, for any workflow or script that uses it. Create the replacement first where you can, store it as an encrypted secret, and run one pipeline to confirm it works before you finish the cleanup.
Do I need to check other repositories?
Yes, if the token could reach them. Look at the repositories it was granted access to, not only the one where the leak was found, and check the organization audit log for activity across all of them.