Subscribe to the Non-Human & AI Identity Journal

Why do leaked secrets remain a problem after developers delete them?

Deleting a secret from the latest commit does not remove it from earlier commits, copied artefacts, archives, or other systems that already captured it. Unless the credential is revoked and rotated, it may remain valid and exploitable. That is why detection must be paired with lifecycle response, not treated as the end state.

Why Deleted Secrets Still Matter

Deleting a secret from the latest branch only removes one visible copy. The real problem is that secrets tend to spread into commit history, forks, build artefacts, tickets, chat exports, backups, caches, and downstream systems that already ingested them. Once that happens, the credential is no longer controlled by the developer who deleted it. NHI teams have seen this pattern repeatedly in incidents covered in the 52 NHI Breaches Analysis and the Guide to the Secret Sprawl Challenge.

This is why deletion is not remediation. A leaked API key, token, or certificate can remain valid until it is explicitly revoked, rotated, and removed from every place it was copied. Industry data reinforces the operational gap: GitGuardian and CyberArk report that the average time to remediate a leaked secret is 27 days, even though most organisations believe they have strong secrets management. That lag is long enough for attackers to replay access, move laterally, or automate exfiltration. In practice, many security teams discover the leak only after a downstream system has already been accessed, rather than through intentional secret lifecycle control.

What Actually Happens After a Secret Is Deleted

Deletion changes the codebase, not the credential’s history or validity. Git preserves prior commits, release tags, mirrors, and clones. CI/CD systems may have already pulled the secret into logs or environment variables. Chat systems, issue trackers, and documentation platforms can also preserve copied values. Current guidance suggests treating every exposed secret as compromised the moment it is observed, regardless of whether the original file was cleaned up. For implementation patterns, the OWASP Non-Human Identity Top 10 is useful for mapping credential exposure to concrete control failures.

The operational response should be staged:

  • Identify the secret type and where it was used, including CI/CD runners, SaaS integrations, and workload identities.
  • Revoke or disable the credential at the source before assuming any cleanup is complete.
  • Rotate dependent credentials, certificates, and signing keys that may have trusted the leaked value.
  • Search for copies in repos, archives, tickets, logs, object storage, and developer endpoints.
  • Validate that the replacement secret has a shorter lifetime, tighter scope, and monitored usage.

This is also where automated detection alone fails. GitGuardian’s 230M AWS environment compromise and Reviewdog GitHub Action supply chain attack show how quickly one exposed credential can spread through pipelines that were assumed to be trusted. These controls tend to break down when secrets are reused across multiple services because revocation in one system does not necessarily invalidate access elsewhere.

Where Teams Get Tripped Up

Tighter secret controls often increase operational overhead, requiring organisations to balance developer speed against the cost of constant rotation and incident response. The hardest cases are long-lived secrets, shared service accounts, and credentials embedded in third-party integrations. Best practice is evolving toward short-lived credentials and workload identity, but there is no universal standard for this yet across every toolchain and cloud environment. The practical direction, however, is clear: static secrets should be the exception, not the default.

Autonomous systems raise the stakes further. When an AI agent or automated workload can chain tools, call APIs, and act without human review, a leaked secret becomes an execution primitive rather than a simple login token. That is why current guidance increasingly favours just-in-time provisioning, ephemeral secrets, and workload identity over standing credentials. The latest Anthropic report on AI-orchestrated cyber espionage is a reminder that automated tool use can amplify small mistakes into fast-moving incidents. For broader governance context, the Ultimate Guide to NHIs — Static vs Dynamic Secrets explains why TTL and scope matter more than the storage location of the secret itself.

Where guidance breaks down most often is in hybrid estates with shared credentials, weak inventory, and no authoritative source for revocation status.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST CSF 2.0 and NIST AI RMF set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP Non-Human Identity Top 10 NHI-03 Focuses on secret exposure and rotation failures for non-human identities.
NIST CSF 2.0 PR.AC-4 Least-privilege access limits blast radius after a secret leak.
NIST AI RMF AI risk governance is needed when agents can misuse leaked credentials.

Assign ownership for autonomous workload access and review credential risk continuously.