How to Detect and Respond to Leaked Cloud Credentials: Secret Scanning, Revocation and Blast-Radius Analysis

How to Detect and Respond to Leaked Cloud Credentials: Secret Scanning, Revocation and Blast-Radius Analysis

Leaked Cloud Credentials: How to Detect, Revoke and Measure the Blast Radius

When Palo Alto Networks’ Unit 42 pushed a real AWS access key to a public GitHub repository, AWS attached a quarantine policy to the owning IAM user about ten seconds later. That is fast. It is also not the end of the incident, because the key was still active and the policy only blocks a list of high-risk actions. Leaked cloud credentials are now detected faster than ever, yet most teams still treat the response as “rotate the key and move on.” That habit misses the part that actually hurts: the temporary sessions, new keys and roles an attacker can mint from a key before anyone rotates it. GitGuardian counted 28.65 million new hardcoded secrets on public GitHub in 2025, so the volume is not falling either.

This guide gives you a seven-step runbook you can adopt this week, with the commands, policies and queries for each step.

What this covers: prevention with pre-commit hooks and GitHub push protection, detection across repos, CI logs, images and canary keys, safe liveness triage, AWS key quarantine and session revocation, CloudTrail blast-radius queries in Athena, and the move to short-lived credentials.

Context and Background

Leaked cloud credentials are not new, but three things changed in the last two years. First, the volume grew. GitGuardian’s State of Secrets Sprawl 2026 reports 28.65 million new hardcoded secrets added to public GitHub commits in 2025, a 34% year-over-year increase and the largest single-year jump the company has recorded. AI-service secrets alone reached 1,275,105, up 81%. Second, leaked secrets stay valid. GitGuardian retested credentials it had confirmed valid in 2022 and found more than 64% still valid in January 2026. Remediation, in other words, is the bottleneck, not detection.

Third, the platforms started acting on your behalf. GitHub’s secret scanning partner program forwards exposed tokens from public repositories and public npm packages directly to the issuing provider. That program runs by default and cannot be switched off for partner patterns on public repositories. AWS uses those alerts to attach the AWSCompromisedKeyQuarantineV3 managed policy to the exposed IAM user. Google Cloud went further: since June 16, 2024, exposed service account keys are disabled automatically unless an organization opts out through the iam.serviceAccountKeyExposureResponse constraint.

These automatic controls create a dangerous illusion about leaked cloud credentials. Teams see the AWS support case, read “your key has been quarantined,” and assume the cloud provider has contained the incident. It has not. The provider has reduced fraud risk on a fixed list of actions. Everything else is still your job.

The incumbents in this space fall into three groups. Platform-native scanners include GitHub secret scanning and push protection, GitLab secret detection, and cloud provider exposure programs. Open-source scanners such as Gitleaks and TruffleHog run locally and in CI. Commercial platforms such as GitGuardian add org-wide monitoring and incident workflows. None of them performs blast-radius analysis on leaked cloud credentials for you, which is why this post spends most of its time there.

If your organization already enforces account structure through guardrails, read our guide to cloud landing zone architecture with SCPs and organization policy first. Several containment moves below depend on having an organization-level control plane. The AWS guidance on what to do if you inadvertently expose an access key is the original primary source for the basic steps, although it dates from 2014 and predates the quarantine policy.

The Leaked Cloud Credentials Response Lifecycle

Responding to leaked cloud credentials means running seven steps in order: prevent the commit, detect exposure anywhere, triage liveness and ownership without using the key, contain by deactivating it and revoking derived sessions, measure blast radius from audit logs, eradicate long-lived keys, and close the control gaps. Rotation alone covers only step four.

Leaked cloud credentials response lifecycle from prevention through detection, triage, containment, blast-radius analysis, eradication and post-incident review

Figure 1: The seven-step response lifecycle for leaked cloud credentials, with a fast path from detection straight to containment.

The diagram reads left to right. Prevention feeds detection, which feeds a short triage step. The dashed arrow from detection to containment is the fast path: for a confirmed live production key found in a public place, you contain first and triage in parallel. The loop from post-incident review back to prevention is where most organizations get their lasting improvement.

