Leaked API Key on GitHub? Revoke It Before Cleaning Git History

If an API key reaches a GitHub repository, deleting the visible line is not enough. The urgent question is whether the credential can still authorize access. Secure that credential with its issuer first; then repair the application, investigate exposure and decide whether repository-history cleanup is necessary.

Evidence and scope: CoreSecTech checked official GitHub documentation on 7 October 2026. This is a documentation-based response guide, not a reproduced incident. We did not expose a test credential, inspect a customer repository or measure detection times. The handoff checklist and evidence record below are CoreSecTech recommendations. Use them only for repositories and services you are authorized to manage.

What changed: new detectors, not automatic incident resolution

GitHub’s 5 October 2026 changelog added five secret types: lovable_api_key, logfire_token, pydantic_ai_gateway_api_key, supabase_oauth_access_token and supabase_scoped_personal_access_token. Lovable Labs also joined its secret-scanning partner program. This is expanded detection coverage, not evidence that a particular repository leaked a key.

GitHub distinguishes provider notifications from user-facing alerts. A supported partner secret found publicly can be reported to its issuer for action. Do not interpret that notification as a guaranteed revocation or a completed investigation. Confirm the credential’s state with the provider. The announcement does not establish that every Supabase key format, every Pydantic credential or every push-protection capability is covered.

1. Identify the credential and assign a response owner

Keep the raw value out of chat messages, public issues, screenshots and AI prompts. CoreSecTech recommends a restricted incident record containing the provider, credential identifier, repository, affected commit or alert URL, first known exposure time, responsible owner and dependent services. An identifier is preferable to copying the credential itself.

If you have access, open the repository’s Security and quality → Vulnerability alerts → Secret scanning area. Open the relevant alert and inspect its locations. GitHub documents filters including secret-type: and provider:; use the supported name rather than guessing a filter. See viewing and filtering alerts. If the tab or alert is unavailable, ask an authorized repository administrator. Do not broaden your access permissions just to follow this guide.

A discovery timestamp is not necessarily the original exposure timestamp. Record both when known. Keep unknown dates explicitly unknown; do not estimate an exposure window from the alert’s position in a list.

2. Check coverage before trusting an empty alert list

GitHub’s secret-scanning overview says public repositories are scanned automatically for free. Organization-owned private and internal repositories require GitHub Secret Protection enabled on supported GitHub Team or Enterprise Cloud plans. Check your actual repository’s eligibility and configuration; a public-repository rule is not a promise of free private-repository coverage.

Scanning includes Git history across branches, and GitHub periodically rescans when new secret types are added. There is no guaranteed completion time in that statement. An older commit can therefore matter even when the current file looks clean. Partner notifications are separate from repository user alerts; their absence from that list is not proof that no provider notification occurred.

Consult the supported-patterns reference for the exact secret type and its capabilities. Detection, partner reporting, push protection and validity checking are separate features. A validity check is not supported for every pattern; “unknown” is not the same as revoked. An empty alert list does not prove that all credentials are safe.

3. Contain the credential without hiding an outage risk

GitHub’s leaked-secret remediation guide prioritizes revocation for high-risk exposure. Use the issuer’s official portal or documented process. If you lack access, escalate to the credential owner immediately. Do not paste the key into an unofficial “key checker” or make exploratory API calls to see what data it can access.

SituationImmediate responseEvidence to retain
Active production credential exposed publiclyEscalate and prioritize revocation; coordinate affected services.Issuer confirmation and time of containment.
A replacement is needed to avoid an outageAn authorized owner may deploy the replacement promptly, then revoke the old credential.Deployment verification and old-credential revocation.
Validity is unknownAsk the issuer/owner to verify state; do not assume the key is harmless.Who checked it, when, and the reported state.
Provider says the key was already revokedVerify that dependent services use an approved replacement.Revocation confirmation and service checks.

On narrow screens, scroll the table horizontally. The replacement-first option is a brief, coordinated transition—not permission to leave an exposed credential active indefinitely. If unauthorized activity is suspected, involve the security lead before prioritizing convenience over containment. Never restore service by reactivating the leaked key.

4. Repair dependencies and investigate what happened

CoreSecTech recommends a dependency checklist: application runtime configuration, deployment platform, CI jobs, scheduled tasks and authorized integrations. For each, record an owner, replacement location and a service-specific verification step. Avoid one person assuming that another has updated production. Store the new value in the approved secret-management system, not another source file. For CI-specific controls, consult GitHub Actions secret storage; it is not a substitute for the credential issuer’s revocation process.

Review provider audit records and relevant GitHub security or organization logs through authorized access. GitHub documents personal security-log review separately; use the correct log for your investigation. Record suspicious activity separately from confirmed misuse. An exposure is not proof of data theft, while an absence of visible events is not proof that nothing happened. State the time range and logs actually reviewed, including any retention or access gaps. Do not publish account identifiers or confidential log contents.

Successful application requests with the replacement establish that those checked functions work; they do not establish that the old credential has been revoked. Keep these two verification steps separate in the incident record.

5. Remove the exposure; assess history cleanup separately

Remove the credential from current source and prevent another commit from introducing it. A new commit does not erase the older one. GitHub’s sensitive-data removal guide warns that history rewriting can change commit hashes, disrupt collaborators and leave copies in forks or clones. Rewriting history cannot invalidate a credential or remotely erase somebody else’s copy.

Do not improvise a force-push as an emergency response. After containment, have the repository owner and security lead decide whether sensitive material still requires coordinated history removal. Follow the complete official procedure, including collaborator cleanup and any support involvement that applies. This article deliberately supplies no destructive cleanup command.

For prevention, review staged changes before committing, avoid hardcoded credentials and use approved runtime secret injection. A local environment file still contains sensitive data: keep it out of source control and avoid exposing it in logs. If sensitive files are not meant to be tracked, configure the repository’s ignore rules; that is prevention, not erasure of an existing exposure.

6. Close the alert only after remediation

GitHub’s alert-resolution instructions say removing a token from the repository does not automatically close its alert. After confirming revocation and recording remediation, use Close as with the accurate reason. Closing an alert changes its tracking state; it does not revoke a key at its issuer. Do not choose “false positive” merely because you deleted the file.

Before the handoff is complete, confirm: the old credential is invalidated; necessary replacements are stored safely; affected services were checked; relevant logs were reviewed or gaps recorded; cleanup decisions have an owner; and the alert’s reason matches the evidence. Keep unresolved investigation work open separately even if credential containment is complete.

7. Prevent the next leak without overstating protection

GitHub describes push protection as a control that can block supported secrets before they reach the repository. Review applicable coverage and bypass policy with your administrator. Do not bypass a warning simply to complete a deployment. A scanner is a safety net, not permission to put credentials in source code, and supported patterns do not cover every possible secret.

Frequently asked questions

Does making the repository private solve the leak?

It can reduce continued public visibility, but it does not revoke the credential or recover copies already obtained. Coordinate containment with the issuer rather than treating visibility as remediation.

Should I deliberately commit a key to test a detector?

No live credential is needed for this response workflow. Do not create a real exposure to confirm a detector. Any separate validation exercise needs authorization and a controlled test plan.

Does a newly supported pattern mean old leaks are fixed?

No. Expanded detection may surface an exposure; it does not establish revocation, application recovery or an investigation outcome. Verify each separately.

Final check: prove containment, not just a clean file

A useful response ends with evidence that the leaked credential no longer authorizes access, required services use a safe replacement and remaining exposure or investigation tasks are documented. A clean file, a closed alert and a working application answer different questions. Do not substitute one for the others.