DevelopmentIndustry Guide12 min readPublished June 4, 2026

~29M secrets leaked in 2025 · 64% of 2022 leaks still active · zero-downtime rotation is a solved problem

Secrets Management & Key Rotation: The 2026 Reference

GitGuardian counted roughly 29 million hardcoded secrets pushed to public GitHub in 2025, and most leaked credentials are never revoked. The hard part was never the rotation mechanics — those are solved. The hard part is making rotation automatic enough that it happens even when no one is watching.

DA
Digital Applied Team
Senior engineers · Published Jun 4, 2026
PublishedJun 4, 2026
Read time12 min
SourcesOWASP · GitGuardian · Vercel · AWS
Secrets on public GitHub
~29M
added in 2025 (GitGuardian)
+34% YoY
2022 leaks still valid
64%
active as of Jan 2026
AI-service secret leaks
+81%
YoY surge (GitGuardian)
OIDC token TTL
60min
Vercel federation, cached ≤45m

Secrets management is the discipline of keeping the credentials that unlock your systems — API keys, database passwords, signing secrets, OAuth tokens — out of source code, off developer laptops, and unusable the moment they leak. In 2026 it stopped being a nice-to-have. GitGuardian's own dataset counted roughly 29 million hardcoded secrets added to public GitHub in 2025, and the credential you forgot to rotate is now the credential an attacker most reliably finds.

What's changed is not the threat — leaked credentials have been a top breach vector for years — but the texture of it. AI coding assistants ship code faster and, per GitGuardian's measurement, leak secrets at a higher rate while doing so. A brand-new attack surface opened up in Model Context Protocol (MCP) configuration files. And, paradoxically, the leaks that hurt most are the ones nobody ever cleaned up: the same dataset found that 64% of credentials valid and leaked in 2022 were still active in January 2026.

This reference walks the full lifecycle: how big the 2026 leak problem actually is, why AI tooling amplifies it, the OWASP-defined stages every secret moves through, a comparison of where to store secrets in a serverless-first stack, the zero-downtime rotation patterns that genuinely work, why OIDC federation lets you skip rotation entirely for some credentials, and the scanning and incident-response steps that catch the leaks you didn't prevent. Every figure below is attributed to its primary or stated source.

Key takeaways
  1. 01
    Leak volume is climbing, not plateauing.GitGuardian's State of Secrets Sprawl 2026 reports roughly 29 million hardcoded secrets pushed to public GitHub in 2025 — a 34% year-over-year jump and, per the report, the largest single-year increase it has recorded.
  2. 02
    The real failure is non-remediation.Rotation mechanics are solved. The gap is governance: GitGuardian found 64% of credentials leaked and valid in 2022 were still active in January 2026, largely because teams lack a repeatable path to revoke and replace a leaked secret.
  3. 03
    AI tooling is a leak amplifier.Per GitGuardian's own dataset, AI-assisted commits leaked secrets at roughly twice the baseline rate, and AI-service credential detections surged 81% year-over-year. Treat AI-generated code as a higher-risk source for hardcoded secrets, not a safer one.
  4. 04
    OIDC federation eliminates the credential entirely.Short-lived, exchangeable OIDC tokens — Vercel issues them with a 60-minute TTL — remove the long-lived API key from your environment variables altogether. For database access, Vault dynamic secrets do the same: generate on demand, auto-revoke on expiry.
  5. 05
    Layer your defenses: scan, rotate, federate.The production-grade stack is a fast pre-commit hook (Gitleaks), a verifying scanner in CI (TruffleHog), platform push protection, and short-lived credentials wherever the provider supports them — so a hardcoded secret is caught before it ships and useless if it does.

01The Leak PictureThe 2026 numbers are worse, and the reason is remediation.

Start with the volume. GitGuardian's State of Secrets Sprawl 2026 — the firm's annual scan of public GitHub activity — reported 28,649,024 hardcoded secrets added in 2025, a 34% increase year over year and, per GitGuardian, the largest single-year jump in its reporting history. These figures come from GitGuardian's own detection dataset, not a neutral industry benchmark; read them as a credible vendor measurement of the leaks its scanners can see, which skews toward public repositories.

The more uncomfortable finding is what happens after a secret leaks. GitGuardian reported that 64% of credentials that were valid and leaked in 2022 were still active and exploitable in January 2026. Separately, it found that long-lived secrets dominate the policy-breach pattern: around 60% of the violations it tracks involve credentials with no expiry configured at all. The throughline is governance, not technology. Rotation works; the problem is that most teams have no repeatable path to actually do it when a leak is discovered.