Time is the governing variable, and both sides are automated

The Unit 42 test gives a rare, precise timeline. On December 19, 2025, the researchers created an IAM user and access key, then pushed the key to a public repository at 18:50:05 UTC. AWS attached the quarantine policy at 18:50:15. GitHub’s email arrived at 18:50:16, the AWS Health alert at 18:50:17, an AWS email at 18:50:26, and a support case at 18:50:59. Detection by the provider took seconds.

Attackers run the same race. Credential-harvesting bots watch public commit streams continuously, and their first move is usually a cheap identity check. Unit 42 notes that GitHub’s own validation calls appear in CloudTrail as GetCallerIdentity with a user agent containing GHAS-AWS_KEYID-validation. Any other GetCallerIdentity from an unfamiliar IP shortly after a leak should be treated as hostile. The practical consequence is that your response clock starts at the commit timestamp, not when a human reads the alert.

Rotation is not containment, because credentials have descendants

An IAM access key is a parent credential. With it, an attacker can call sts:GetSessionToken to mint temporary ASIA-prefixed credentials. AWS documents that IAM user sessions from GetSessionToken last between 900 seconds and 129,600 seconds (36 hours), with 12 hours as the default. The key can also call AssumeRole into any role it is trusted for, and iam:CreateAccessKey or iam:CreateUser if its policies allow.

Deleting the parent key does not obviously kill those descendants. AWS’s own guidance is to invalidate temporary credentials explicitly, either with a deny policy conditioned on token issue time or by denying the user outright. The IAM documentation adds that a deny keyed on the user’s unique ID in aws:userid “includes any temporary security credential sessions that were created by calling the GetSessionToken API.” If you only rotate, you may leave a 36-hour window open.

Validity, not detection count, should drive priority

Most scanners now report whether a secret is live. TruffleHog, for example, classifies results as verified, unverified or unknown, based on an API call to the issuing service. That signal is useful, but it is not sufficient. GitGuardian’s 2026 report states that 46% of critical secrets are missed when teams prioritize on validation alone. Some secrets cannot be verified without side effects, and some verifiers fail for network reasons.

A better model ranks findings on three axes: exposure surface (public beats private), privilege of the owning identity, and liveness. A dead key in a public repo still matters if it reveals naming conventions or account IDs. A live, read-only key in a private repo matters less than a live administrator key in a container image pushed to a public registry. The runbook below assumes that ranking.

Walk-through: The Seven-Step Runbook With Commands

This section is the how-to. Each step lists what to do, the commands or code, and the reason it matters. The examples use AWS because it has the richest public tooling, but each step names the Google Cloud or GitHub equivalent where one is documented.

Step 1: Prevent the commit with pre-commit hooks and GitHub push protection

The cheapest of all leaked cloud credentials is the one that never leaves a laptop. Install a local scanner as a pre-commit hook so secrets are blocked before they enter Git history. Gitleaks publishes an official pre-commit hook:

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/gitleaks/gitleaks
    rev: v8.24.2   # example from the Gitleaks README; pin to the current release
    hooks:
      - id: gitleaks

Gitleaks v8.19.0 deprecated the older detect and protect subcommands in favor of git, dir and stdin. Older blog posts still show gitleaks protect --staged, which works but is hidden from --help. Use the new verbs in new configurations:

# scan the full history of the current repository
gitleaks git -v .

# scan a directory that is not a git repo, such as an unpacked artifact
gitleaks dir ./build-output

# scan anything piped in, such as a CI log
cat job.log | gitleaks stdin

Local hooks are opt-in, so they need a server-side backstop. On GitHub.com, push protection for users is enabled by default and blocks you from pushing supported secrets to public repositories. Repository-level push protection is different. It is disabled by default and requires GitHub Secret Protection, which GitHub priced at $19 per active committer per month when it became available on April 1, 2025. GitHub also turned on secret scanning and push protection by default for new public repositories in March 2024.

Pay attention to bypass behavior. Anyone with write access can bypass repository push protection by choosing a reason. “It’s used in tests” and “It’s a false positive” close the resulting alert, while “I’ll fix it later” leaves it open. For production organizations, enable delegated bypass so that a small reviewer group must approve each bypass request.

