caelo

Caelo › Guides › GitHub secret scanning alert

Got a GitHub secret scanning alert? What to do next

By Arthi Arumugam, Irth Labs · Published · Updated

Short answerRevoke or rotate the secret at its provider first. GitHub's docs say removing it from the code, pushing a new commit or recreating the repository does not stop it being exploited. Then replace it with an environment variable, decide whether to clean history, and close the alert as Revoked. Alerts do not close on their own.

What the alert tells you

  • Where: the file, commit and branch where GitHub found the secret. Secret scanning covers the whole history, so the line may already be gone from your latest code.
  • Validity: Active means GitHub checked with the provider and the secret works. Inactive and Unknown are the other states. GitHub checks GitHub tokens by default; checks for partner secrets need GitHub Team or Enterprise Cloud with Secret Protection.
  • Partner alerts: for public repositories, GitHub sends supported secrets directly to the provider, who decides whether to revoke it, issue a new one or contact you. That is why you may get an email from the provider as well.

Fix it, step by step

Before: the secret is a string in the code

const client = new Client({ apiKey: "ghp_..." });

After: read on the server from the environment

const client = new Client({ apiKey: process.env.GITHUB_TOKEN });

List open alerts and close one as revoked with the GitHub CLI

gh api repos/OWNER/REPO/secret-scanning/alerts --jq '.[] | {number, secret_type, state}'
gh api -X PATCH repos/OWNER/REPO/secret-scanning/alerts/NUMBER \
  -f state=resolved -f resolution=revoked
  1. Revoke or rotate the secret in the provider's dashboard. GitHub calls this "the most important remediation step".
  2. Check the provider's logs for use you did not make while the secret was exposed.
  3. Replace the literal in your code with an environment variable read on the server, as below, and set the new value in your host.
  4. Decide whether to rewrite git history. It does not undo the leak, but it stops the next person who clones from finding the old value.
  5. Close the alert with the reason that matches what you did. For a real key you rotated, that is Revoked.

Which close reason should you pick?

These are the four resolution values in GitHub's REST API: revoked, false_positive, used_in_tests and wont_fix.

ReasonPick it when
RevokedYou revoked or rotated the secret at the provider. This is the right answer for almost every real key.
False positiveThe match is not a secret at all, for example a random string that happens to look like one.
Used in testsIt is a test credential that grants nothing real.
Won't fixYou accept the risk. For a live production key, this is almost never the right choice.

Push protection: blocked before it lands

Push protection blocks pushes that contain supported provider secrets. By default, anyone with write access can bypass it by giving a reason: it's used in tests, it's a false positive, or I'll fix it later. If the secret is real, do not bypass it: take it out of the commit and use an environment variable.

Check it automatically before you push

Caelo checks the files in your project on your machine for 12 provider key patterns (Stripe, OpenAI, Anthropic, AWS, GitHub, SendGrid, Slack, Google, Supabase and private keys), plus Supabase service_role JWTs, before anything reaches GitHub. It does not read git history, which GitHub secret scanning does, so the two work well together: Caelo while you build, GitHub after you push.

1. Run the free local check

npx caelo .

Caelo is a free, open source (MIT) command line tool and MCP server from Irth Labs that checks the files of an AI-built app for exposed API keys, Supabase and Firebase misconfigurations and .env files with real values. It runs on your machine, uploads nothing and uses no AI model. Each finding comes with a plain-English fix.

2. Act on a finding

Follow the fix in your report and run Caelo again. If Git could commit an untracked file containing secrets, preview a US$19 quick fix for that file.

For findings that need an engineer, Irth Labs offers a US$490 App Health Check. You receive a written report within 48 hours and a fixed repair quote. The fee counts toward the repair if you proceed.

Book the App Health Check See repair services

Questions

I removed the secret in a new commit. Is the alert resolved?

No. The secret is still in the earlier commit, and GitHub says secret scanning does not close alerts automatically when the token is removed. Revoke the secret, then close the alert.

Are private repositories scanned?

Only when they belong to an organization on GitHub Team or Enterprise with Secret Protection enabled. Secret scanning runs for free on public repositories.

How do I know if it is a false positive?

Look at the validity status if your plan shows it, and at the provider's dashboard: if the key exists there, it is real. When in doubt, rotate it. That costs little and ends the question.

Sources