Where secrets leaked in 2025 · GitGuardian-measured counts

Source: GitGuardian State of Secrets Sprawl 2026
Secrets on public GitHub (2025)GitGuardian dataset · +34% YoY
~29M
AI-service credential leaks (2025)GitGuardian · +81% YoY surge
~1.3M
DeepSeek API keys on public GitHubsingle-provider leak count
113K
Unique secrets in MCP config files2,117 (8.8%) confirmed valid
24K

Two structural findings reframe where you should look. First, private repositories are not safer: GitGuardian reports internal repos are roughly six times more likely to contain a hardcoded secret than public ones — the perceived safety of a private repo breeds carelessness. Second, a meaningful share of incidents originate outside repositories entirely. About 28% of the credential incidents GitGuardian tracked came from collaboration tools — Slack, Jira, Confluence — and those were, in its data, 13 percentage points more likely to be classified as critical than repository leaks. Your scanning coverage probably stops at the repo; the leaks don't.

How the attacker mix is shifting
The 2026 Verizon Data Breach Investigations Report found that software vulnerability exploitation (around 31% of breaches) edged ahead of credential abuse as the top initial-access vector — by Verizon's account, the first time in the report's history that credential abuse was not number one. Read this carefully: credential abuse did not disappear. It fell to roughly 13% of breaches. Stolen and leaked credentials remain a first-tier risk; the story is that the attacker toolkit is diversifying, not that secrets stopped mattering.

02The AI AmplifierThe productivity-security paradox of AI-assisted code.

Here is the angle most coverage misses. AI coding tools do two things at once: they write more code, faster, and — per GitGuardian's dataset — that code leaks secrets at a higher rate than human-baseline commits. GitGuardian reported that AI-assisted commits leaked secrets at roughly twice the baseline rate. We are deliberately not printing the precise per-tool percentages as if they were a neutral benchmark: these come from GitGuardian's own measurement and methodology, they have not been independently replicated, and the honest framing is "roughly double, per GitGuardian," not a hard universal constant.

The category-level trend is the durable signal. GitGuardian reported that AI-service credential leaks surged about 81% year over year in 2025, with eight of its ten fastest-growing detector categories tied to AI services. As a single illustration, it counted roughly 113,000 leaked DeepSeek API keys on public GitHub. The mechanism is intuitive: developers wiring up new AI providers paste keys into quick-start scripts, commit the scaffolding, and move on. More providers plus faster scaffolding equals more exposed keys.

"AI-assisted commits leak secrets at a 3.2% rate, roughly 2x the baseline."— GitGuardian, State of Secrets Sprawl 2026

The takeaway is not "stop using AI tools." It is to treat AI-generated code as a higher-risk source for hardcoded secrets and adjust your guardrails accordingly: a pre-commit secret scanner is no longer optional when an assistant can generate fifty lines of integration boilerplate in a keystroke. The same automation that creates the risk can close it — push protection and pre-commit hooks run just as fast against AI output as human output.

03New SurfaceMCP config files: a leak surface that didn't exist two years ago.

Model Context Protocol configuration files are where AI agents are told which tools and services they may call — and, too often, the credentials to call them with. GitGuardian's 2026 report is the first large-scale measurement of this surface: it found 24,008 unique secrets exposed in MCP configuration files on public GitHub, of which 2,117 (8.8%) were confirmed validcredentials. That validity rate matters — these aren't expired placeholders, they are live keys an attacker could use.

The leak mechanism is depressingly familiar: developers copy an MCP server config from a tutorial, drop their real API key into the example, get it working, and commit the whole file. Because MCP tooling is new, most teams haven't added these file patterns to their scanner allowlists or pre-commit checks yet. If you're building agentic workflows — and on a custom-AI-build stack you probably are — add MCP config paths to your secret-scanning scope today, and prefer referencing credentials by environment variable inside those files rather than inlining them.

A practical rule for agent configs
Treat any committed file that an AI agent reads as a public file. MCP configs, tool manifests, and prompt templates all get copied, shared, and pushed. Reference secrets through environment variables or a secrets manager from inside those files — never paste the literal key. The same discipline applies to the webhook and callback handlers your agents trigger; our reference on idempotent webhook delivery covers safely re-running rotation callbacks without double-applying them.

04The LifecycleOWASP's four lifecycle stages every secret moves through.