The provider programs are the third prevention layer. GitHub forwards partner-pattern matches from public repositories to issuers. For AWS, that triggers quarantine. For Google Cloud service account keys, it triggers automatic disabling under the default DISABLE_KEY setting. Check that your Google Cloud organization has not set WAIT_FOR_ABUSE, and confirm that security contacts are current, because both notifications depend on them.

Step 2: Detect exposure beyond the repository

Repository scanning is necessary but no longer covers the main paths by which leaked cloud credentials escape. Secrets leak through CI logs, container images, artifact buckets, chat tools and AI prompts. A sound detection program covers each surface with a specific tool.

For Git history across an organization, run TruffleHog with verification:

# all repos in a GitHub org, verified hits only
trufflehog github --org=your-org --results=verified

# a container image, layer by layer
trufflehog docker --image your-registry/app:1.4.2 --results=verified

# an S3 bucket of build artifacts
trufflehog s3 --bucket=your-artifacts-bucket

# local files, such as downloaded CI logs
trufflehog filesystem ./ci-logs/

The default --results value is verified,unverified,unknown. Use verified for paging and the full set for weekly hygiene reports.

CI logs deserve their own control. In the March 2025 compromise of the tj-actions/changed-files GitHub Action, the malicious code printed runner secrets into workflow logs. StepSecurity points out that workflow run logs are not among the surfaces GitHub lists for its new public monitoring feature. Download and scan logs from public repositories yourself, or better, prevent secrets from reaching steps that do not need them.

For enterprises, GitHub’s public monitoring reached general availability on October 28, 2026. It scans public github.com content, including git content, pull request comments and gists, and attributes findings to your enterprise through membership or verified email domains. It is included with Secret Protection or Advanced Security on GitHub Enterprise Cloud. It never scans private repositories. It closes a real gap: an employee’s personal side project that contains a work key.

AI prompts and agent transcripts are the newest surface. Developers paste .env files and stack traces into assistants, and those prompts cross gateways and logs you do not control. GitGuardian also measured a 3.2% secret-leak rate in Claude Code-assisted commits against a 1.5% baseline across public commits. Our same-day companion analysis on how API keys leak through LLM providers, resellers and logs covers that path in depth. For this runbook, the point is simple: pipe prompt logs and agent transcripts through gitleaks stdin or a redaction proxy, exactly as you would CI logs.

Finally, plant canary credentials, which turn leaked cloud credentials from a liability into a tripwire. A canary key is a real but powerless credential placed where only an intruder would find it, such as a developer laptop’s ~/.aws/credentials, a fake CI variable, or a decoy config in an internal wiki. Any use of it is a high-fidelity alert, because no legitimate process should ever call it. Services such as Thinkst’s Canarytokens generate AWS key canaries, and you can build your own with an IAM user that has no permissions plus a CloudTrail alert on its access key ID.

Sequence diagram of an aws access key leaked to GitHub, showing partner alert, AWS quarantine, attacker probing and security team containment

Figure 2: The public-leak race. Provider automation and attacker automation start at the same commit, and the security team joins last.

Figure 2 shows why the human response must be pre-scripted. GitHub notifies AWS, AWS quarantines and opens a case, and in parallel an attacker bot validates the key. AWS Health events and support cases do not appear in CloudTrail, as Unit 42 observed, so your SIEM will not see them unless you route them separately. The security team’s first useful actions, deactivation and the CloudTrail query, happen only after a person reads one of those notifications.

Step 3: Triage ownership and liveness without making things worse

Triage of leaked cloud credentials answers three questions: whose key is this, is it live, and what can it do? Answer them from your own account first, without calling AWS with the leaked key.

Start with the key ID. The prefix tells you the type: AKIA is a long-term key for an IAM user or the root user, while ASIA is a temporary STS credential. If you do not know which account owns it, GetAccessKeyInfo returns the account number. Run it with your own credentials, not the leaked ones:

# which account owns this key? (call with YOUR credentials)
aws sts get-access-key-info --access-key-id AKIAEXAMPLEKEYID0000

