If an API key, access token, private key, or cloud secret appears in a public repository, build log, ticket, chat, or alert, treat it as potentially compromised. This guide provides a provider-neutral response workflow: confirm the exposure without spreading it, revoke or disable the credential, issue a replacement, review access and activity, preserve evidence, check for cost or data impact, and record follow-up controls. Use the checkpoints as a repeatable secret-leak incident response checklist, then revisit them during routine security reviews.
Overview
An exposed secret is not automatically proof that an attacker used it, but you should avoid relying on secrecy after disclosure. A credential may have been copied by a crawler, logged by a third-party system, included in a notification, or viewed by someone outside the intended audience. The safest assumption is that the secret is no longer confidential until the relevant provider confirms that it has been revoked or rendered unusable.
First identify what was exposed and what it could reach. An API key limited to a test service is different from a cloud access key with permission to change infrastructure, read customer data, or create additional credentials. A short-lived token may expire soon, while a private signing key can remain dangerous until every system that trusts it has been updated. The response should match the credential's permissions, lifetime, environment, and data access.
Do not paste the secret into an incident ticket, chat room, email, or new repository while investigating. Record a redacted identifier, such as the last four characters, the service name, the location of exposure, and the approximate discovery time. If you need to share evidence, use an approved restricted channel and limit access to people handling the incident.
Secret-exposure severity guide
| Exposure type | Typical concern | Immediate priority |
|---|---|---|
| Publicly visible API key with unclear limits | Unauthorized API use, quota consumption, or access to associated data | Revoke or restrict it promptly; inspect usage and billing |
| Cloud access key or token with write permissions | Infrastructure changes, persistence, data access, or new credential creation | Disable it urgently and review activity and privilege escalation paths |
| Database password or connection string | Direct access to stored data or operational systems | Rotate the credential, restrict network access, and review database logs |
| Signing, encryption, or webhook secret | Forged tokens, altered integrations, or verification bypass | Rotate according to the system's key-transition process and validate consumers |
| Short-lived, narrowly scoped test token | Limited unauthorized activity during its valid period | Revoke or allow expiry, then confirm scope and test-environment isolation |
Severity can increase when the secret was public, remained exposed for an unknown period, had broad permissions, or was used by production systems. If regulated, customer, employee, or payment data may be involved, follow your organization's incident and notification procedures rather than making an independent disclosure decision.
What to track
Track the incident as a timeline, not just a ticket marked “fixed.” Capture the following fields:
- Credential identity: service, account or project, environment, credential type, and a redacted fingerprint.
- Exposure location: repository and commit, CI/CD log, container image, issue, support ticket, screen recording, paste, or endpoint.
- Exposure window: when it was introduced, discovered, removed, and revoked. If unknown, say so.
- Permissions: read, write, administrative, deployment, billing, database, signing, or other capabilities.
- Systems and data: applications, storage, queues, databases, customer records, or infrastructure reachable with the credential.
- Observed activity: authentication events, API calls, configuration changes, downloads, errors, unusual locations, or cost changes.
- Containment actions: revocation, rotation, access-policy changes, network restrictions, repository cleanup, and deployment updates.
- Evidence: relevant log references, timestamps, alert IDs, repository links, and screenshots with secrets removed.
After revocation, issue a new credential through the provider's normal console or command-line workflow. Store it in an approved secrets manager or protected runtime configuration, not in source code. Update every legitimate consumer before deleting the old value from deployment configuration. Test the replacement in a controlled way, then confirm that the old credential fails where it should.
Removing a secret from the latest file does not necessarily remove it from repository history, build artifacts, caches, container layers, backups, or third-party logs. Purge or restrict those copies according to the system's retention and cleanup capabilities. A repository cleanup is useful, but it is not a substitute for revocation.
Provider-neutral response checklist
- Confirm the credential type, scope, environment, and exposure location.
- Notify the incident owner or on-call security contact using a redacted summary.
- Revoke, disable, or restrict the exposed credential.
- Inspect authentication, API, audit, database, deployment, and billing logs for the exposure window.
- Search for related credentials, newly created users, policy changes, and unusual resources.
- Generate and securely distribute a replacement credential.
- Update applications, pipelines, integrations, and local development configuration.
- Remove exposed copies from source, artifacts, tickets, and shared systems where practical.
- Confirm normal operation and verify that the old credential no longer works.
- Document impact, decisions, evidence, and preventive changes.
Cadence and checkpoints
Use a fast response for an active exposure, then continue with scheduled checks. During the first review, establish whether the credential was public, whether it had production permissions, and whether logs cover the entire exposure window. If logging is incomplete, record that limitation rather than treating an absence of evidence as evidence of no activity.
Within the next operational review, verify that the replacement is stored in a managed secrets system, that its permissions are narrower where possible, and that unused credentials have been removed. Review CI/CD settings, pull-request protections, local environment files, container build processes, and deployment manifests. Add secret scanning to repositories and pipelines where supported, and ensure alerts reach an owner who can act on them.
On a monthly or quarterly cadence, track:
- Open secret-exposure incidents and their time to containment.
- Secrets discovered by scanners, grouped by source and environment.
- Credentials without an identified owner, expiration, scope, or rotation process.
- Privileged credentials used by more systems than necessary.
- Failed, expired, or unexpectedly active credentials.
- Audit-log coverage for authentication, administrative changes, and sensitive data access.
- Repeated leak locations, such as build logs, tickets, or developer workstations.
These checkpoints turn a one-time API key compromise response into a control-improvement cycle. The goal is not merely to rotate one value, but to reduce how often secrets are exposed and how much damage a single exposure can cause.
How to interpret changes
A rising number of secret alerts may indicate more leaks, but it may also reflect better scanning. Interpret the trend alongside exposure location, severity, time to revocation, and whether alerts are actionable. A small number of high-privilege incidents deserves more attention than a larger number of expired test tokens.
Pay particular attention to changes that suggest active misuse: successful authentication from an unexpected source, sudden increases in API calls, new resources, policy modifications, disabled logging, access to sensitive records, or unexpected billing activity. A credential used only by a known deployment process presents a different investigation path from one used by an unfamiliar client or newly created identity.
Do not assume rotation closes the incident if the secret was used to create persistence. Review new users, access keys, tokens, service accounts, roles, scheduled jobs, webhooks, firewall rules, and deployment changes made during the exposure window. If evidence suggests data access or system alteration, escalate under your formal incident-response process.
Internal notification template
Subject: Potential secret exposure: [service/environment] — action required
Summary: A [credential type] associated with [service or project] was found in [location] at [time]. The value has been [revoked/disabled/restricted] at [time].
Current assessment: Scope is [known/unknown]. Relevant permissions include [summary]. Initial log review covers [time range] and shows [no confirmed misuse / activity requiring investigation / review in progress].
Actions needed: Owners of [applications or pipelines] must update configuration by [time]. Please do not copy or forward the secret. Report related activity to [incident channel or owner].
Next review: The incident owner will provide an update after access, audit, and billing checks are complete.
When to revisit
Revisit this guide whenever an API key, token, cloud secret, password, private key, or signing value is exposed, even if it appears unused. Also review the workflow monthly or quarterly as part of security operations, after changing cloud accounts or CI/CD systems, and after introducing a new secrets manager or scanning tool.
Refresh the operational details at least every six months and whenever a major provider changes its console, credential model, audit-log controls, token behavior, or revocation process. Provider-specific links and menu names can change; use the provider's current official documentation and confirm the exact account, project, region, and environment before taking action.
For the next incident, start with the redacted timeline, contain first, and investigate in parallel. Link the completed record to your security alert triage process and access-review schedule. For related identity or phishing concerns, see what to do after an email or password credential leak, how to investigate a phishing email, and the quarterly SaaS access review guide. A secret leak is contained only when the credential is no longer usable, affected systems have been checked, and the organization has reduced the chance of a repeat exposure.