Deleting a leaked Git secret is not enough—rotate the credential

· Original article ↗

Summary

The article demonstrates that deleting a file, rewriting Git history, or deleting a repository may leave leaked secrets accessible. It recommends revoking and replacing exposed credentials, then checking for signs of prior misuse.

Key points

  • The article says LiteLLM’s post-mortem described an administrative key committed to a public repository; the key was reportedly used months later to obtain a GitHub token and ship a malicious release.
  • Deleting a file in a later commit does not remove the secret from earlier Git history, which secret scanners can still inspect.
  • The article demonstrates that a rewritten history may leave commits retrievable from GitHub by their commit hash.
  • Deleting a repository may not remove copies retained in forks.
  • The recommended response is to revoke the exposed credential, issue a replacement, and update systems that used the old one.
  • After rotation, review credential usage logs, recent commits, CI configuration changes, and pipeline runs; treat the exposure as an incident if misuse cannot be ruled out.

Article Details

Defense Focus
Detect exposed credentials in source code, Git history, and developer-machine files, then rotate credentials and investigate possible prior misuse.
Detection Methods
  • Scan current code and, when enabled, full Git history, including deleted files.
  • Use known credential patterns and generic-secret detection techniques.
  • Check whether supported leaked credentials are still active.
  • Use IDE extensions and pre-commit hooks to warn before secrets are committed, and block CI/CD builds or pull requests containing secrets.
  • Scan local developer-machine files, including shell history, for hardcoded secrets.
Data Sources
  • Current repository code and full Git history
  • Credential usage and access logs
  • Commits to main and protected branches
  • CI and workflow configuration changes and recent pipeline runs
  • Local files on developer machines, including shell history
Rule Types
  • Known credential-pattern and generic-secret detection
Platforms
  • GitHub
  • GitLab
  • Bitbucket
  • Azure DevOps
Defensive Actions
  • Immediately revoke exposed credentials, issue replacements, and update every place the old credentials were used.
  • Do not rely on deleting a file, rewriting Git history, or deleting a repository to secure a leaked credential.
  • After rotation, review credential usage and access logs, recent commits, CI/workflow changes, and pipeline runs for signs of prior misuse.
  • If prior misuse cannot be ruled out, treat the exposure as an incident.
  • Enable full Git history scanning and use pre-commit, IDE, and CI/CD secret checks.
  • Use device scanning to look for hardcoded secrets on developer machines.

MITRE ATT&CK

People

Vendors

Products

Tools

Related Articles