The OWASP Secrets Management Cheat Sheet is the industry-standard reference here, and it frames every secret as moving through four lifecycle stages. Getting the lifecycle right is what turns secrets management from a pile of one-off env vars into a governable system. OWASP also classifies hardcoded and improperly stored secrets under the A04:2025 — Cryptographic Failures category in the current OWASP Top 10, with continuous secret scanning recommended as a compensating control.

Stage 01
Creation
01

Generate with least privilege and cryptographic robustness. OWASP recommends AES-256-GCM or ChaCha20-Poly1305 for at-rest encryption, TLS for all secret transmission, and separating production from development secrets into distinct management systems.

Least privilege
Stage 02
Rotation
02

Replace credentials on a schedule and automate it. OWASP notes NIST guidance excludes routine human-password rotation — but machine credentials should rotate automatically. Automation is what makes rotation happen even when no engineer is watching.

Automate it
Stage 03
Revocation
03

De-authorize a credential immediately on compromise. This is the stage that breaks most often in practice — the 64% still-valid figure is fundamentally a revocation-and-rotation failure, not a detection failure.

Immediate on compromise
Stage 04
Expiration
04

Assign every secret a type-appropriate TTL so it dies on its own if nothing else cleans it up. Long-lived secrets with no expiry are, in GitGuardian's data, the single dominant policy-violation pattern.

TTL everything
"Engineers should not have access to all secrets in the secrets management system, and the Least Privilege principle should be applied."— OWASP Cheat Sheet Series, Secrets Management Cheat Sheet

05Storage OptionsWhere to put secrets in a serverless-first stack.

OWASP's recommended order of preference for CI/CD secrets is, in descending order: a dedicated secrets-management system (Vault, AWS Secrets Manager); the CI/CD native store (GitHub Secrets, GitLab Variables) for short-lived, non-critical credentials; and runtime-only retrieval, where the running service fetches the credential at runtime and the CI/CD pipeline never touches it at all. Most leaks live below that hierarchy — in plain env vars and committed config — so the first move is simply climbing it.

The table below is our consolidated comparison for a serverless-first stack. We have not seen an existing comparison that puts OIDC workload identity and open-source self-hosted options alongside the managed services in one view; most stop at three tools. Cells are drawn from the vendor documentation and comparison sources cited throughout this guide.

Secrets storage options for a serverless-first stack, compared across encryption, dynamic secrets, rotation, audit logging, self-hosting, and best-fit workload.
OptionDynamic secretsAuto rotationSelf-hostedBest for
Platform env vars (Vercel/Netlify)NoManual (generate-swap-revoke)N/A (managed)Small projects; pair with OIDC for cloud access
GitHub / GitLab CI secretsNoManualN/A (managed)Short-lived, non-critical CI/CD credentials
AWS Secrets ManagerPartial (Lambda-driven)Yes (staging labels)No (managed cloud)AWS-native apps wanting managed rotation
HashiCorp VaultYesYes (online rekey)YesDynamic secrets + transit encryption in one tool
Doppler (SaaS)LimitedYesNo (SaaS)Broad integration coverage across many syncs
Infisical (OSS)Yes (Postgres/MySQL/RabbitMQ)YesYes (MIT core)Vendor-neutral OSS; ships an MCP server for agents
OIDC workload identityEffectively (short-lived)N/A — no stored credentialN/A (federation)Cloud access from CI/serverless without stored keys
The open-source pivot
HashiCorp's 2023 move to the Business Source License pushed teams that need a vendor-neutral open-source guarantee toward alternatives including Infisical and OpenBao. Infisical's open core (MIT) passed 25,000 GitHub stars in February 2026, scans 140+ secret types, and ships an MCP server for connecting AI agents securely. Vault remains, per the comparison sources, the only tool in its class offering both dynamic secrets and transit (encryption-as-a-service) in one product. If you're calling these systems at volume during rotation, rate-limiting your secrets-management API calls keeps the rotation job from throttling itself.

06Zero-DowntimeRotation without an outage is a solved problem.

The core pattern is the same everywhere, and it is dead simple: generate the new credential, deploy it everywhere, verify, and only then revoke the old one. The critical constraint — the one that causes most rotation outages — is the overlap window. Both old and new credentials must be valid simultaneously until every consumer has picked up the new one. Invalidate the old credential too early and anything that hasn't redeployed yet breaks.

Vercel documents this precisely for environment variables: generate the new credential at the provider, update the Vercel environment variable, redeploy the affected project(s), verify, and finally invalidate the old credential — and it warns explicitly that invalidating the old credential before all projects have redeployed will break those projects. AWS Secrets Manager encodes the same idea with staging labels: AWSCURRENT and AWSPENDING track the two versions through a four-step Lambda flow (createSecretsetSecret testSecretfinishSecret), with both credentials active during the transition window.

