Skip to content
Detectors

Scanner deep dive

Overview

The GitHub detector looks for token types including Personal Access Token (classic) and Personal Access Token (fine-grained).

Provider and detector details

Summary

GitHubVersion ControlDraft: not yet checked by a person

GitHub hosts code repositories and supports code review and collaboration. Personal access tokens let scripts and tools act on a user's behalf.

Website Credential docs

  • Recognizable prefix (“ghp_” or “gho_” (4 more))
  • Keyword + nearby pattern
  • Randomness check (differs by version)
  • Unchanged since Sep 18, 2026
  • Source at 2325546

Runs on any connection. Triggered by keywords in the content, after decoding.How TruffleHog works

GitHub is a web-based platform used for version control and collaborative software development. GitHub tokens can be used to access and modify repositories and other resources. GitHub is a platform for version control and collaboration. Personal access tokens (PATs) can be used to access and modify repositories and other resources.
TruffleHog’s own description of this detector
About GitHub

source code hosting and collaboration platform. Products: git hosting, pull requests, GitHub Apps, Actions.

A verified token can call GET /user and whatever else the token’s scopes allow. Exact repository, organization, or admin access is not known from the detector alone.

Detector source documents GET {endpoint}/user with Authorization: token. 2xx means the token authenticated. This registry does not claim admin, billing, or organization-wide privileges.

Provider documentation

Draft provider notes, not yet checked by a person. Not read from source.

How detection works

One matching rule looks for 40-character strings of lowercase hex characters near “github_token”, “github_secret” or “github_key” (17 more).

Matching rules and source
Keywords
  • github
  • gh

Regex

  • v1 regexgithub_old.go:32–37 (opens TruffleHog source on GitHub)

    \b([0-9a-f]{40})\b

    Matches 40-character strings of lowercase hex characters.

    Show as a diagram

    Must appear near: “github_token”, “github_secret”, “github_key”, “github_api”, “github_pat” or “githubtoken” (14 more)

github_old.go:32–37 (opens TruffleHog source on GitHub)github_old.go:62 (opens TruffleHog source on GitHub)github_old.go:157 (opens TruffleHog source on GitHub)github_old.go:163 (opens TruffleHog source on GitHub)github_old.go:170 (opens TruffleHog source on GitHub)
Detector-wide rules and behavior

How it works

  1. Values below an entropy threshold are skipped. The threshold differs by version; How it behaves lists each one.
  2. Drops matches that look like known non-secrets (10 rules, in at least one variant).
  3. Reports each remaining match as a possible GitHub credential. It isn’t known to work until it’s verified.
Regular expression near a keyword
One value
Guards against false matches
Differs by version; How it behaves lists each threshold

Ignored when the match starts with:

  • avatars.githubusercontent.com
  • actions/
  • raw.githubusercontent.com/
  • api.github.com/repos/
  • gist.github.com/
  • sha256:
  • github.com/
  • pipelines.actions.githubusercontent.com/
  • ghcr.io/

Known false positives:

  • github commit

How it behaves

What this detector does at each step of the TruffleHog pipeline.

Keywords

Any one of these in the decoded text wakes the detector.

  • github
  • gh

github_old.go line 63 (opens TruffleHog source on GitHub)

Behavior

Multi-part
No
Match window
512 bytes on each side of a keyword
ahocorasickcore.go line 159 (opens TruffleHog source on GitHub)
Custom endpoints
Yes, can verify against your own server
github_old.go line 17 (opens TruffleHog source on GitHub)
Randomness check
Skips values with entropy below 3.5
github_old.go line 115 (opens TruffleHog source on GitHub)
False-positive check
The shared word lists

Verification. When a scan allows it, TruffleHog tests a match by calling the provider. A scan can turn this off for every detector or for this one. Atlas only describes this; it never tests credentials. How the verify decision works

Analyzer.GitHub Analyzer

In short

  • v1: Wakes on “github” or “gh” and tests matches with the provider. A default scan runs it.
  • v2: Wakes on “ghp_”, “gho_”, “ghu_”, “ghs_”, “ghr_” or “github_pat_” and tests matches with the provider. A default scan runs it.

How verification works

Each variant checks a found key its own way. Compare their requests and how answers are judged below.

Open Source + Enterprise support detection and verification for this credential type. Edition source.

Does checking a key change anything at the provider?

Not expected to: it’s a GET request, which reads without changing anything, and the source declares no changes.

Files
v1/github_old.go
Request
GEThttps://api.github.com/usergithub_old.go:157 (opens TruffleHog source on GitHub)
Key is sent as
Authorization token headergithub_old.go:163 (opens TruffleHog source on GitHub)
Troubleshoot this check

If a result looks wrong, work through these steps. They’re built from the request and status rules above. The Atlas doesn’t send anything.

1. Send the same request yourself

Each variant checks keys its own way. Use the one that matches your key’s format (see Detection above).

  • v1

    curl -i -H "Authorization: token $API_KEY" "https://api.github.com/user"
    • $API_KEY: the key you're checking
  • v2

    No check is tied to this variant’s files in what was read from source.

Only test keys you own or are allowed to check. Each command is one read-only GET request, the same one TruffleHog makes. Compare the status you get with “How responses are judged” above.

2. Likely causes

  • The scanner couldn't reach the provider. The scanner needs outbound HTTPS access to api.github.com. A firewall, proxy or DNS problem is reported as an error, not a rejection, and the key can be checked again.
  • The provider changed its API. If the provider answers differently from the table above, its API may have changed since this check was written. Compare against the provider's docs.

