A company rotates a leaked API key the moment it’s discovered sitting in a public repository, considers the genuine incident resolved, and doesn’t actually realize that same key sat readable in the repository’s full commit history for over a year before anyone ever actually noticed it was there at all - plenty of real time for anyone who happened to be looking through that history to have already quietly found and used it.
Why Removing a Secret From the Latest Commit Doesn’t Genuinely Remove It
Deleting a secret from a file and committing that specific change only removes it from the repository’s current, latest state - the original commit that actually introduced the secret still remains fully accessible in git history, and anyone with genuine read access to that repository can check out that specific earlier commit and retrieve the exact original secret value directly, entirely unaffected by any later commit that appeared to remove it. This is a genuinely common, easy misunderstanding: teams treat a secret as resolved the moment it’s removed from the current working file, when the real actual exposure persists indefinitely in git history unless that history is deliberately, specifically rewritten to genuinely purge it.
Why Secrets End Up Committed in the First Place, Repeatedly
Secrets typically end up committed through genuinely mundane, easy-to-understand real mistakes - a developer hardcodes a credential temporarily for local debugging and forgets to actually remove it before committing, a configuration file containing real secrets gets committed because it wasn’t actually added to a proper ignore list, or a secret gets accidentally pasted directly into a commit message itself. These are genuinely human, understandable mistakes rather than any kind of deliberate carelessness, and they recur with real, predictable statistical regularity across any large enough codebase and any large enough team, over any sufficiently long enough period of time.
Why Automated Scanning Needs to Cover Full Git History, Not Just New Commits
Many secrets scanning tools focus specifically on catching new secrets in genuinely new commits going forward, which is valuable and doesn’t actually address secrets that were already committed at some earlier point before that specific scanning tool was ever actually put in place. A genuinely complete secrets scanning approach needs to also scan full existing git history at initial setup time, since a repository can easily be running months or years of accumulated history containing real, still-live secrets that predate any new forward-looking scanning process by a considerable real margin.
Why Rotation Matters More Than Removal Once a Secret Has Genuinely Been Exposed
Once a secret has been committed to a repository with any real meaningful access beyond a single trusted individual, the actual safe assumption is that it may genuinely have already been seen, regardless of how quickly it was subsequently removed from the current working file or how obscure that specific exposure might have originally seemed at the time. Rotating the actual underlying credential itself - not merely removing it from the repository, and not merely rewriting git history to scrub it - is the only real step that genuinely, fully eliminates the actual risk, since a genuinely leaked credential remains dangerous for as long as it stays valid, entirely independent of whether it still remains visible anywhere at all.
