Sub topic 9
Working through secret scanning alerts
This chapter covers how to read a secret scanning alert, decide how urgent it is, and close it with an honest resolution reason. It assumes you can already read the Security tab of a repository and run gh commands. It also assumes you know what the alert sources are: committed secrets found by scanning, and secrets let through by a push protection bypass. Remediation (revoking, rotating, cleaning history) has its own chapter. Here the focus is the triage decision that comes first.
What an alert represents
Secret scanning examines the full Git history of every branch, plus issues, pull requests, and discussions. When it finds a string matching a supported pattern, it opens an alert. An alert is a record about one secret, not one occurrence. If the same token appears in ten commits, you get one alert with ten locations.
Each alert carries these fields:
| Field | What it tells you |
|---|---|
| Secret type | Which pattern matched, such as a cloud provider key or a personal access token |
| Locations | The commits, files, and lines (or issue and pull request text) where the value appears |
| Validity | `active`, `inactive`, or `unknown`, when validity checks are available for that type |
| Push protection bypassed | Whether someone pushed the secret after overriding a block, and with which reason |
| State | `open` or `resolved`, plus a resolution when resolved |
Only people with the right access can see alerts. Repository admins, organization owners, security managers, and users granted the secret scanning alerts permission can view them. Ordinary contributors cannot, because the alert page shows the secret itself.
A triage workflow
Triage is a short sequence of questions. Answer them in order for every open alert.
1. Is it a real credential?
Open the alert and look at the first location. Context usually settles this fast. A value in test/fixtures/ or in a README example is probably a placeholder. A value in config/production.yml is probably real. If you cannot tell, treat it as real. Misclassifying a live key as noise costs far more than a few minutes of checking.
2. How urgent is it?
If the secret type supports validity checks, GitHub contacts the provider to see whether the token still works. active means it works now, so these go to the top of the queue. unknown means GitHub could not determine the status, so handle it as if it were active. inactive means the provider rejected it, which lowers urgency but does not remove the need to look.
Other factors matter as much as validity:
- Repository visibility. A secret in a public repository should be assumed already harvested, because automated scrapers watch public pushes.
- Privilege of the credential. A read-only key for a sandbox differs from an admin token for production.
- Bypass flag. An alert created by a push protection bypass means a person saw the warning and chose to continue. Check the bypass reason, and ask the person why if it looks wrong.
3. Act on the credential, then close the alert
The order matters. Revoke or rotate the credential at the provider first. Closing the alert does not disable anything. It only changes what GitHub shows you.
Choosing the resolution reason
When you close an alert, GitHub requires a resolution. Pick the one that matches what actually happened, because the reasons feed reporting and later audits.
| Resolution | API value | Use it when |
|---|---|---|
| Revoked | `revoked` | The credential was real and has been revoked or rotated at the provider |
| False positive | `false_positive` | The matched text is not a credential |
| Used in tests | `used_in_tests` | The credential is real-looking but belongs to a test setup and grants nothing of value |
| Won't fix | `wont_fix` | You accept the risk, for example the secret is already expired and not worth tracking |
| Pattern edited / deleted | `pattern_edited`, `pattern_deleted` | A custom pattern was changed or removed, which closes its alerts |
The last row applies to alerts from custom patterns. GitHub sets those resolutions itself when you edit or delete the pattern.
You can attach a comment to any resolution. Use it. A line such as "Rotated in vault on 2026-12-04, ticket SEC-118" saves the next reviewer from repeating your investigation.
Triage with the REST API
The Security tab is fine for a handful of alerts. For many alerts or many repositories, use the API through gh. This lists open alerts with the fields you need for ranking:
gh api 'repos/OWNER/REPO/secret-scanning/alerts?state=open' \
--jq '.[] | {number, secret_type_display_name, validity, push_protection_bypassed}'Pass --paginate as well if the repository can have more than 30 open alerts. Without it, gh api returns only the first page.
To see where a specific alert appears, request its locations:
gh api repos/OWNER/REPO/secret-scanning/alerts/42/locations \
--jq '.[] | {type, path: .details.path, commit: .details.commit_sha}'Location entries for commits include the path and commit SHA. Entries for issues or pull requests carry URLs instead of paths, so path can come back null for those.
Once the credential has been revoked, close the alert:
gh api --method PATCH repos/OWNER/REPO/secret-scanning/alerts/42 \
-f state=resolved \
-f resolution=revokedAdd -f resolution_comment='Rotated in vault, ticket SEC-118' to record the note. A request with state=resolved and no resolution is rejected. A revoked resolution is only accurate after the revocation has really happened, so do not put this call at the start of a script.
To reopen an alert that was closed by mistake, send -f state=open. Reopening is the correct fix for a wrong resolution, and it keeps the history honest.
Common errors
- Closing the alert before revoking. The dashboard looks clean while the token still works. Make revocation the first step and the API call the last.
- Assuming a deleted commit fixed it. Removing the line or even force-pushing does not end exposure. Forks, clones, caches, and pull request refs may still hold the value. The alert often stays open for the same reason, since the secret still exists in history GitHub can reach.
- Ignoring
unknownvalidity. Many secret types have no validity check. Unknown is not a safe signal. - Triage by age. An alert from two years ago can be the most dangerous if the key was never rotated. Sort by validity and privilege, not by date.
- Treating one alert as one leak. Check all locations. A secret may also appear in an old branch or in a pull request description that your cleanup missed.
- Dismissing bypass alerts without a conversation. The bypass reason (used in tests, false positive, fix later) is the developer's claim. Verify it before accepting it.
- Missing alerts because of permissions. If your
gh apicall returns 404 or 403, the token may lack the secret scanning alerts permission, or the feature may not be enabled on that repository.
Keeping the queue healthy
A queue of open alerts that nobody owns becomes background noise. A few habits help:
- Assign a rotation or owner for alert review, and set a target time for active credentials.
- Use
paths-ignorein.github/secret_scanning.ymlfor fixtures that always hold dummy values, so real alerts stand out. Do not exclude paths that might hold real configuration. - Review closed alerts periodically, filtering for
false_positiveandwon't fix. A spike in either points to a pattern problem or a team habit worth fixing. - When the same secret type keeps appearing, treat it as a workflow problem and change how that team handles credentials.
Exercise
An alert shows an active cloud provider key in deploy/prod.env, found in a repository that was made public last week. A teammate suggests closing it as used_in_tests because "the file is old". What do you do, and which resolution do you eventually use?
Show answer
Do not close it yet. The key is active, the repository is public, and the file name suggests production use, so revoke and rotate the key at the provider first and check the provider's logs for unauthorized use since the repository became public. Once the key no longer works, close the alert with revoked and a comment recording the rotation. used_in_tests would be a false claim here.
Exercise
Write the gh api command that closes alert 17 as a false positive and records the reason "Documentation placeholder in README example".
Show answer
gh api --method PATCH repos/OWNER/REPO/secret-scanning/alerts/17 -f state=resolved -f resolution=falsepositive -f resolutioncomment='Documentation placeholder in README example'