Pattern A
Generate-swap-revoke (static keys)

The universal pattern for third-party API keys, OAuth client secrets, and JWT signing secrets. Generate new, deploy everywhere, verify, then revoke old. The overlap window is mandatory — accept dual-valid credentials until every consumer has migrated.

Most third-party keys
Pattern B
Staging labels (managed rotation)

AWS Secrets Manager automates the swap with AWSCURRENT / AWSPENDING labels and a createSecret → setSecret → testSecret → finishSecret Lambda. The service holds both versions valid through the transition so consumers never see a gap.

AWS-native apps
Pattern C
Dynamic secrets — rotation you skip

Vault generates short-lived database credentials on demand with a configurable TTL and auto-revokes them on expiry. There is no rotation event to schedule because no long-lived credential exists. The strongest pattern where the provider supports it.

Database access
Pattern D
Online key rekey (encryption keys)

Vault rotates its encryption key online via a single API call with no downtime: the old key stays in the keyring to decrypt existing values while new values use the new key. Rekeying the root and unseal keys is a separate two-phase operation.

Transit / at-rest keys

One forward-looking note on operationalizing rollouts: the safest way to cut traffic over to a freshly rotated credential is to gate it. Rather than flipping every consumer at once, route a small slice of traffic to the new credential, confirm health, then ramp — exactly the discipline described in our guide to feature-flagging credential rollouts. A flag lets you abort instantly if the new credential misbehaves, without a redeploy, and it makes the overlap window an observable, controllable thing instead of a race.

07OIDC FederationThe best rotation is the one you never have to do.

The most consequential shift for serverless and CI engineers is also the least adopted, because most tutorials still show a long-lived API key pasted into an environment variable. OIDC federation removes the stored credential entirely. Vercel's OIDC federation issues short-lived, non-persistent tokens signed by Vercel's identity provider; AWS, GCP, and Azure can exchange those tokens for scoped, short-lived cloud credentials. Per Vercel's docs, the token TTL is 60 minutes and Vercel caches it for up to 45 minutes to ensure validity within a function's execution lifecycle. The net effect: no long-lived cloud key ever lives in your environment variables, so there is nothing to leak and nothing to rotate.

"When you create long-lived, persistent credentials in your backend to allow access from your web applications, you increase the security risk of these credentials being leaked and hacked."— Vercel Documentation, OIDC Federation

The same principle applies to databases through Vault dynamic secrets. Instead of a static database password sitting in an env var, the service requests a credential from Vault at runtime; Vault generates one scoped to a configurable TTL and automatically revokes it when the lease expires. We deliberately avoid quoting a single default TTL — the actual value depends on the secret engine and your configuration — but the pattern is the point: short-lived by construction, revoked automatically, never committed anywhere.

If you take one architectural decision from this reference, make it this: for any credential where the provider supports short-lived, federated, or dynamically-issued access, prefer that over a stored long-lived key. It is the only approach that defeats the 64% never-revoked statistic structurally, because there is no persistent secret for anyone to forget to rotate.

08ScanningCatch the leaks you didn't prevent.

Federation and rotation reduce how many long-lived secrets exist; scanning catches the ones that still slip through. The production-grade strategy layers two open-source tools with platform push protection. Gitleaks covers 150+ secret patterns and is fast enough to run as a pre-commit hook, blocking a push in milliseconds before the secret ever reaches the remote. TruffleHog covers 800+ secret types across git repos, S3, Docker images, Slack, and Jenkins — and, crucially, actively verifies whether a detected credential is still live, which cuts the noise of expired-placeholder false positives. The recommended combination: Gitleaks pre-commit plus TruffleHog in CI.

Platform-level push protection is the third layer. GitHub's secret scanning blocks known credential patterns at push time; per GitHub's changelog, it added base64-encoded secret detection with push protection by default in November 2025 and shipped extended metadata (owner, email, creation and expiry dates) for leaked secrets in February 2026. GitHub also reports that a Copilot-assisted scanning improvement achieved a 94% reduction in false positives. We are reporting only the figures GitHub states; treat broader "total secrets blocked" claims with caution unless you can confirm them against the primary changelog.

Layer 01 · Pre-commit
Gitleaks hook
150+ patterns · blocks in ms