# in that account: which user, which status, last used when and where?
aws iam list-access-keys --user-name suspected-user
aws iam get-access-key-last-used --access-key-id AKIAEXAMPLEKEYID0000

AWS notes that GetAccessKeyInfo does not indicate whether the key is active, inactive or deleted. The get-access-key-last-used output gives the last service, region and timestamp, which is your first hint about attacker activity.

The common advice is to test liveness with aws sts get-caller-identity using the leaked key. That call needs no permissions; AWS documents that it succeeds even under an explicit deny. It is therefore a reliable liveness test. The trade-off is that it generates a GetCallerIdentity event in the victim account, which can confuse your own timeline. If you must test with the key, do it from a known, documented IP address and record the timestamp so you can exclude it from the investigation.

# only if you cannot answer liveness from inside the owning account
AWS_ACCESS_KEY_ID=AKIAEXAMPLEKEYID0000 \
AWS_SECRET_ACCESS_KEY='redacted' \
aws sts get-caller-identity --no-cli-pager
# record: time, source IP, operator name, ticket ID

Never paste the secret into a third-party validation website. Treat the secret value like evidence: store it in your incident vault, reference it by key ID everywhere else, and keep it out of chat threads and tickets.

Finally, assess privilege. List attached and inline policies, group memberships, and role trust relationships that name the user. If the IAM user can assume roles, those roles are in scope. Our post on AWS IAM policy evaluation logic, SCPs and permission boundaries explains how to compute effective permissions when SCPs and boundaries are involved.

Step 4: Contain by deactivating the key and revoking derived sessions

Containment for an AWS access key leaked publicly has four moves, and the order matters.

First, if production depends on the key, ship a replacement credential before you cut the old one. Ideally the replacement is a role, not another key. If time does not allow, accept the outage. A short outage costs less than an attacker’s 36-hour session.

Second, deactivate the key rather than deleting it. AWS’s own guidance favors disabling because a disabled key can be restored if an application breaks unexpectedly, and the key ID remains available as a forensic anchor:

aws iam update-access-key \
  --user-name suspected-user \
  --access-key-id AKIAEXAMPLEKEYID0000 \
  --status Inactive

Third, kill the descendants. For sessions minted with GetSessionToken, attach a deny keyed on the user’s unique ID. The IAM documentation states that this covers those session credentials. Find the ID with aws iam get-user --user-name suspected-user --query User.UserId:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyAllForCompromisedUserIncludingSessions",
      "Effect": "Deny",
      "Action": "*",
      "Resource": "*",
      "Condition": {
        "StringLike": { "aws:userid": ["AIDAEXAMPLEUSERID000"] }
      }
    }
  ]
}

For roles the user could assume, use Revoke active sessions in the IAM console. It attaches an inline policy named AWSRevokeOlderSessions that denies everything to sessions issued before roughly 30 seconds in the future, using aws:TokenIssueTime. You can apply the same pattern with the CLI:

CUTOFF=$(date -u -d '+1 minute' +%Y-%m-%dT%H:%M:%SZ)
aws iam put-role-policy --role-name deploy-role \
  --policy-name RevokeOlderSessions-IR1234 \
  --policy-document "{
    \"Version\": \"2012-10-17\",
    \"Statement\": [{
      \"Effect\": \"Deny\", \"Action\": \"*\", \"Resource\": \"*\",
      \"Condition\": {\"DateLessThan\": {\"aws:TokenIssueTime\": \"$CUTOFF\"}}
    }]
  }"

Three limits apply. The time-based deny does not affect long-term keys, because requests signed with them carry no aws:TokenIssueTime. Service-linked roles cannot have sessions revoked. Roles created from IAM Identity Center permission sets must be handled in Identity Center, not IAM.

Fourth, leave the AWS quarantine policy attached. Its description says plainly “Do NOT remove this policy” and directs you to the support case. The current managed policy page lists default version v4, last edited November 9, 2026. It denies actions such as iam:CreateAccessKey, iam:CreateUser, ec2:RunInstances, lambda:CreateFunction, s3:GetObject, bedrock:InvokeModel and organizations:LeaveOrganization. It is a strong fraud brake. It is not a deny-all.

