# Got a GitHub secret scanning alert? What to do next

Canonical: https://caelo.sh/guides/github-secret-scanning-alert-what-to-do
Published: 2026-11-27 · Updated: 2026-11-27 · Arthi Arumugam, Caelo by Irth Labs

**Short answer:** Revoke 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

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

After: read on the server from the environment

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

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

```bash
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`.

| Reason | Pick it when |
| --- | --- |
| Revoked | You revoked or rotated the secret at the provider. This is the right answer for almost every real key. |
| False positive | The match is not a secret at all, for example a random string that happens to look like one. |
| Used in tests | It is a test credential that grants nothing real. |
| Won't fix | You 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.

- [Install Caelo: npx caelo . or the MCP server](/)
- [How Caelo compares with gitleaks, TruffleHog, Semgrep and others](/compare)

## Check your own app

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. Follow the fix in the report and rerun Caelo. For an untracked, unignored file containing secrets, preview the US$19 quick fix. https://caelo.sh/fix
3. For an engineer's assessment, book the US$490 App Health Check. Irth Labs delivers a report and fixed repair quote, with credit toward the repair. https://www.irthlabs.com/start?service=app-health-check

## 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

- [GitHub docs: Remediating a leaked secret.](https://docs.github.com/en/code-security/tutorials/remediate-leaked-secrets/remediating-a-leaked-secret)
- [GitHub docs: Resolving secret scanning alerts.](https://docs.github.com/en/code-security/how-tos/manage-security-alerts/manage-secret-scanning-alerts/resolving-alerts)
- [GitHub docs: Evaluating alerts (validity checks).](https://docs.github.com/en/code-security/secret-scanning/managing-alerts-from-secret-scanning/evaluating-alerts)
- [GitHub docs: Secret scanning for partners.](https://docs.github.com/en/code-security/secret-scanning/introduction/about-secret-scanning-for-partners)
- [GitHub docs: About push protection.](https://docs.github.com/en/code-security/secret-scanning/introduction/about-push-protection)
- [GitHub REST API: Secret scanning alerts.](https://docs.github.com/en/rest/secret-scanning/secret-scanning)
- [Caelo source: every rule in lib/rules.js.](https://github.com/arthi-arumugam-git/caelo/blob/master/lib/rules.js)

## Related guides

- [I leaked an API key or the Supabase service_role key. What do I do now?](https://caelo.sh/guides/leaked-api-key-what-to-do)
- [API keys in mcp.json: are your MCP config files leaking secrets to git?](https://caelo.sh/guides/api-keys-in-mcp-json)
- [What free tool can check a Lovable, Bolt or Cursor app for security issues before launch?](https://caelo.sh/guides/free-security-scanners-for-ai-built-apps)
- [Committed your .env file to GitHub? What to do, in order](https://caelo.sh/guides/env-file-committed-to-github)
