Sub topic 11
Validity checks: prioritizing active secrets
This chapter assumes you can read a secret scanning alert list and understand the difference between a leaked secret and a revoked one. It covers what validity checks report, how to enable them, and how to use the result to order your work.
What a validity check does
A leaked credential is only dangerous while it still works. A validity check asks the credential's provider whether a detected token is currently active. GitHub then records the answer on the alert, so you can see which alerts need action first.
Validity checks apply to supported provider patterns only. They do not apply to custom patterns, and not every provider supports them.
The validity statuses
Each alert carries one of these values in its validity field.
| Status | Meaning | What to do |
|---|---|---|
| `active` | The provider confirmed the secret still works. | Revoke and rotate now. |
| `inactive` | The provider reports the secret no longer works. | Verify, then close the alert. Review history for related secrets. |
| `unknown` | GitHub could not determine the status. | Treat it as possibly active until you check with the provider. |
The unknown status is common. It appears when a provider does not support checks, when a check has not run yet, or when the provider could not be reached. It does not mean the secret is safe.
Enabling validity checks
Validity checks are a setting of secret scanning, found under the repository's Settings, in the Advanced Security section. Organization owners can also enable them for many repositories at once. Availability depends on your plan, so confirm the option appears for your repository.
Once enabled, GitHub checks supported secrets when it creates an alert. It also rechecks them later, so a status can change from active to inactive after you revoke the credential.
Reading validity in the API
The alert list from the earlier automation example already prints the validity field. You can filter to the alerts that need attention first:
gh api 'repos/OWNER/REPO/secret-scanning/alerts?state=open&validity=active' \
--jq '.[] | {number, secret_type_display_name, validity}'The validity query parameter accepts active, inactive and unknown, and you can pass several values separated by commas. Replace OWNER/REPO with your repository.
Using validity to prioritize
The flow below shows how validity shapes your order of work.
Work through the alerts in this order:
- Handle every
activealert first. Revoke the credential at its provider, rotate it, and then close the alert. - Investigate
unknownalerts next. Ask the provider or check the credential's own console. - Review
inactivealerts last. Confirm the secret is really dead, then close the alert.
Common mistakes
- Closing an
inactivealert without looking. The credential may have expired, but the same file could hold other secrets, or the token could be reusable in another form. - Ignoring
unknown. A missing status is a gap in information, not a safe result. - Trusting a stale status. A check reflects the moment it ran. Revoke first, then confirm that the status changes.
- Skipping rotation for inactive secrets. If a pattern of leaks exists, find the cause with the practices from the prevention chapter.
Exercise
An open alert shows validity: unknown for a cloud provider token. A teammate says it can be closed because it is not marked active. What should you do?
Show answer
Do not close it yet. Unknown means GitHub could not confirm the status, so treat the token as possibly active. Check with the provider or its console. If the token works, revoke and rotate it, then close the alert as revoked. If it is already dead, close it with the matching reason.