On Google Cloud, the equivalent move is to disable the service account key, then delete it after review:

gcloud iam service-accounts keys disable KEY_ID \
  --iam-account=builder@project-id.iam.gserviceaccount.com

For a GitHub personal access token, revoke it from the token settings page or ask an organization owner to revoke it, then review the organization audit log for its use.

Step 5: Measure blast radius with CloudTrail lineage queries

Blast-radius analysis for leaked cloud credentials answers one question: what did any credential descended from the leaked key do between first exposure and full containment? You answer it by following lineage in CloudTrail, not by searching for the key ID alone.

Credential lineage graph used in credential leak incident response, showing a leaked key spawning session tokens, assumed roles, new keys and new users

Figure 3: Credential lineage. A leaked key’s blast radius is the union of everything its descendants touched, including new keys and users that survive rotation.

Figure 3 is the mental model. The leaked AKIA key can mint GetSessionToken sessions and role sessions, and either can chain into further roles. Data access and compute abuse can happen at any depth. The most dangerous branch is persistence: a new access key or a new user that is not derived from the leaked key at all, and therefore survives every revocation step you just ran.

The queries below assume the CloudTrail table created by the standard Athena integration, named cloudtrail_logs here. Adjust column names to your table definition and add partition filters to control scan cost. Treat them as templates, not drop-in code.

Query 1: everything the leaked key did directly.

SELECT eventtime, eventsource, eventname, awsregion,
       sourceipaddress, useragent, errorcode
FROM cloudtrail_logs
WHERE useridentity.accesskeyid = 'AKIAEXAMPLEKEYID0000'
  AND eventtime >= '2026-11-20T00:00:00Z'
ORDER BY eventtime;

Look first at errorcode. A run of AccessDenied errors across many services is the fingerprint of automated permission enumeration. Successful calls are the ones that matter.

Query 2: temporary credentials the leaked key minted.

SELECT eventtime, eventname, sourceipaddress,
       json_extract_scalar(responseelements, '$.credentials.accessKeyId') AS child_key,
       json_extract_scalar(requestparameters, '$.roleArn') AS role_arn
FROM cloudtrail_logs
WHERE useridentity.accesskeyid = 'AKIAEXAMPLEKEYID0000'
  AND eventsource = 'sts.amazonaws.com'
  AND eventname IN ('GetSessionToken', 'AssumeRole', 'GetFederationToken')
  AND errorcode IS NULL;

Each child_key is an ASIA key ID. Feed them back into Query 1 to see what each session did, and repeat for any AssumeRole they made. This loop is the lineage walk in Figure 3.

Query 3: persistence attempts.

SELECT eventtime, eventname, useridentity.arn AS actor,
       useridentity.accesskeyid AS via_key,
       requestparameters
FROM cloudtrail_logs
WHERE eventsource = 'iam.amazonaws.com'
  AND eventname IN ('CreateAccessKey', 'CreateUser', 'CreateLoginProfile',
                    'UpdateLoginProfile', 'AttachUserPolicy', 'PutUserPolicy',
                    'CreateRole', 'UpdateAssumeRolePolicy', 'AttachRolePolicy')
  AND eventtime >= '2026-11-20T00:00:00Z'
ORDER BY eventtime;

Filter via_key against the leaked key plus every child key from Query 2. Any hit means the attacker may hold credentials you have not yet revoked. Note also that, per Unit 42, the quarantine attachment itself appears as an AttachUserPolicy event whose userIdentity shows the victim user even though AWS performed it. Do not misread that event as attacker activity.

Query 4: data and compute access by the whole lineage.

SELECT eventsource, eventname, COUNT(*) AS calls,
       MIN(eventtime) AS first_seen, MAX(eventtime) AS last_seen
FROM cloudtrail_logs
WHERE useridentity.accesskeyid IN ('AKIAEXAMPLEKEYID0000', 'ASIAEXAMPLECHILD0001')
  AND errorcode IS NULL
GROUP BY eventsource, eventname
ORDER BY calls DESC;

