Every leaked key raises the same two questions, and most teams answer neither properly: what could this credential reach, and what did someone actually do with it? Revoking the key stops future use, but it does not tell you whether customer data was read, whether new keys or users were created for persistence, or which systems need a closer look. This runbook covers the scoping work that sits between revocation and recovery: identifying who the key belongs to without making the incident worse, enumerating its effective permissions with each provider's own tools, and reading the usage evidence for the exposure window. It is written for incident responders, cloud and platform engineers and secrets owners. The wider response process (triage, rotation, communication) lives in the Leaked Credential Response Playbook and the API Key Leak Response Playbook; this page goes deeper on the scoping step only. Providers are listed alphabetically; order is not a ranking.
Key takeaways
- Two numbers, not one. Potential blast radius is what the key's permissions allow; actual impact is what the logs show it did. Report both, because the first drives containment and the second drives notification.
- Identify from your side first. Look the key up in your own inventory, secrets manager and provider consoles before you send it to any API, so that your test calls do not pollute the very logs you need.
- Use the provider's evaluation tools, not attached policy names. AWS policy simulation, Google Cloud Policy Analyzer and Policy Troubleshooter, and Azure role assignment listing with inherited and group scopes reveal effective access that a single policy view hides.
- Start the log review at first exposure. The window opens when the key became visible (the commit time, the paste time, the build log date), not when you detected it.
- Look for persistence before you close. New keys, users, service account keys, webhooks and OAuth grants created during the window turn a contained leak into an ongoing compromise.
When you need this
- Secret scanning alert or third-party report: a key turns up in a public repository, a container image, a support ticket or a paste site. See the Generic API Key Detection Guide for how such keys are found.
- Supply chain incident: a compromised package, CI plugin or developer tool may have read environment variables and configuration files (ATT&CK T1552.001 Credentials In Files).
- Unexplained spend or activity: a billing spike on a model provider or cloud account often means a key is in use somewhere it should not be. See the LLMjacking Guide.
- Offboarding or vendor exit: keys held by a departed engineer or a terminated supplier need the same scoping before you can say nothing was taken.
Before you start
Scoping is evidence work. Three rules keep it clean.
- Record the exposure facts first: where the key appeared, the earliest timestamp you can prove (commit date, file creation, log line), whether the location was public, and the full key prefix and identifier. Never paste the full secret into a ticket or chat channel; store it once, in the incident's restricted evidence store.
- Prefer identifier lookups to authenticated calls: many providers let you identify a key from its non-secret part or from your own inventory. An authenticated "who am I" call from your network creates a log entry that you then have to tell apart from attacker activity, so note the source IP and time of every test call you make.
- Do not wait for scoping to contain: if the key is live and broadly privileged, rotate or disable it first and scope afterwards. Provider logs survive revocation; the attacker's access does not need to.
Prepare read access to the logs you will need before the clock runs: AWS CloudTrail, Google Cloud audit logs, Microsoft Entra sign-in logs and Azure Activity Log, the GitHub organisation audit log, provider usage dashboards and billing exports. Retention differs by provider and plan, so check it on day one and export anything near its expiry.
Step 1: Identify the key and its owner
The key format usually tells you the provider and the credential type, and the type changes everything that follows.
| Provider | Format clues | How to identify the owner |
|---|---|---|
| AWS | Access key IDs beginning AKIA are long-term credentials for an IAM user or the root user; ASIA are temporary credentials created by STS | sts get-access-key-info returns the owning account ID from the key ID alone; in your own account, the IAM credentials report maps the key to a user. For ASIA keys, review STS events in CloudTrail to find who requested the session |
| GitHub | Classic and fine-grained personal access tokens, OAuth tokens, GitHub App tokens and deploy keys | Hash the token with SHA-256 (base64 output) and search the organisation audit log with hashed_token:"VALUE"; this finds events without exposing the token. See How to revoke a leaked GitHub personal access token and check what it touched |
| Google Cloud | API keys; service account key JSON files (which name the service account); OAuth client secrets | gcloud services api-keys lookup KEY_STRING returns the key's project resource name; gcloud services api-keys describe KEY_ID shows whether the key is bound to a service account |
| Microsoft Azure | Client secrets and certificates for app registrations and service principals; tenant and client IDs often sit next to the secret in configuration files | Match the client ID to the app registration and service principal in Entra ID, then note the credential's display name and expiry |
| OpenAI | Project API keys owned by a user or a service account | The Admin API project key object returns owner (type user or service_account), owner_project_access, redacted_value, created_at and last_used_at |
| Slack | xoxb- bot token, xoxp- user token, xapp- app-level token, xwfp- workflow token | auth.test needs no scopes and returns the workspace (team_id), the user or bot (user_id, bot_id) and enterprise_id where present |
| Stripe | sk_live_ secret key, rk_live_ restricted key, sk_org_ organisation key; _test_ variants are sandbox keys | Match the key name and note in the Dashboard API keys page; the key type alone tells you whether permissions are unrestricted (sk_) or assigned (rk_) |
Ownership is not the same as identity. A user-owned key generally acts with that user's access, so the scope is the person's entitlements, not the application's. Record both the technical identity (ARN, service principal, bot) and the accountable human owner. See the NHI ownership guide for how to fix ownership gaps once the incident is over.
Step 2: Confirm whether the key is live
A key that was already revoked before exposure needs no blast radius work, but prove it rather than assume it.
- AWS:
sts get-caller-identityreturns the account, ARN and user ID of the caller. AWS states that no permissions are required for this call and that an explicit deny does not block it, so a successful response proves the key works but says nothing about what it can do.GetAccessKeyInfo, by contrast, does not indicate whether the key is active, inactive or deleted. - GitHub:
GET /userworks for classic and fine-grained tokens (a fine-grained token needs no permissions for it). For classic tokens and OAuth app tokens, theX-OAuth-Scopesresponse header lists the granted scopes. - Google Cloud: check the key's state in the Credentials page or with
describerather than calling a production API with it. - Microsoft Azure: check the credential list on the app registration; an expired or deleted secret no longer authenticates.
- OpenAI: the key object's presence in the Admin API listing shows it still exists;
last_used_atisnullif it has never been used. - Slack:
auth.testreturnsok: falsewithinvalid_authornot_authedfor a dead token. - Stripe: the key's status on the API keys page; an expired key returns an authentication error.
Every live-check call is itself a logged event. Write down the time and source address so the log review in Step 4 can exclude it.
Step 3: Enumerate what the key could access
This is the potential blast radius. Attached policy names are a starting point; effective access depends on inheritance, groups, boundaries, deny rules and resource policies, so use each provider's evaluation tooling. The Attack Surface vs Blast Radius guide explains why this number matters for prioritisation.
| Provider | Tool | What it tells you | Watch for |
|---|---|---|---|
| AWS | IAM SimulatePrincipalPolicy (aws iam simulate-principal-policy) | For a user, group or role and a list of actions and resources, returns allowed, implicitDeny or explicitDeny per pair, with the matching statements. A user's group policies are included | Resource-based policies must be passed in manually and are supported for users only; resource control policies are not evaluated; AWS advises confirming results against the live environment |
| GitHub | Token settings page; X-OAuth-Scopes header; audit log token_scopes field | Granted scopes for classic tokens; repository and permission selections for fine-grained tokens | A token can reach every organisation and repository its owner can, within its scopes |
| Google Cloud | Policy Analyzer (gcloud asset analyze-iam-policy --identity=serviceAccount:...) and Policy Troubleshooter | Analyzer lists resources where the principal holds given roles or permissions across a project, folder or organisation; Troubleshooter explains allow, deny and principal access boundary policies for one principal, resource and permission | Analyzer covers allow policies only; Troubleshooter needs Security Reviewer and Deny Reviewer to show deny policies, and shows Unknown where you cannot read a policy |
| Microsoft Azure | az role assignment list --assignee <id> --all --include-inherited --include-groups | Azure RBAC role assignments for the service principal at every scope, including those inherited from parent scopes and from groups | Without --all only subscription-scope assignments are shown; Entra directory roles and Microsoft Graph application permissions are separate from Azure RBAC and need their own review |
| OpenAI | Admin API key object and the owner's project role | Which project the key belongs to and whether it is user- or service-account-owned | A user-owned key follows its owner's project access. See How to audit OpenAI and Anthropic organisation API keys |
| Slack | The app's configured scopes and the identity returned by auth.test | Whether the token acts as a bot or a user, in which workspace and enterprise | A user token reads what the user can read. See the Slack Tokens Security Guide |
| Stripe | Dashboard key permissions | Secret keys have unrestricted permissions on all Stripe APIs; restricted keys carry None, Read or Write per resource, and Write implies Read | Connect permissions on a restricted key extend to connected accounts |
Availability: Google Cloud states that more than 20 Policy Analyzer queries per organisation per day require Security Command Center Premium or Enterprise at organisation level. Other providers' docs consulted for this page state no plan limit for the tools above.
Follow the chains
Direct permissions understate reach. Check each of these explicitly:
- Role assumption and impersonation: AWS
sts:AssumeRoleandiam:PassRole; Google Cloud Service Account Token Creator; Azure permissions to add credentials to other applications. See How to Audit GCP Service Account Impersonation Rights. - Secrets the key can read: access to a secrets manager, CI variables or a key vault means the key's blast radius includes every credential stored there.
- Credential creation rights:
iam:CreateAccessKey, service account key creation, GitHub App installation or token creation let an attacker mint durable access that survives your rotation. - Bound keys: a Google Cloud API key bound to a service account processes requests as that account, and its requests do not appear in service account usage metrics.
Step 4: Find out what the key actually did
This is actual impact. Search by the key's identifier or principal from the first exposure time to the moment of revocation, then subtract your own test calls and known application traffic.
| Provider | Evidence source | Search on |
|---|---|---|
| AWS | CloudTrail event history and trails; IAM last accessed data; get-access-key-last-used | userIdentity.accessKeyId and the principal ARN. Last accessed data keeps service information for at least 400 days, appears in the console within about four hours, and includes denied attempts, so confirm success in CloudTrail. See the AWS CloudTrail Guide |
| GitHub | Organisation audit log; exported audit log for Git events | hashed_token:"VALUE"; the UI and REST API do not return Git events, so export the log to find clones and pushes |
| Google Cloud | Cloud Audit Logs in Logs Explorer; Security Command Center findings | The principal email; for delegated calls, protoPayload.authenticationInfo.serviceAccountDelegationInfo.firstPartyPrincipal.principalEmail; in Security Command Center, access.principal_email |
| Microsoft Azure | Entra service principal sign-in logs; Azure Activity Log; Microsoft Graph activity where collected | Service principal name or ID, IP address and resource; the portal groups matching sign-ins into one row that expands to individual events |
| OpenAI | Key last_used_at; organisation usage and cost data | Key ID and project; compare usage against the application's normal profile |
| Slack | Workspace access and audit logs available on your plan | The user or bot ID from auth.test |
| Stripe | Workbench request logs, opened from the key's menu on the API keys page | The key; GET requests are reads, POST and DELETE are writes |
What to classify
- Validation only: a single identity call (for example
GetCallerIdentityorauth.test) from an unknown address soon after exposure means someone found and tested the key. Treat it as compromised even with no further activity. - Enumeration: list and describe calls across services show an attacker mapping the same blast radius you mapped in Step 3.
- Data access: reads of objects, records, repositories or messages. Record which data sets and whether personal data is involved; this drives notification decisions.
- Change and persistence: new access keys, users, service account keys, role assignments, OAuth apps, webhooks or SSH keys. Google Cloud's guidance names new service account keys, user accounts and project-level SSH keys as items to look for.
- Resource abuse: compute, model or messaging use that shows up mainly in billing.
Step 5: Write the scope statement
Close the scoping step with a short, dated statement that the incident lead can act on:
- Key: provider, type, identifier (never the secret), owner and accountable human.
- Exposure window: first provable exposure, revocation time, and whether the location was public.
- Potential blast radius: the services, resources and data classes the key could reach, including chained access.
- Observed activity: the classification from Step 4, with event counts, source addresses and log references.
- Persistence check: what was searched for and the result.
- Gaps: log sources that were missing or past retention. A gap means "unknown", not "nothing happened", and should be stated as such to legal and privacy colleagues.
Decision guidance
| Situation | Approach |
|---|---|
| Broad key (admin, owner, unrestricted secret key), public exposure | Revoke immediately, then scope; assume enumeration happened and review every service the principal could reach |
| Narrow, read-only key, private exposure, no use after exposure | Rotate on a planned schedule; a short log review over the window is usually proportionate |
| Key whose owner can impersonate or create credentials | Scope the chained identities too, and check them for new credentials before closing |
| Logs missing or past retention | Scope by permissions alone and report the gap; do not state that no access occurred |
| Small team, single provider | Provider console views (Stripe request logs, OpenAI usage, CloudTrail event history) are enough for most cases |
| Large estate, many accounts or projects | Use organisation-level tools (Policy Analyzer at organisation scope, organisation CloudTrail trails, exported GitHub audit logs) and a SIEM query per provider prepared in advance |
Detection and measurement
Scoping is faster when the evidence is already in place. Log and alert on identity calls from unfamiliar sources, new credential creation for non-human identities and usage of keys outside their normal network ranges; Stripe access policies, for example, block and notify on requests from outside a key's allowed IP addresses or networks. Track these metrics:
- Time to owner: minutes from alert to a named accountable owner for the key.
- Time to scope statement: hours from alert to a signed-off Step 5 statement.
- Log coverage: percentage of key-issuing providers whose audit logs reach your SIEM with retention longer than your typical detection delay.
- Unrestricted key share: proportion of keys with full permissions (Stripe secret keys, unrestricted Google Cloud API keys, owner-level roles).
- Unknown-owner keys: count of keys that could not be tied to a person during incidents.
Common failure patterns
- Treating "who am I" as a permission check: a successful
GetCallerIdentityproves only that the key works. It cannot be denied by policy, so it reveals nothing about access. - Starting the log search at detection time: attackers who scan public sources often use a key within minutes of exposure. Search from the earliest commit or upload.
- Reading one policy and stopping: inherited Azure assignments, group bindings, Google Cloud folder policies and AWS resource policies all extend reach beyond the identity's own attachments.
- Polluting the evidence: unrecorded test calls with the leaked key from analyst laptops are later indistinguishable from attacker activity.
- Missing persistence: rotating the leaked key while an attacker-created key or OAuth grant stays active. The Codecov breach showed how credentials harvested from CI environments spread far beyond the first system.
- Reporting gaps as clean: "no suspicious activity found" in a log that only kept seven days is not evidence of no access.
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| NIST CSF 2.0 | RS.AN-03 | Analysis is performed to establish what has taken place during an incident |
| NIST CSF 2.0 | DE.CM-03 | Monitoring of technology usage to find adverse events, including key usage |
| NIST SP 800-53 Rev 5 | IR-4, AU-6, AC-6 | Incident handling, audit record review, and least privilege that keeps blast radius small |
| NIST SP 800-61 Rev 3 | Incident response recommendations | Places analysis within CSF 2.0 based incident response |
| ISO/IEC 27001:2022 Annex A | A.5.26, A.8.15 | Response to information security incidents; logging |
| MITRE ATT&CK | T1078.004, T1552.001, T1528 | Valid Accounts: Cloud Accounts; Credentials In Files; Steal Application Access Token |
Practitioner checklist
- Record the first provable exposure time and location before touching the key.
- Identify provider, credential type, technical identity and accountable owner.
- Contain first if the key is live and broadly privileged; scope afterwards.
- Log the time and source address of every test call made with the leaked key.
- Enumerate effective permissions with the provider's evaluation tools, including inherited, group and resource-based access.
- Follow impersonation, role assumption, secrets access and credential creation chains.
- Search usage logs from first exposure to revocation and classify activity.
- Check for new keys, users, role assignments, OAuth apps and webhooks created in the window.
- Write a dated scope statement that separates potential blast radius, observed activity and log gaps.
Standards and references
- NIST: SP 800-61 Rev 3, Incident Response Recommendations and Considerations for Cybersecurity Risk Management: A CSF 2.0 Community Profile
- AWS: GetAccessKeyInfo API reference
- AWS: SimulatePrincipalPolicy API reference
- GitHub: Identifying audit log events performed by an access token
- Google Cloud: Handle compromised Google Cloud credentials
- Google Cloud: Analyze IAM policies with Policy Analyzer
- Microsoft: az role assignment reference
- Stripe: Restricted API keys
Related NHI Mgmt Group resources: Leaked Credential Response Playbook, Attack Surface vs Blast Radius, Cloud Access Key Leak Playbook, API Key Management Guide.