Join our Newsletter — 33% off our NHI Course
Home› Guides› Secret Format Design Guide: Why Providers Add Prefixes…
Guide Secrets Management

Secret Format Design Guide: Why Providers Add Prefixes and Checksums to Keys

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 11 min read
On this page

An API key that looks like any other random string cannot be reliably found when it leaks, cannot be told apart from a hash or an ID, and cannot be routed to the team that can revoke it. Over the last few years many providers have redesigned their tokens with identifiable prefixes, checksums and fixed encodings so that scanners can find them with almost no false positives and report them to the issuer automatically. This guide explains each design element, what it buys and what it does not, using formats that providers publish in their own documentation, and gives a practical recipe for designing your own token format. It is for platform engineers who issue API keys or tokens and for secrets programme owners who run scanning and revocation.

Key takeaways

  • Format is a security control. A distinctive prefix plus a checksum turns leak detection from guesswork on entropy into a near-exact match, which makes automated revocation practical.
  • Prefixes identify issuer, type and environment. Published examples include ghp_, glpat-, pypi-, xoxb- and sk_live_; none of them carry secret material.
  • Checksums let anyone discard fakes offline. GitHub stores a 32-bit CRC32 checksum in the last six characters so candidates can be validated without a database call; a checksum is not a signature and adds no secrecy.
  • Entropy still does the security work. The random part must come from a CSPRNG with at least 128 bits of entropy, as OWASP ASVS 5.0 requires for non-guessable strings.
  • Design for the whole leak lifecycle. A good format is matched by a published pattern, a scanning partner integration, a revocation endpoint and server-side storage of only a hash.

Why secret format matters

Secret scanners face two problems with unstructured keys. Generic high-entropy detection produces large numbers of false positives (hashes, UUIDs, random IDs), and even a true match does not say which service issued the credential, so triage is slow. GitHub describes its old tokens as 40-character hexadecimal strings that looked like SHA hashes, which made detection "inefficient and sometimes inaccurate". When the format is distinctive, three things improve at once:

  • Precision: a regular expression anchored on a unique prefix matches almost only real tokens. GitHub expected the prefix alone to bring its secret scanning false positive rate down to 0.5%.
  • Routing: the prefix names the issuer and token type, so a finding goes straight to the right revocation process. See the Developer Secret Scanning Triage.
  • Automation: issuers can join scanning partner programmes and receive reports for leaked tokens within their own systems, without the leaking customer doing anything.

Leaked credentials found in files are mapped by MITRE ATT&CK as T1552.001 Credentials In Files under T1552 Unsecured Credentials. Format design does not stop the leak; it shortens the time from exposure to revocation.

Identifiable prefixes

The table lists prefixes exactly as each provider documents them, as of November 2026. Providers are listed alphabetically; the order is not a ranking, and each provider's own guide on this site covers its tokens in depth.

ProviderDocumented prefixes (examples)What the prefix encodesSource
GitHubghp_ personal access token, gho_ OAuth access, ghu_ user-to-server, ghs_ server-to-server, ghr_ refreshIssuer ("gh") plus the first letter of the token type, joined by an underscoreGitHub engineering blog
GitLabglpat- personal, project, group and impersonation tokens; gldt- deploy; glrt- runner; glcbt- CI/CD job; glptt- trigger; gloas- OAuth application secretIssuer ("gl") plus token type; GitLab describes them as "standard identifications"GitLab token overview
PyPIpypi- followed by a base64-serialised macaroonIssuer; documented match pattern pypi-[A-Za-z0-9-_]{85,}PyPI secret reporting API docs
Slackxoxb- bot, xoxp- user, xapp- app-level, xoxe.xapp- rotating app-levelToken family and typeSlack token types docs
Stripepk_ publishable, rk_ restricted, sk_ secret, each with _test_ or _live_; sk_org_ organisationKey type and mode (sandbox or live), which also signals whether the key is safe to exposeStripe API keys docs

Provider details: the GitHub Token Types and Prefixes Reference, GitLab Tokens Security Guide, PyPI API Tokens and Trusted Publishing Security Guide, Slack Tokens Security Guide and Stripe API Keys Security Guide.

