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

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.
From the detector’s Description() in source
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 regexkeyPatgithub_old.go:32–37 (opens TruffleHog source on GitHub)Placed by its version number

    \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”, “githubtoken”, “githubsecret”, “githubkey”, “githubapi”, “githubpat”, “gh_token”, “gh_secret”, “gh_key”, “gh_api”, “gh_pat”, “ghtoken”, “ghsecret”, “ghkey”, “ghapi” or “ghpat”

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.
Prefix regex
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
  • rotation_guide
  • version
  • token_type
  • username
  • url
  • account_type
  • site_admin
  • name
  • company
  • ldap_dn
  • email
  • 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

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.

Source says: GET of the authenticated user; mutating side effects not declared

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

    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

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
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 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.

pkg/analyzer/cli.go registers this detector key to the analyzer package.

How it works

  1. Runs after the detector reports the match as verified.
  2. Evaluates what the credential may be able to access using the analyzer’s own checks or rules.
  3. Reports what it finds. Its source lists 127 permissions in 2 groups and 3 resource types.

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

Every fact on this page was parsed from trufflesecurity/trufflehog at 2325546, unless a row below says otherwise.

2325546
2921dcc
Parser
trufflehog-detectors-analyzers-v12
Extraction
intel-detector-v7

4 of 24 evidence rows need attention

Evidence rows that need attention
FieldStatusValueSource
lastSeenAt2026-11-25T16:33:44.855ZNo citation
verify.statusCodesNone extractedFile
timeoutNone extractedFile
rateLimitNone extractedFile
All 24 evidence rows
All evidence rows
FieldStatusValueSource
descriptionGitHub 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
keywordsgithub, gh, ghp_, gho_, ghu_, ghs_, ghr_, github_pat_File
detectorTypesGithubFile
filesv1/github_old.go, v2/github.goFile
patterns\b([0-9a-f]{40})\b, \b((?:ghp|gho|ghu|ghs|ghr|github_pat)_[a-zA-Z0-9_]{36,255})\bFile
patternTypeprefix_regexFile
statusactiveFile
lastSeenAt2026-11-25T16:33:44.855ZNo citation
rotationGuidehttps://howtorotate.com/docs/tutorials/github/File
verify.hasVerifyYesFile
verify.httpMethodsGETFile
verify.statusCodesNone extractedFile
entropyMinimum3.5File
allowlistRulesliteral 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
timeoutNone extractedFile
rateLimitNone extractedFile
errorHandlingSetVerificationErrorFile
verify.urlshttps://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-keysecretFile
detection.keywordsgithub, ghLines 62–62
detection.keywordsghp_, gho_, ghu_, ghs_, ghr_, github_pat_Lines 71–71
verification.endpointhttps://api.github.com/userLines 157–157
verification.httpMethodGETLines 157–157
verification.authenticationMethodAuthorization token headerLines 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