Github Pat
Detects GitHub access tokens by prefix: classic personal access tokens (ghp_), OAuth tokens (gho_), GitHub App user tokens (ghu_), refresh tokens (ghr_) and GitHub App installation tokens (ghs_). Installation tokens are matched in both formats: the legacy 40-character form and the stateless form GitHub made the default in October 2026 (still ghs_, about 520 characters, a JWT with two dots). Fine-grained personal access tokens (github_pat_) are covered by global-github-pat-fine-grained. This pattern is based on a Microsoft Purview built-in sensitive information type. Users already running Purview may prefer to enable the built-in SIT directly, or use this version as a starting point for customisation.
- Type
- regex
- Engine
- universal
- Confidence
- high
- Confidence justification
- High confidence: every branch starts with a GitHub-specific prefix that GitHub introduced so that scanners can identify its tokens. The opaque branch is a fixed 40 characters. The stateless installation-token branch needs ghs_ plus three long URL-safe runs joined by exactly two dots, which file names and identifiers that merely begin with ghs_ do not satisfy. GitHub advises treating tokens as opaque and may change the stateless layout again; the bounds leave room above the published length of about 520 for that reason. The checksum in the opaque format is not validated.
- Detection quality
- Verified
- Jurisdictions
- global
- Regulations
- Criminal Code Act 1995 (Cth)
- Frameworks
- CIS Controls, ISO 27001, NIST CSF, PCI-DSS, SOC 2
- Data categories
- credentials, security
- Scope
- specific
- Risk rating
- 8
- Platform compatibility
- Purview: Compatible, GCP DLP: Compatible, Macie: Compatible, Zscaler: Compatible, CrowdStrike DLP: Compatible, Palo Alto: Adapted from Purview, Netskope: Adapted from Purview
Pattern
(?-i)\b((?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{36})\b
Corroborative evidence keywords
api key, api_key, apikey, access key, secret key, private key, auth token, authorization, access token, bearer, conn str, connection string, connectionstring, cookie, credential, database, host, [object Object], oauth, passphrase (+33 more)
Proximity: 300 characters
Should match
ghp_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef0123— GitHub PAT with ghp prefixgho_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef0123— GitHub OAuth tokenghs_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef0123— GitHub server-to-server tokenghs_1234567_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghij.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123_-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefgh— Bare stateless installation token (ghs_, app ID, underscore, then a three-part JWT; 488 characters); 65 discovery tierGitHub App installation token: ghs_1234567_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghij.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123_-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefgh— Labelled stateless installation token; 85 tierhttps://x-access-token:ghs_7654321_KLMNOPQRSTUVWXYZabcdefghijklmnopqrst.0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRST.ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGH@github.com/octo-org/octo-repo.git— Stateless installation token embedded in a git remote URL (github.com supplies the keyword); 85 tier
Should not match
GitHub Actions reads ghs_config.production.yaml before each deploy— A file name that begins with ghs_ and has two dots; the runs are far shorter than a token'sGitHub App installation token: ghs_1234567_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghij.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789— ghs_ value with only one dot (a truncated stateless token) is neither formatghx_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef01— Invalid prefix (ghx instead of ghp/gho/ghu/ghs/ghr)ghp_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef0— Too few characters after prefix (35 instead of 36)ghp_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef012— Too many characters after prefix (37 instead of 36)template example placeholder record identifier— Template/sample context should be excluded even when anchor words are present
Known false positives
- Expired tokens. Installation tokens (ghs_) expire after one hour, so one found in an old CI log or chat export is usually dead. Mitigation: The pattern cannot test validity. Treat a recent match as live; for older content, confirm the timestamp before escalating.
- Made-up tokens in documentation, tests and tutorials that copy the real prefix and length. Mitigation: The template-exclusion dictionary suppresses values framed as examples or placeholders. The opaque format's checksum is not validated, so structurally valid fakes still match.
- Source files, variables or keys whose names begin with ghs_ and contain dots. Mitigation: The stateless branch needs three runs of at least 20 characters with no other punctuation, joined by exactly two dots, which names of this kind do not reach.
References
- GitHub personal access token entity definition - Microsoft Learn
- About authentication to GitHub, GitHub's token formats - GitHub Docs (prefix per token type; stateless ghs_APPID_JWT rollout from 27 April 2026; installation tokens may not be 40 characters)
- GitHub changelog, 24 April 2026 (installation tokens change to ghs_APPID_JWT, about 520 characters and varying; ghs_[A-Za-z0-9]{36} may not match; GitHub Enterprise Server not affected)
- GitHub changelog, 15 May 2026 (a stateless token has two dots, a stateful one none; GitHub's recommended regex for both is ghs_[A-Za-z0-9\.\-_]{36,})
- GitHub changelog, 2 October 2026 (stateless format is now the default for newly minted installation tokens; still ghs_, about 520 characters instead of 40)