Prefix design choices

  • Separator outside the body alphabet: GitHub chose an underscore because it is not a Base64 character, so a random string is unlikely to reproduce the prefix by accident, and because double-clicking selects the whole token. Hyphens and dots also appear in published formats; whichever you choose, keep it out of the random body's alphabet if possible.
  • Type and environment, never secrets: encode issuer, token type and environment (Stripe's _test_ and _live_ are a clear example). Never put customer IDs, email addresses, tenant names, scopes or anything confidential in the prefix: it is printed in logs, scanners and alerts by design.
  • Stable and fixed: GitLab notes its prefixes cannot be configured (except personal access tokens), because stability is what lets scanners rely on them.
  • Distinct per type: separate prefixes for long-lived keys, short-lived access tokens and refresh tokens let responders prioritise.

The IETF published a vendor-neutral alternative, RFC 8959 "The 'secret-token' URI Scheme" (Informational, January 2021), which wraps any token as secret-token:<token> so repositories and CI systems can refuse commits containing it. The RFC notes the scheme cannot prevent intentional disclosure and that users may strip the scheme to evade detection.

Checksums and offline validation

A prefix tells a scanner what a string claims to be; a checksum lets it check that claim cheaply. GitHub's design computes a 32-bit CRC32 over the token, encodes it in Base62 with leading zero padding, and places it in the last six characters. In GitHub's words, this lets it "eliminate fake tokens without having to hit our database". GitHub's secret scanning partner programme documentation recommends the same three traits for any issuer: a uniquely defined prefix, high-entropy random strings and a 32-bit checksum.

Design elementBenefitWhat it does not do
Unique prefixNear-exact scanner matching; routes findings to issuer and typeDoes not prove the string is a real token
Non-alphabet separatorRandom strings cannot mimic the prefix; whole token selectableNo security value on its own
Checksum (e.g. CRC32, 32 bits)Offline rejection of typos, examples and fakes; fewer false positives and API callsNot a MAC or signature: anyone can compute a valid checksum, so it never authenticates
Fixed length and alphabetTight regex with low false positives; predictable storageDoes not add entropy
CSPRNG random body (128 bits or more)Unguessability, the actual security propertyDoes not help detection
Environment marker (test or live)Severity triage; safe-to-expose keys distinguishableMust not replace server-side checks on mode
Published pattern and partner integrationThird-party scanners report leaks to the issuer automaticallyNeeds a working, monitored revocation path

Because the checksum is public knowledge, an attacker can generate strings with valid checksums. That is harmless: a valid checksum only means "worth checking", and the issuer still validates the token against its store. Do not use a keyed MAC in the token as a substitute for a server-side lookup unless you have designed the key management for it.

Entropy, length and encoding

  • Entropy target: OWASP ASVS 5.0 requirement V11.5.1 asks that non-guessable strings come from a CSPRNG with at least 128 bits of entropy, and notes that UUIDs do not meet this. Many issuers go higher; GitHub raised OAuth token entropy from 160 to 178 bits while keeping the length unchanged.
  • Encoding: Base62 (letters and digits) avoids characters that break in URLs, shells and config files, and keeps tokens selectable. Base32 is case-insensitive and easier to read aloud; Base64url is denser. Pick one alphabet and fix the length.
  • Length budget: total length = prefix + separator + random body + checksum. With Base62, each character carries about 5.95 bits, so 128 bits needs at least 22 characters of body and GitHub's six-character checksum holds 32 bits.
  • Structured tokens: some formats serialise a structured credential after the prefix. PyPI's tokens are pypi- followed by a base64 macaroon of variable length (85 characters or more), so scanners match a minimum length rather than an exact one.

Designing your own token format

  1. Inventory what you issue: list every credential type (API keys, personal tokens, service tokens, refresh tokens, webhook secrets) with lifetime and blast radius.
  2. Choose a prefix scheme: a short, registered-looking issuer code plus a type code (and environment where relevant), and a separator outside your body alphabet. Check public scanner rule sets for collisions with existing prefixes.
  3. Generate the body: at least 128 bits from a CSPRNG, encoded in a fixed alphabet and length.
  4. Append a checksum: a 32-bit CRC over prefix and body, encoded in the same alphabet with fixed padding. Document the algorithm so scanners can validate offline.
  5. Store only a hash: keep a hash of the full token server side (with the prefix and perhaps the last few characters shown in your console for identification). This supports lookup without retaining the secret, in line with NIST SP 800-53 IA-5 authenticator management and SC-28 protection at rest.
  6. Publish the pattern: document the regex, join scanning partner programmes and provide a signed-report endpoint. GitHub's programme sends a JSON list with token, type, url and source, signed with ECDSA (NIST P-256, SHA-256), and asks partners to treat every reported secret as public and compromised. PyPI adopted the same reporting pattern for its own API.
  7. Roll out alongside old formats: issue new-format tokens to new requests first, accept both formats during a migration window, prompt users to rotate old tokens, then retire the old format with a dated notice.
  8. Test: unit-test generation, checksum validation and rejection of altered tokens; run your published regex against real repositories and logs to measure false positives before announcing it.

Rollback is simple if the server accepts both formats during migration: if a client library mishandles the new separator or length, keep issuing the old format to that client while it is fixed. For broader key handling, see the API Key Management Guide.

Impact on secret scanning and revocation

StageWithout a designed formatWith prefix, checksum and partner integration
DetectionEntropy heuristics, many false positivesAnchored regex plus checksum check, few false positives
AttributionManual guess at issuerPrefix names issuer and type
ValidationLive API call for every candidateOffline checksum first, live check only for survivors
NotificationDepends on the person who leaked itScanner reports to issuer endpoint automatically
RevocationManual, often delayedIssuer can revoke or alert the owner on receipt

Internal scanners benefit the same way: precise rules for your own formats can run in pre-commit hooks, CI and push protection without alert fatigue. See the Git Secret Scanning Guide and the Secret Scanner Rule Coverage Comparison Guide.

Measuring the programme

  • Share of issued credentials in a prefixed, checksummed format.
  • Scanner precision for your own token rules (true findings divided by all findings).
  • Median time from leak report to revocation or owner notification.
  • Number of legacy-format tokens still active, trending to zero.
  • Partner report volume and the share processed automatically.

Common failure patterns

  • Encoding tenant names, user IDs or scopes in the prefix, leaking information through every log line and alert.
  • Treating the checksum as proof of authenticity and skipping the server-side lookup.
  • Using UUIDs or timestamps as the random body, which falls short of 128 bits of entropy.
  • Publishing a prefix but no revocation endpoint, so reports arrive with nowhere to go.
  • Allowing legacy unprefixed tokens to live on indefinitely after the new format ships.
  • Storing tokens in plaintext so the issuer can "show" them later, which turns a database read into a credential leak.

Framework mapping

FrameworkReferenceHow format design supports it
NIST SP 800-53 Rev 5IA-5 Authenticator Management; IA-5(7) No Embedded Unencrypted Static AuthenticatorsDetectable formats make embedded secrets findable and revocable
NIST SP 800-53 Rev 5SC-28 Protection of Information at Rest; SI-4 System MonitoringHash-only storage; scanning for exposed tokens
NIST CSF 2.0PR.AA-01Credentials for services managed by the organisation
OWASP ASVS 5.0V11.5.1CSPRNG with at least 128 bits of entropy
MITRE ATT&CK v20T1552.001 Credentials In FilesShortens exposure window for leaked keys

Practitioner checklist

  • List every credential type you issue and decide its prefix, type code and environment marker.
  • Keep prefixes free of any confidential or customer data.
  • Generate at least 128 bits of CSPRNG entropy in a fixed alphabet and length.
  • Append and document a 32-bit checksum for offline validation, and never treat it as authentication.
  • Store only hashes of issued tokens.
  • Publish the regex, join scanning partner programmes and run a signed-report revocation endpoint.
  • Migrate legacy formats with a dated retirement plan and measure remaining legacy tokens.
  • Add rules for your own formats to internal pre-commit, CI and push protection scanning.

Standards and references

Related NHI Mgmt Group resources: Secrets Management Guide · API Key Management Guide · Git Secret Scanning Guide · API Key Leak Response Playbook

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.