Sub topic 3
What GitHub recognizes: provider patterns and secret types
This chapter assumes you know basic Git, can read an alert in a repository's Security tab, and can run gh commands in a terminal. It explains what secret scanning looks for, how a match is named, and why some matches can block a push while others only raise an alert.
Detection is pattern-based
Secret scanning does not understand your code. It compares text against a catalog of patterns and reports strings that fit. Each pattern describes the shape of one kind of credential. Examples are a fixed prefix, a length, an allowed character set, and sometimes a checksum or a second companion value.
The shape of a credential decides how reliable the match is. A token with a distinctive prefix and a checksum is almost never a false positive. A string that is just 40 hexadecimal characters could be an API key, a Git commit hash, or a hash of a file. GitHub therefore handles different kinds of patterns differently.
Secret types
Every pattern has a secret type. This is a stable identifier, and it appears in several places:
- In the alert list, as a display name such as "GitHub Personal Access Token".
- In the REST API, as
secret_type(the identifier) andsecret_type_display_name(the label shown in the UI). - In filters, both in the alert search box and in the
secret_typequery parameter of the API. - In push protection messages, which name the type that was detected.
Treat the identifier as the key you automate against. Display names are meant for people and can be reworded. Identifiers follow a lowercase, underscore-separated convention, for example github_personal_access_token or aws_access_key_id. Look up the exact identifier for any type in GitHub's "Supported secret scanning patterns" documentation.
The four families of patterns
Patterns fall into four families. The family tells you how much to trust a match.
| Family | What it matches | Confidence | Push protection |
|---|---|---|---|
| Provider patterns | Credentials issued by a specific service, such as a cloud provider, a payment processor, or GitHub itself | High | Many, but not all, are supported |
| Non-provider patterns | Credentials with a recognizable format but no single issuer, such as private keys, connection strings, and HTTP authorization headers | Medium | A smaller set, depending on the pattern |
| Generic secrets | Passwords and similar values found by an AI-based detector instead of a fixed format | Lower | Not a blocking category in the same way |
| Custom patterns | Regular expressions you or your organization define | As good as your regex | Optional, when you enable it for that pattern |
Generic secret detection and custom patterns are covered in later chapters. This chapter concentrates on provider patterns, because they are the foundation and the part you will see most often.
Provider patterns
A provider pattern targets credentials issued by one service. GitHub maintains these patterns, many of them together with the service providers. The provider knows its own token format best, including prefixes, lengths, and checksums. The next chapter covers how providers take part in this and what happens to a token once it is detected.
Some provider credentials come as a pair, such as an access key ID plus a secret access key. These cases behave in one of two ways:
- Each half has its own pattern and its own secret type. An ID by itself is often not sensitive, so it may be reported at lower priority or not at all.
- The pair is reported together when both halves appear close together in the same file.
Check the supported patterns table to see which behavior applies to the credential you care about.
Non-provider patterns
Some credentials have no issuer but are still unmistakable. A PEM-encoded private key starts with a -----BEGIN ... PRIVATE KEY----- header. A database connection string has a scheme, a user, and a password in a fixed layout. These patterns are broader than provider patterns, so GitHub treats them as a separate group. In the alert list they can be filtered apart from provider alerts so that they do not drown out higher-confidence results.
What decides whether a pattern blocks a push
Secret scanning and push protection read from overlapping but different lists. Push protection scans your commits before they are accepted, and it interrupts the developer. A false positive there costs real time, so it is limited to patterns with a low false-positive rate.
This produces a common situation: a secret type that raises alerts after a push but never blocks one. If you expect a block and do not get one, check the "push protection" column for that secret type in the supported patterns documentation before looking for a configuration problem.
The order of checks in the diagram is a simplification. GitHub evaluates patterns independently, and one string can in principle match more than one of them.
Working with secret types through the API
Because the secret type is the stable key, it is the right thing to group and filter by when you review a repository. This command counts open alerts by type, with the largest groups first:
gh api --paginate 'repos/OWNER/REPO/secret-scanning/alerts?state=open' \
--jq '.[].secret_type' | sort | uniq -c | sort -rnReplace OWNER/REPO with your repository. The output is one line per type, with a count in front. A repository with a few types and large counts usually has a systemic problem, such as a test suite that commits real tokens. A long tail of single alerts is more likely individual mistakes.
To narrow a listing to specific types, pass a comma-separated list in the secret_type parameter:
gh api 'repos/OWNER/REPO/secret-scanning/alerts?secret_type=github_personal_access_token,aws_access_key_id' \
--jq '.[] | {number, secret_type_display_name, state}'The identifiers must match the documentation exactly. A misspelled identifier does not match anything, so you get an empty list instead of an error, and an empty list can look like good news. If a filtered query returns nothing that you expected to see, rerun it without the filter to confirm.
The listing endpoint also accepts a validity filter. It is only useful once validity checks are on, which a later chapter covers.
Where coverage ends
Pattern matching has predictable blind spots. Knowing them keeps you from treating a clean alert list as proof that no secrets exist.
- Unrecognized formats. A secret from a service with no pattern, or an internal token, is invisible until you add a custom pattern.
- Low-structure secrets. A password in a config file has no prefix to match. Generic detection may catch it, but it is a best-effort aid.
- Transformed values. A secret that is Base64-encoded, split across lines, or built by string concatenation does not look like the pattern any more.
- Changed formats. Providers sometimes change token formats. Patterns are updated, but there can be a gap, and old-format tokens may still be valid.
- Excluded or unscanned content. Paths you exclude are not scanned, and the types of content that are scanned depend on the feature and repository type.
Availability by repository type
Which patterns run, and whether you get alerts at all, depends on repository visibility and plan. Public repositories receive partner-pattern detection by default. For private and internal repositories, secret scanning for users and push protection are part of GitHub's paid security offering for organizations and enterprises. The packaging and product names for these features have changed over time, so confirm the current terms in the GitHub documentation for your plan before you plan a rollout. The enabling chapter covers configuration.
Reading a detection correctly
When you open an alert, take three steps in order:
- Read the secret type. This tells you which service or format it belongs to, and so who can revoke it.
- Judge the family. A provider match on a distinctive token deserves immediate action. A generic match needs a human to look at the context first.
- Check where it was found. The location (file path, commit, branch, issue, or pull request text) tells you how far it was exposed and whether it is a test fixture.
Alerts triage and remediation are covered in later chapters. The point here is that the secret type is the first fact you have, and it shapes everything after it.
Exercise
Your team expects a blocked push when someone commits a certain internal service token, but the push goes through. A secret scanning alert for it appears a few minutes later. Give two likely reasons, and say what you would check first.
Show answer
The token's secret type may not be supported by push protection, since that list is a smaller subset of the patterns that raise alerts. It may also be a custom pattern that has not had push protection enabled. Check the secret type in the alert, then look it up in the supported patterns documentation (for a provider type) or in the custom pattern settings (for a custom type) to see whether push protection is enabled for it.
Exercise
A script filters alerts with secret_type=github_personal_acces_token and returns an empty list. Why is this misleading, and how do you verify?
Show answer
The identifier is misspelled (acces), so it matches no alerts, and the API returns an empty list instead of an error. Rerun the query without the secret_type filter, or group alerts by type with --jq '.[].secret_type', and compare the identifiers with the documentation.