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

Should not match

Known false positives

References

Collections