Runs locally before the commit lands. Fast, deterministic, and the single highest-leverage control for AI-generated boilerplate — it stops the secret before it ever leaves the laptop.

Stop it at the source
Layer 02 · CI
TruffleHog verifier
800+ types · live-credential check

Scans the full repo plus S3, Docker, Slack, and Jenkins in CI, and verifies whether each detected credential is still active — so your alerts are real leaks, not expired examples.

Verify, don't just detect
Layer 03 · Platform
Push protection
GitHub secret scanning

Blocks known credential patterns at push time, with base64 detection on by default since Nov 2025 and richer leaked-secret metadata since Feb 2026. A 94% false-positive reduction is the figure GitHub states.

Backstop at the remote

09Incident ResponseWhen a secret leaks: the OWASP four-step playbook.

Detection is worthless without a rehearsed response. OWASP's incident-response playbook for a leaked secret is four ordered steps, and the order matters: Revoke the credential immediately to de-authorize it; Rotate in a replacement, preferably through automation; Delete the secret from all systems and from commit history; and Logthe access patterns prior to exposure so you can assess blast radius. Revoke comes first for a reason — removing the secret from git history without first revoking it leaves a live credential in anyone's existing clone.

OWASP also requires that the whole lifecycle be auditable: who requested each secret, what approvals were granted, when it was used, and every rotation and revocation event. That audit trail is what turns a one-off scramble into the repeatable remediation path whose absence drives the 64% never-revoked figure. The discipline is the deliverable — a documented, drilled runbook beats a clever tool every time.

"Auditing is an essential part of secrets management due to the nature of the application. You must implement auditing securely to be resilient against attempts to tamper with or delete the audit logs."— OWASP Cheat Sheet Series, Secrets Management Cheat Sheet

For teams building on a custom-AI stack, this is exactly the kind of governance we wire into delivery from day one rather than bolting on after an incident. If you want a second set of senior eyes on your secrets posture — scanning coverage, rotation automation, OIDC adoption, and an incident runbook — our AI transformation engagements and custom development work start with precisely this kind of review.

10ConclusionThe mechanics are solved. The discipline is the work.

The state of secrets, June 2026

Stop asking how to rotate. Ask how to make rotation automatic enough that nobody has to remember.

The 2026 data tells a consistent story. Leak volume is climbing — roughly 29 million secrets on public GitHub in 2025 by GitGuardian's count — AI tooling is amplifying the rate, and a brand-new MCP surface is leaking live keys. But none of that is the core problem. The core problem is that most leaked secrets are never cleaned up: 64% of credentials leaked in 2022 were still valid in January 2026.

That is a governance failure, not a technical one, and the fix is architectural. Use OIDC federation and dynamic secrets wherever the provider supports them, so the long-lived credential simply doesn't exist. Where you must hold a static key, use the generate-swap-revoke pattern with a real overlap window. Layer Gitleaks pre-commit, TruffleHog in CI, and platform push protection so a hardcoded secret is caught before it ships and verified-dead if it does. And rehearse the OWASP revoke-rotate-delete-log playbook so remediation is a runbook, not a panic.

The teams that come out ahead in 2026 won't be the ones with the most sophisticated vault. They'll be the ones who made rotation and revocation so automatic that the question "is this key still valid?" stops being scary — because the answer is always "only for the next sixty minutes."

Secrets governance, built in not bolted on

Make rotation automatic enough that a leaked key is a non-event.

We build production systems on a custom-AI stack with secrets governance designed in from day one — OIDC federation, dynamic secrets, layered scanning, and a rehearsed incident runbook — so a leaked key is caught before it ships and useless if it isn't.

Free consultationSenior engineersTailored solutions
What we review

Secrets posture engagements

  • Scanning coverage — pre-commit, CI, and platform push protection
  • Rotation automation for static keys and managed services
  • OIDC federation and dynamic-secret adoption
  • MCP and agent-config secret hygiene
  • Incident runbook — revoke, rotate, delete, log
FAQ · Secrets management 2026

The questions we get every week.

GitGuardian's State of Secrets Sprawl 2026 reported 28,649,024 hardcoded secrets added to public GitHub in 2025 — roughly 29 million — a 34% increase year over year and, per the report, the largest single-year jump in its reporting history. It's important to attribute this correctly: these are figures from GitGuardian's own detection dataset, not a neutral industry benchmark, and they reflect the leaks its scanners can observe across public repositories. The trend, not the exact integer, is the durable takeaway: leak volume is climbing, not plateauing, and AI-service credential detections grew especially fast.