# Credential Rotation and Revocation > Invalidating an exposed credential and replacing it everywhere it is consumed, without an outage — the only step that actually ends a secret leak, and the one most programs never finish. ## How it works Detection, ticket closure and file deletion change nothing for an attacker; only invalidation does. The data shows how rarely that happens: - **64%** of secrets confirmed valid in 2022 were still valid in January 2026 (GitGuardian). - Truffle Security disclosed 21,981 live keys from GitLab/Bitbucket; **81%** still worked six months later. - Flare: 75% of developers who removed a secret from a Docker image never rotated it. - 2,600 valid TLS certs mapped to leaked private keys (GitGuardian/Google): 4,300 disclosure emails, 9% response; only 24 revoked via CRL. 84 still valid in Jan 2026. - CISA's leaked GovCloud keys stayed valid 48h after the repo was pulled. Why it stalls: rotation itself is mechanical; the hard part is **finding every copy and every consumer**. GitGuardian's worked example: one leaked production key had 13 copies (hardcoded fallback, config file, a stale pipeline variable that overrode the vault, a Jira ticket…) and the team knew about one. Revoke first and the next deploy breaks; update only the vault and the pipeline keeps using the old variable. ## Metric ``` time_to_revoke = confirmed_invalidation_ts - validation_ts ``` Track it alongside MTTD/MTTR; MTTR can close on a ticket while the key still works. ## Rotation patterns | Pattern | Mechanism | Outage risk | |---|---|---| | **Dual-credential overlap** | Two active keys (AWS access keys, key-pair auth): issue new, migrate consumers, validate, disable old | Low | | **Staged rotation (AWS Secrets Manager)** | Lambda steps create → set → test → finish; versions `AWSPENDING` → `AWSCURRENT` → `AWSPREVIOUS` for rollback | Low if the function validates the target DB/user and the pending secret before promotion (OWASP) | | **Dynamic / leased** | Vault/STS mint per-consumer creds; lease expiry revokes ([[Vaults and Secret Stores]]) | Very low | | **Single-credential swap with revert** | Platforms allowing one password per account: rotate, owner validates, temporary revert path if it breaks | Medium — revert path is what keeps owners willing to rotate | | **Mounted-secret refresh** | Secrets Store CSI Driver `--enable-secret-rotation=true`; app must re-read the file or restart | Medium | ## Incident runbook (leaked credential) 1. **Validate** read-only (who/what is it: `aws sts get-caller-identity`), record timestamp. 2. **Scope**: permissions, consumers, every copy (code, CI vars, vault, tickets, chat, images, endpoints), owner. 3. **Revoke/rotate** in blast-radius order — cloud keys and roles first; issue the replacement into a secret manager or an OIDC role, not a new `.env` line. 4. **Confirm** the old credential fails; review provider logs from the exposure time, not the detection time. 5. Clean up history/artifacts afterwards ([[Secrets in Git History]]). For mass events, platforms push keys to issuers for bulk revocation: Railway sent leaked customer keys to GitHub, GitLab, Anthropic, OpenAI, OpenRouter and Stripe, rotated all its own keys twice, and paused deploys; >100,000 users may have had keys revoked upstream. Truffle Security's revocation program and the GitHub partner program let issuers auto-revoke what scanners find. ## Inventory first (SCALER) For service accounts at scale: **S**cale (discover accounts and where creds spread, using login history) → **C**lassify (tie to app) → **A**ssign (named owner) → **L**ifecycle (expiry with warnings) → **E**nforce → **R**otate. Skipping a stage reappears later as an outage. Pre-rotation checklist: valid? exposed where? scope? consumers? vaulted? duplicates? owner? rollback plan? ## Related - [[Secrets Management]] - [[Leaked Cloud Credentials]] · [[Secret Scanning]] · [[Vaults and Secret Stores]] · [[Workload Identity Federation]] - [[Developer Workstation Secrets]] ## Sources - [[raw/blog.gitguardian.com/how-to-measure-time-to-revoke-for-exposed-credentials-10653|How to Measure Time to Revoke for Exposed Credentials]] - [[raw/blog.gitguardian.com/how-to-reduce-time-to-revoke-for-exposed-credentials-10821|How to Reduce Time to Revoke for Exposed Credentials]] - [[raw/blog.gitguardian.com/why-is-credential-rotation-so-hard-follow-one-leaked-production-key-15022|Why Is Credential Rotation So Hard? Follow One Leaked Production Key]] - [[raw/blog.gitguardian.com/rotating-1-000-service-account-passwords-with-zero-outages-why-the-inv-12422|Rotating 1,000 Service Account Passwords With Zero Outages]] - [[raw/blog.gitguardian.com/service-account-credential-rotation-the-blast-radius-checklist-11989|Service Account Credential Rotation: The Blast Radius Checklist]] - [[raw/trufflesecurity.com/truffle-security-secrets-revocation-program-13348|Truffle Security Secrets Revocation Program]] - [[raw/blog.gitguardian.com/2-622-valid-certificates-exposed-google-gitguardian-study-4071|2,622 Valid Certificates Exposed: Google-GitGuardian Study]] - [[raw/gitguardian.com/the-state-of-secrets-sprawl-2026-gitguardian-annual-report-4349|The State of Secrets Sprawl 2026 - GitGuardian Annual Report]] - [[raw/flare.io/thousands-of-secrets-exposed-on-docker-hub-4067|Thousands of Secrets Exposed on Docker Hub]] - [[raw/cheatsheetseries.owasp.org/secrets-management-owasp-cheat-sheet-series-2716|Secrets Management - OWASP Cheat Sheet Series]] - [[raw/sedai.io/aws-secrets-manager-secure-credential-storage-best-practices-4494|AWS Secrets Manager: Secure Credential Storage & Best Practices]] - [[raw/secrets-store-csi-driver.sigs.k8s.io/secret-auto-rotation-with-secrets-store-csi-driver-4058|Secret Auto Rotation with Secrets Store CSI Driver]] - [[raw/groundcover.com/secret-rotation-how-it-works-4057|Secret Rotation: How It Works]] - [[raw/medium.com/the-railway-breach-from-a-build-system-privilege-escalation-to-decrypt-13147|The Railway Breach: From a Build-System Privilege Escalation to Decrypted Customer Secrets]] - [[raw/medium.com/find-leaked-secrets-in-git-and-rotate-them-before-they-are-used-14860|Find leaked secrets in Git and rotate them before they are used]] - [[raw/krebsonsecurity.com/cisa-admin-leaked-aws-govcloud-keys-on-github-8102|CISA Admin Leaked AWS GovCloud Keys on Github]]