There are two common blind spots. S3 object reads and Lambda invocations are data events, which are not logged by default; if you did not enable them, Query 4 cannot see object-level reads. Default CloudTrail event history covers 90 days of management events, so anything older requires a trail delivered to S3 or a CloudTrail Lake event data store.

Complement the logs with access analysis. Logs tell you what happened. Effective permissions tell you what could have happened in the gaps your logging does not cover. IAM Access Analyzer can flag resources shared outside your zone of trust and unused permissions; run it on the affected accounts and compare findings before and after the exposure window. For the scoping memo, record two numbers separately: confirmed blast radius from logs, and potential blast radius from permissions.

Step 6: Eradicate long-lived keys with OIDC and short-lived roles

The durable fix for leaked cloud credentials is to stop issuing keys that can leak for years. In CI, replace stored keys with OpenID Connect federation. A GitHub Actions workflow can assume an AWS role with a token GitHub issues per job:

permissions:
  id-token: write
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::111122223333:role/gha-deploy
          aws-region: eu-west-1
      - run: aws sts get-caller-identity

Scope the role’s trust policy to the exact repository and branch or environment via the sub claim. Our deep dive on GitHub Actions OIDC federation, reusable workflows and runner security covers trust-policy patterns and common mistakes.

For workloads, use instance profiles, IRSA or EKS Pod Identity on AWS, and Workload Identity Federation on Google Cloud. For secrets that must exist, such as third-party API keys, put them in a secrets manager with rotation and deliver them at runtime. The External Secrets Operator architecture for Kubernetes and the OpenBao production tutorial show two ways to do that.

Measure eradication with a number. Run the IAM credential report weekly and track the count of active access keys older than 90 days. On Google Cloud, Google’s own security blog has long argued that teams should stop using service account keys at all, and organization policy constraints can block key creation.

Step 7: Close the loop with a post-incident review

Write a short, blameless review of the leaked cloud credentials incident within a week. The timeline should include five timestamps: commit time, first provider alert, first attacker call, key deactivation, and last derived-session activity. The gap between the first and fourth timestamps is your real exposure window, and it is the metric to drive down.

Then ask which control should have caught it earlier. Was the pre-commit hook missing? Was push protection bypassed, and by whom? Did the AWS support case reach a mailbox nobody reads? Unit 42 specifically recommends aggregating support cases, for example through AWS Systems Manager Explorer, so security teams see them. Our guide to incident management architecture with severity levels and blameless postmortems has a template that fits this format.

Trade-offs, Gotchas, and What Goes Wrong

The most common failure is a split notification path. GitHub emails the committer, AWS emails the account’s contacts and opens a support case, and Google emails project owners. None of these reliably reaches the security on-call. Route AWS Health events through EventBridge to your paging system, and alert on CloudTrail AttachUserPolicy events whose policyArn contains AWSCompromisedKeyQuarantine.

Containment decision flow for leaked cloud credentials covering replacement, deactivation, derived-session denial, persistence hunting and escalation

Figure 4: Containment decision flow. The branch that most teams skip is the hunt for persistence after the key itself is dead.

Figure 4 makes the second gotcha explicit. Deactivating the key, revoking sessions and closing the ticket feels complete, yet the persistence hunt is what decides whether the incident is over. If Query 3 finds a new key or user, the scope is now the account, and the response escalates.

Scanner limits are the third issue. Unit 42 notes that GitHub push protection may skip very large pushes and only alerts on the first five secrets in a single push. Gitleaks and TruffleHog rely on patterns and entropy, so custom internal token formats need custom rules. Every scanner produces false positives, and alert fatigue leads to “I’ll fix it later” bypasses that never get fixed.

Fourth, the quarantine policy changes over time. AWS stopped attaching older versions when a new one shipped, but users quarantined years ago may still carry an older version with fewer denies. Audit IAM users for any AWSCompromisedKeyQuarantine attachment and treat each one as an open incident until the key is retired.

Fifth, revocation has collateral damage. AWSRevokeOlderSessions cuts off every user of a role, including legitimate pipelines and engineers, and the AWS CLI caches credentials until you clear ~/.aws/cli/cache. A deny on a shared deployment role during business hours can look like an outage. Coordinate first when the role is shared, but do not delay when the leak is public.