3. Check the provider’s docs

4. Still stuck

Report it to TruffleHog

Include the status code and response you got. Never include the key.

Errors, timeouts and rate limits
Not found in source
Not found in source
If the provider can’t be reached
The result is an error, not a rejection, and the key can be checked again.

All URLs found in source

  • https://api.github.com
  • https://developer.github.com/v3/#oauth2-token-sent-in-a-header
  • https://howtorotate.com/docs/tutorials/github/
  • https://developer.github.com/v3/users/#get-the-authenticated-user
  • https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/
  • https://github.blog/changelog/2022-10-18-introducing-fine-grained-personal-access-tokens/
  • https://developer.github.com/v3/#oauth2-keysecret

Verified findings

Open Source · Standard output (stdout)

The CLI prints verified findings to stdout. Use --json for structured output.

Example scan output · credential redacted

✅ Found verified result 🐷🔑
Detector Type: Github
Decoder Type: PLAIN
Raw result: [redacted]
Terminal printer source
CI formats

With --github-actions, GitHub Actions displays this workflow command as a warning on the indicated file and line.

::warning file=config/example.env,line=8,endLine=8::Found verified Github result 🐷🔑
GitHub Actions printer source

Legacy compatibility. --json-legacy writes pre-v3 JSON for Git, GitLab, and GitHub sources only.

Enterprise alerts

When Enterprise verifies that a secret is live, a configured notifier can alert your team. The finding is also available through the Enterprise API.

A notifier that displays rotation guides can include this link with the alert.

Open rotation guide

Optional analysis

What the analyzer checks

In Open Source, run trufflehog analyze separately from the scan. Enterprise runs enabled self-discovery analyzers on first discovery of a supported live secret.

Rotation resources

Token types

TruffleHog’s source looks for 6 token types, and names each one.

What the vendor says:from the vendor’s own pages. Their exact words appear only where the vendor’s licence allows it.

Token types: from TruffleHog’s source, and what the vendor says
PrefixName in sourceWhat the vendor says
ghp_Personal Access Token (classic)Personal access token (classic)docs.github.com
Exact passagePersonal access token (classic) | ghp_ | Managing your personal access tokensGitHub Docs, "About authentication to GitHub", GitHub's token formats. Checked 2026-11-24.GitHub Docs, CC BY 4.0. Table row shown as text; long passages shortened (…). Licence
github_pat_Personal Access Token (fine-grained)Fine-grained personal access tokendocs.github.com
Exact passageFine-grained personal access token | github_pat_ | Managing your personal access tokensGitHub Docs, "About authentication to GitHub", GitHub's token formats. Checked 2026-11-24.GitHub Docs, CC BY 4.0. Table row shown as text; long passages shortened (…). Licence
gho_OAuth Access TokenOAuth access tokendocs.github.com
Exact passageOAuth access token | gho_ | Authorizing OAuth appsGitHub Docs, "About authentication to GitHub", GitHub's token formats. Checked 2026-11-24.GitHub Docs, CC BY 4.0. Table row shown as text; long passages shortened (…). Licence
ghu_GitHub App User-to-Server TokenUser access token for a GitHub Appdocs.github.com
Exact passageUser access token for a GitHub App | ghu_ | Authenticating with a GitHub App on behalf of a userGitHub Docs, "About authentication to GitHub", GitHub's token formats. Checked 2026-11-24.GitHub Docs, CC BY 4.0. Table row shown as text; long passages shortened (…). Licence
ghs_GitHub App Server-to-Server (installation) TokenInstallation access token for a GitHub Appdocs.github.com
Exact passageInstallation access token for a GitHub App | ghs_ | Authenticating as a GitHub App installation. Note: Starting April 27, 2026, GitHub began a staged rollout of a stateless format (ghs_APPID_JWT) to all newly minted GitHub App installation tokens … If your application expects or relies on installation tokens being exactly 40 characters long, it may not handle this new token format correctly.GitHub Docs, "About authentication to GitHub", GitHub's token formats. Checked 2026-11-24.GitHub Docs, CC BY 4.0. Table row shown as text; long passages shortened (…). Licence
Caution: Since April 27, 2026 GitHub has been rolling out a new installation-token format (ghs_APPID_JWT) that TruffleHog's regex may only partly match; see "Formats the vendor documents that this detector may miss" below. Not confirmed on a real token.
ghr_GitHub App Refresh TokenRefresh token for a GitHub Appdocs.github.com
Exact passageRefresh token for a GitHub App | ghr_ | Refreshing user access tokensGitHub Docs, "About authentication to GitHub", GitHub's token formats. Checked 2026-11-24.GitHub Docs, CC BY 4.0. Table row shown as text; long passages shortened (…). Licence

Formats the vendor documents that this detector may miss

  • ghs_APPID_JWTInstallation access token, stateless format (rolling out since 2026-04-27)Only 47 of 156 characters matcheddocs.github.com

Each result comes from a made-up token in the shape the vendor documents, run against this detector’s regexes at TruffleHog 2325546. Not confirmed on a real token: a real one may differ, and TruffleHog may catch it some other way.

Pages TruffleHog’s source links to (5)

Coverage in other scanners

4 scanners have a confirmed match.

Changes

No changes to GitHub since Sep 18, 2026, when Atlas started recording.

When TruffleHog changes this detector, the changed fields, the pull request and the source diff appear here for review.

Browse all changesSource history on GitHub

Source

Facts on this page were read from trufflesecurity/trufflehog at commit 2325546.

2325546
2921dcc