skip to content

A GitHub secret scanning alert flags a live cloud key — what is your response order?

level: seniorimportance: must knowfreq 65%

answer

  1. Sequence is what is being graded
  2. The cheapest fix is the one that expires it
  3. GitHub cannot tell you if it was used
  4. Closing the alert changes nothing
  5. Forks and cached views outlive a rewrite

basics

~20 s

Revoke and reissue the credential first, then check the provider's logs for misuse, then close the GitHub alert with the revoked resolution, and only then clean history. Rewriting commits does not un-leak anything already fetched.

solid answer

~60 s

Order matters and interviewers grade you on it. **1. Revoke.** The moment a live credential appears in a repository, treat it as compromised — the commit is fetchable, and on a public repository automated scrapers are faster than you are. Revoke and reissue at the provider; nothing else reduces risk. **2. Investigate.** Use the provider's own audit trail to see whether the key was used from anywhere unexpected while it was live; GitHub's validity check tells you the credential is active but not whether it was abused. **3. Resolve the alert.** Close it with the right resolution — `revoked`, `false_positive`, `used_in_tests`, or `wont_fix` — and a comment; closing the alert is bookkeeping and changes nothing about the credential. **4. Clean up.** Purge it from history and note that GitHub can keep unreachable commits addressable by SHA and that forks in the repository network may retain them, so contact GitHub Support if you need cached views removed. **5. Prevent.** Turn on push protection so the next one is blocked instead of triaged.

code

bash · 9 lines
bash
curl -X PATCH \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer $GITHUB_TOKEN" \
  https://api.github.com/repos/OWNER/REPO/secret-scanning/alerts/7 \
  -d '{
        "state": "resolved",
        "resolution": "revoked",
        "resolution_comment": "Key deleted at provider and replaced 2026-08-19"
      }'

go deeper

for a junior

Remember the headline rule: a committed credential must be revoked and replaced. Deleting the file or rewriting the commit does not make the key stop working.

for a middle

Be able to give the full order and explain why revocation precedes cleanup, and know that GitHub alerts are closed with an explicit resolution such as revoked or false positive.

for a senior

Show incident thinking: exposure window, provider audit trail, secondary credentials created with the leaked one, and realistic limits on what a history rewrite achieves on GitHub.

for a principal

Own the systemic side — whether credentials can be rotated at all without an outage, who is on call for these alerts, and what upstream change stops the same class of leak recurring across the organisation.

## Why the order is the answer Almost every candidate knows all five actions. The differentiator is sequencing, because the sequence encodes what you believe about exposure. A credential in a repository has already been read by everything with access to that repository — clones, forks, CI runners, caches, mirrors, and on public repositories, automated harvesters that watch the public event stream and try keys within seconds. Every minute spent rewriting history before revoking is a minute the key still works. ## Step 1: revoke and reissue Go to the issuing provider and invalidate the credential. Then create a replacement and deploy it wherever the old one was legitimately used. Yes, this can cause an outage in a service that was depending on the leaked key — that outage is the cost of the leak, and it is smaller than the cost of leaving a live key public. If rotation is genuinely impossible without a coordinated change, that is a finding about your credential design, not a reason to delay. On public repositories the partner programme may have got there first: GitHub forwards matches for partner patterns to the issuing provider, and some providers revoke automatically or email the account owner. Treat that as a bonus, never as your plan. ## Step 2: assume use, then check The question after revocation is what happened while the key was live. GitHub cannot tell you that; only the provider's audit trail can. Look for calls from unfamiliar addresses or regions, unusual API calls, new resources, or new credentials created using the leaked one — the last is how a short exposure becomes a persistent foothold. Fix the scope of the exposure, not just the key: if the credential could create other credentials, revoking it alone may not be enough. Validity checks on the alert are triage input for prioritising among many alerts. "Active" means rotate now. "Inactive" means the key cannot be used today; it does not mean it was never used. ## Step 3: resolve the alert properly An alert is closed with a **resolution**, and the vocabulary is meaningful: `revoked` for a real credential you have invalidated, `false_positive` for something that only looked like a key, `used_in_tests` for a fixture, and `wont_fix` for an accepted risk. Add a resolution comment saying what you did — this is what a future auditor or the next engineer reads. Resolving an alert has no effect on the credential; it is the record of your decision, and mass-closing alerts to clear a dashboard is exactly the behaviour that makes the whole feature untrustworthy. ## Step 4: clean history, with realistic expectations Removing the credential from history is worth doing — it stops the next person copying it out of an old commit, and it keeps a future scan clean. It is also the step candidates over-value. Two GitHub-specific facts to name: - Commits made unreachable by a rewrite can remain **addressable by their SHA** on GitHub, and pull-request views can retain content, so a rewrite does not necessarily make the value unreachable through the web interface. Where that matters, GitHub Support can be asked to remove cached views and stale references. - Repositories in the same **fork network** may retain the commit even after you rewrite yours, because a fork is not your repository. And of course every existing clone, every CI log line that echoed the value, and every backup still has it. This is why revocation is step one and cleanup is step four. ## Step 5: close the loop Enable push protection on the repository if it was not on, so the next occurrence is a rejected push rather than an incident. If the credential type was not covered by any pattern, that is the trigger for a custom pattern. If the same team leaks the same class of credential repeatedly, the real fix is upstream — the credential should not have been in a position to be pasted into a file at all. ## Communicating it A crisp senior answer sounds like: "Revoke and reissue immediately — assume it is compromised. In parallel, pull the provider's audit log to see if it was used and whether it minted anything else. Then resolve the alert as revoked with a note, remove it from history knowing forks and cached views may still hold it, and turn on push protection so it cannot happen the same way again." That is under sixty seconds and hits every point that matters.

  • Why is rewriting history the wrong first move?
    Because it does not invalidate the credential. The commit has already been fetchable by every clone, fork, CI runner and, on public repositories, automated scrapers. Rewriting changes what future readers see while the key still works. Revocation is the only action that reduces risk, so it comes first.
  • The validity check says the leaked key is inactive. Is the incident over?
    No. Inactive means it cannot be used now — often because the provider already revoked it through the partner programme. It says nothing about what happened while it was live. You still check the provider's audit trail for use during the exposure window, and for any secondary credentials or resources created with it.
  • After a history rewrite, why might the secret still be reachable on GitHub?
    Unreachable commits can remain addressable by their SHA, and pull-request views may retain the content; forks in the same network can also still hold the commit. If the exposure genuinely needs to be removed from GitHub's surfaces, that is a request to GitHub Support, not something a local rewrite achieves.
  • How do you resolve the alert once the key is rotated?
    Close it with the revoked resolution and a comment recording what was rotated and when. The other resolutions — false positive, used in tests, won't fix — describe genuinely different decisions, and using them accurately is what keeps the alert list meaningful for whoever reviews it later.

saying these in an interview costs you the question

  • Rewrites history first and rotates later
  • Closes the alert as the primary remediation
  • Treats an inactive validity result as case closed
  • Assumes forks and cached views are cleaned by a rewrite
  • Relies on the partner programme to revoke for them

context