Finally, do not rewrite Git history as your first move. Force-pushing to remove a secret does not remove it from forks, clones, caches or the attacker’s copy. Revoke first; clean history later, if at all.

Practical Recommendations

Treat every confirmed case of leaked cloud credentials as an incident with a severity, an owner and a timeline, even when the provider has already quarantined it. The provider’s controls buy you time; they do not finish the work. Build the runbook before you need it, so the first person who sees an alert can run containment in minutes without asking permission.

Prioritize the controls that shorten the exposure window. Server-side push protection with delegated bypass prevents most public leaks. Routing AWS Health events and quarantine attachments to paging closes the notification gap. A saved set of Athena queries turns blast-radius analysis from a day of ad-hoc work into a fifteen-minute checklist.

Invest in eradication in parallel. Every long-lived key you replace with OIDC or a workload identity is one fewer key that can leak. Set a target, such as zero active IAM user keys in production accounts, and report against it monthly.

A short checklist to adopt this week:

  • Add the Gitleaks pre-commit hook to repository templates.
  • Enable repository push protection and delegated bypass on production organizations.
  • Confirm Google Cloud’s iam.serviceAccountKeyExposureResponse is DISABLE_KEY.
  • Route AWS Health events and quarantine AttachUserPolicy events to on-call.
  • Save the four Athena lineage queries and test them on a canary key.
  • Enable CloudTrail data events for S3 buckets holding sensitive data.
  • Plant canary keys on developer machines and in CI variables.
  • Track active access keys older than 90 days and drive the count down.

Frequently Asked Questions

What should I do first if my AWS access key is leaked?

Deactivate the key immediately with aws iam update-access-key --status Inactive, unless production depends on it and a replacement can ship within minutes. Then attach a deny policy keyed on the IAM user’s unique ID to stop sessions minted with GetSessionToken, and revoke active sessions on any role the user can assume. Leave AWS’s quarantine policy attached and follow the support case. Only after containment should you query CloudTrail for everything the key and its descendant credentials did.

Does AWS automatically revoke leaked access keys?

No. When AWS learns a key was exposed publicly, typically through GitHub’s secret scanning partner program, it attaches the AWSCompromisedKeyQuarantineV3 managed policy to the IAM user and opens a support case. The policy denies a list of high-risk actions such as creating users or keys and launching instances. The key itself stays active, and any action not on the deny list still works. AWS says the policy does not replace your own rotation and incident response.

How does GitHub push protection work?

Push protection scans pushes for supported secret patterns and blocks the push before the secret lands in the repository. On GitHub.com, push protection for users is enabled by default and covers pushes to public repositories. Repository-level push protection is disabled by default and requires GitHub Secret Protection. Users with write access can bypass it by giving a reason, which creates an alert and an audit-log entry. Delegated bypass restricts who may approve bypasses.

Is rotating a leaked key enough?

Usually not. A leaked key can mint temporary credentials that remain valid independently: GetSessionToken sessions for IAM users last up to 36 hours, and role sessions last up to the role’s maximum. An attacker can also create new access keys or users that are unrelated to the leaked key. Proper credential leak incident response therefore revokes derived sessions with deny policies, then searches CloudTrail for persistence before closing the incident.

What is the difference between secret scanning and push protection?

Secret scanning finds secrets that already exist in a repository’s history, issues, pull requests or other content, and raises alerts for remediation. Push protection is preventive: it inspects new pushes and rejects ones containing supported secrets. Both use the same detection patterns. Secret scanning tells you about past mistakes, which still require revocation. Push protection stops the next mistake. Mature programs run both, plus local pre-commit scanning with tools such as Gitleaks or TruffleHog.

How long do leaked secrets stay valid?

Often for years. GitGuardian’s 2026 report found that more than 64% of secrets confirmed valid in 2022 were still valid when retested in January 2026. Providers that auto-disable keys, such as Google Cloud for service account keys, shorten this for their own credential types. Most third-party API tokens and internal credentials have no such program, so they stay live until someone revokes them. That is why expiry by design beats rotation by process.

Further Reading

By Riju — about

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *