Join our Newsletter — 33% off our NHI Course
Home› Guides› How to work out what a leaked API…
Guide Secrets Management

How to work out what a leaked API key could access and what it actually did: Identify the owner, map permissions and read the logs

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 15 November 2026 16 min read
On this page

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.

  1. 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.
  2. 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.
  3. 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.

ProviderFormat cluesHow to identify the owner
AWSAccess key IDs beginning AKIA are long-term credentials for an IAM user or the root user; ASIA are temporary credentials created by STSsts 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
GitHubClassic and fine-grained personal access tokens, OAuth tokens, GitHub App tokens and deploy keysHash 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 CloudAPI keys; service account key JSON files (which name the service account); OAuth client secretsgcloud 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 AzureClient secrets and certificates for app registrations and service principals; tenant and client IDs often sit next to the secret in configuration filesMatch the client ID to the app registration and service principal in Entra ID, then note the credential's display name and expiry
OpenAIProject API keys owned by a user or a service accountThe Admin API project key object returns owner (type user or service_account), owner_project_access, redacted_value, created_at and last_used_at
Slackxoxb- bot token, xoxp- user token, xapp- app-level token, xwfp- workflow tokenauth.test needs no scopes and returns the workspace (team_id), the user or bot (user_id, bot_id) and enterprise_id where present
Stripesk_live_ secret key, rk_live_ restricted key, sk_org_ organisation key; _test_ variants are sandbox keysMatch 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-identity returns 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 /user works for classic and fine-grained tokens (a fine-grained token needs no permissions for it). For classic tokens and OAuth app tokens, the X-OAuth-Scopes response header lists the granted scopes.
  • Google Cloud: check the key's state in the Credentials page or with describe rather 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_at is null if it has never been used.
  • Slack: auth.test returns ok: false with invalid_auth or not_authed for 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.

ProviderToolWhat it tells youWatch for
AWSIAM 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 includedResource-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
GitHubToken settings page; X-OAuth-Scopes header; audit log token_scopes fieldGranted scopes for classic tokens; repository and permission selections for fine-grained tokensA token can reach every organisation and repository its owner can, within its scopes
Google CloudPolicy Analyzer (gcloud asset analyze-iam-policy --identity=serviceAccount:...) and Policy TroubleshooterAnalyzer 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 permissionAnalyzer 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 Azureaz role assignment list --assignee <id> --all --include-inherited --include-groupsAzure RBAC role assignments for the service principal at every scope, including those inherited from parent scopes and from groupsWithout --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
OpenAIAdmin API key object and the owner's project roleWhich project the key belongs to and whether it is user- or service-account-ownedA user-owned key follows its owner's project access. See How to audit OpenAI and Anthropic organisation API keys
SlackThe app's configured scopes and the identity returned by auth.testWhether the token acts as a bot or a user, in which workspace and enterpriseA user token reads what the user can read. See the Slack Tokens Security Guide
StripeDashboard key permissionsSecret keys have unrestricted permissions on all Stripe APIs; restricted keys carry None, Read or Write per resource, and Write implies ReadConnect 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:AssumeRole and iam: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.

ProviderEvidence sourceSearch on
AWSCloudTrail event history and trails; IAM last accessed data; get-access-key-last-useduserIdentity.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
GitHubOrganisation audit log; exported audit log for Git eventshashed_token:"VALUE"; the UI and REST API do not return Git events, so export the log to find clones and pushes
Google CloudCloud Audit Logs in Logs Explorer; Security Command Center findingsThe principal email; for delegated calls, protoPayload.authenticationInfo.serviceAccountDelegationInfo.firstPartyPrincipal.principalEmail; in Security Command Center, access.principal_email
Microsoft AzureEntra service principal sign-in logs; Azure Activity Log; Microsoft Graph activity where collectedService principal name or ID, IP address and resource; the portal groups matching sign-ins into one row that expands to individual events
OpenAIKey last_used_at; organisation usage and cost dataKey ID and project; compare usage against the application's normal profile
SlackWorkspace access and audit logs available on your planThe user or bot ID from auth.test
StripeWorkbench request logs, opened from the key's menu on the API keys pageThe key; GET requests are reads, POST and DELETE are writes

What to classify

  1. Validation only: a single identity call (for example GetCallerIdentity or auth.test) from an unknown address soon after exposure means someone found and tested the key. Treat it as compromised even with no further activity.
  2. Enumeration: list and describe calls across services show an attacker mapping the same blast radius you mapped in Step 3.
  3. Data access: reads of objects, records, repositories or messages. Record which data sets and whether personal data is involved; this drives notification decisions.
  4. 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.
  5. 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

SituationApproach
Broad key (admin, owner, unrestricted secret key), public exposureRevoke immediately, then scope; assume enumeration happened and review every service the principal could reach
Narrow, read-only key, private exposure, no use after exposureRotate on a planned schedule; a short log review over the window is usually proportionate
Key whose owner can impersonate or create credentialsScope the chained identities too, and check them for new credentials before closing
Logs missing or past retentionScope by permissions alone and report the gap; do not state that no access occurred
Small team, single providerProvider console views (Stripe request logs, OpenAI usage, CloudTrail event history) are enough for most cases
Large estate, many accounts or projectsUse 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 GetCallerIdentity proves 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

FrameworkReferenceRelevance
NIST CSF 2.0RS.AN-03Analysis is performed to establish what has taken place during an incident
NIST CSF 2.0DE.CM-03Monitoring of technology usage to find adverse events, including key usage
NIST SP 800-53 Rev 5IR-4, AU-6, AC-6Incident handling, audit record review, and least privilege that keeps blast radius small
NIST SP 800-61 Rev 3Incident response recommendationsPlaces analysis within CSF 2.0 based incident response
ISO/IEC 27001:2022 Annex AA.5.26, A.8.15Response to information security incidents; logging
MITRE ATT&CKT1078.004, T1552.001, T1528Valid 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

Related NHI Mgmt Group resources: Leaked Credential Response Playbook, Attack Surface vs Blast Radius, Cloud Access Key Leak Playbook, API Key Management Guide.

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 15 November 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.