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.
- Recognizable prefix (“ghp_” or “gho_” (4 more))
- Keyword + nearby pattern
- Randomness check (differs by version)
- Unchanged since Sep 18, 2026(log start)
- Source at 2325546
- Change review: Nothing queued
- Default scan: Runs in a default scan
- pkg/detectors/github
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.
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 documentationDraft 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 regexkeyPatgithub_old.go:32–37 (opens TruffleHog source on GitHub)Placed by its version number
\b([0-9a-f]{40})\bMatches 40-character strings of lowercase hex characters.
Show as a diagram
Must appear near: “github_token”, “github_secret”, “github_key”, “github_api”, “github_pat”, “githubtoken”, “githubsecret”, “githubkey”, “githubapi”, “githubpat”, “gh_token”, “gh_secret”, “gh_key”, “gh_api”, “gh_pat”, “ghtoken”, “ghsecret”, “ghkey”, “ghapi” or “ghpat”
Detector-wide rules and behavior
How it works
- Values below an entropy threshold are skipped. The threshold differs by version; How it behaves lists each one.
- Drops matches that look like known non-secrets (10 rules, in at least one variant).
- Reports each remaining match as a possible GitHub credential. It isn’t known to work until it’s verified.
- Prefix regex
- One value
Compare all matching rules side by side
| v1v1/github_old.go | v2v2/github.go | |
|---|---|---|
| Keywords |
|
|
| Regexes |
|
|
- Files
- v1/github_old.go
- Keywords
- github
- gh
- Regexes
v1 regexkeyPatgithub_old.go:32–37 (opens TruffleHog source on GitHub)Placed by its version number
\b([0-9a-f]{40})\bMatches 40-character strings of lowercase hex characters.
Show as a diagram
Must appear near: “github_token”, “github_secret”, “github_key”, “github_api”, “github_pat”, “githubtoken”, “githubsecret”, “githubkey”, “githubapi”, “githubpat”, “gh_token”, “gh_secret”, “gh_key”, “gh_api”, “gh_pat”, “ghtoken”, “ghsecret”, “ghkey”, “ghapi” or “ghpat”
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
- rotation_guide
- version
- token_type
- username
- url
- account_type
- site_admin
- name
- company
- ldap_dn
- location
- scopes
- expiry
How it behaves
What this detector does at each step of the TruffleHog pipeline.
pkg/detectors/github/v1 · Scanner
Keywords
Any one of these in the decoded text wakes the detector.
- github
- gh
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.
Source says: GET of the authenticated user; mutating side effects not declared
| v1v1/github_old.go | v2v2/github.go | |
|---|---|---|
| Request | GEThttps://api.github.com/usergithub_old.go:157 (opens TruffleHog source on GitHub) | Not tied to this variant’s files in what was read from source. The check may live in a shared file. |
| Key is sent as | Authorization token headergithub_old.go:163 (opens TruffleHog source on GitHub) | — |
| How answers are judged | — |
- 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)
- How answers are judged
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
Rule:
header. Key placement as recorded:Authorization token header.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
- Provider documentation Atlas provider entry, draft
- docs.github.com: permissions required for fine grained personal access tokens from the GitHub analyzer notes
- docs.github.com: scopes for oauth apps from the GitHub analyzer notes
4. Still stuck
Report it to TruffleHogInclude the status code and response you got. Never include the key.
Errors, timeouts and rate limits
- Not found in source
- Not found in source
- SetVerificationError
Verified means HTTP 2xx. This is a range check, not a StatusOK switch.
other statuses: not verified; transport errors are stored separately
transport errors return a verification error
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 sourceCI 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 sourceLegacy 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 guideOptional 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.
- Open GitHub Analyzer →
- Classic tokenReads from provider
Reads the X-OAuth-Scopes response header.
- Fine-grained token (no X-OAuth-Scopes header)Tests each permission
Tests each permission per repository through a dedicated check function.
View example analyzer output
Redacted Open Source terminal excerpts. Analyzer header source
Classic token
Classic token output source[i] Token User: [redacted] [x] Classic Token has no scopesFine-grained token
Fine-grained token output source[i] Token User: [redacted] [!] Repository Access: Public Repositories (read-only)Permissions and sources
127 permission names in source
Alert delivery has no documented ordering relative to analysis. How Analyze runs.
pkg/analyzer/cli.go registers this detector key to the analyzer package.
How it works
- Runs after the detector reports the match as verified.
- Evaluates what the credential may be able to access using the analyzer’s own checks or rules.
- Reports what it finds. Its source lists 127 permissions in 2 groups and 3 resource types.
Rotation resources
Use the rotation guide to replace this credential.
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.
| Prefix | Name in source | What 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 Token | OAuth 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 Token | User 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) Token | Installation 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 |
| ghr_ | GitHub App Refresh Token | Refresh 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)
Written in the detector’s source by its authors. Shown as written: this doesn’t say what each page covers.
Coverage in other scanners
4 scanners have a confirmed match.
GitHub Secret ProtectionConfirmed match
- GitHub App Installation Access Token
github_app_installation_access_tokenPush protection yes · Validity check yes - GitHub OAuth Access Token
github_oauth_access_tokenPush protection yes · Validity check yes - GitHub Personal Access Token
github_personal_access_tokenPush protection yes · Validity check yes - GitHub Refresh Token
github_refresh_tokenPush protection yes · Validity check yes
- GitHub App Installation Access Token
KingfisherConfirmed match
betterleaks.github-app-tokenThe rule declares validation, access mapping, revocation.betterleaks.github-fine-grained-patThe rule declares validation, access mapping, revocation.betterleaks.github-oauthThe rule declares validation, access mapping, revocation.betterleaks.github-patThe rule declares validation, access mapping, revocation.betterleaks.github-refresh-tokenThe rule declares validation, access mapping, revocation.
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.
Source
Every fact on this page was parsed from trufflesecurity/trufflehog at 2325546, unless a row below says otherwise.
- Source file
- pkg/detectors/github/v1/github_old.go
- Parser
- trufflehog-detectors-analyzers-v12
- Extraction
- intel-detector-v7
4 of 24 evidence rows need attention
All 24 evidence rows
| Field | Status | Value | Source |
|---|---|---|---|
| description | 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. | File | |
| keywords | github, gh, ghp_, gho_, ghu_, ghs_, ghr_, github_pat_ | File | |
| detectorTypes | Github | File | |
| files | v1/github_old.go, v2/github.go | File | |
| patterns | \b([0-9a-f]{40})\b, \b((?:ghp|gho|ghu|ghs|ghr|github_pat)_[a-zA-Z0-9_]{36,255})\b | File | |
| patternType | prefix_regex | File | |
| status | active | File | |
| lastSeenAt | 2026-11-25T16:33:44.855Z | No citation | |
| rotationGuide | https://howtorotate.com/docs/tutorials/github/ | File | |
| verify.hasVerify | Yes | File | |
| verify.httpMethods | GET | File | |
| verify.statusCodes | None extracted | File | |
| entropyMinimum | 3.5 | File | |
| allowlistRules | literal false positive: github commit, known non-sensitive prefix: avatars.githubusercontent.com, known non-sensitive prefix: actions/, known non-sensitive prefix: raw.githubusercontent.com/, known non-sensitive prefix: api.github.com/repos/, known non-sensitive prefix: gist.github.com/, known non-sensitive prefix: sha256:, known non-sensitive prefix: github.com/, known non-sensitive prefix: pipelines.actions.githubusercontent.com/, known non-sensitive prefix: ghcr.io/ | File | |
| timeout | None extracted | File | |
| rateLimit | None extracted | File | |
| errorHandling | SetVerificationError | File | |
| verify.urls | 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 | File | |
| detection.keywords | github, gh | Lines 62–62 | |
| detection.keywords | ghp_, gho_, ghu_, ghs_, ghr_, github_pat_ | Lines 71–71 | |
| verification.endpoint | https://api.github.com/user | Lines 157–157 | |
| verification.httpMethod | GET | Lines 157–157 | |
| verification.authenticationMethod | Authorization token header | Lines 163–163 | |
| verification.expectedStatuses.verified | {"statuses":[],"names":["2xx"],"outcome":"verified"} | Lines 170–170 |
Parser completeness
- Field status: Extracted
- Field status: Extracted
- Field status: Extracted
- Field status: Extracted
- Field status: Extracted
- Field status: Extracted
- Field status: Extracted
- Field status: Extracted
- Field status: Extracted
- Field status: Extracted
- Field status: Not scanned
Package files (2)
- v1/github_old.go
- v2/github.go