NewDo you know which regulations apply to you? Find out in under 3 minutes. Our sincere gift:EU scoperKorea scoper
How can we help?

Message us on

KakaoTalkLINE

Response within 48 hours

Send us an email →
The Secret You Deleted Is Still in Your Repo
Vulnerability

The Secret You Deleted Is Still in Your Repo

July 24, 2026·Alex Holmquist, Panke IT Solutions LLC

You committed an API key by mistake, caught it within the hour, deleted it in the next commit, and moved on. I have seen people do this more times than I can count. But the key is still there. All you did is stack more changes on top of a tree that still has your secret. Git stacked it on top. Here is why deleting a leaked secret does not help, and the two actions that actually do.

A row of git commits on a dark canvas: an early commit glows with a small key inside it, a later commit labelled

Git keeps everything

Git stores your project as a chain of snapshots. A new commit leaves every earlier commit untouched.

The snapshot that holds the secret is back in the chain, reachable by anyone with access to the repo. That's the whole point of version control — it lets you return to any past state.

An attacker reads all the history

Here are examples of how your git history reaches an "outsider".

The first is a public repository, which automated scanners crawl around the clock.

GitGuardian, State of Secrets Sprawl 2026: 28.65 million new hardcoded secrets appeared in public commits in 2025 — a 34% jump in a single year.

A freshly pushed credential is often found within minutes.

The second is much more stealthy. If you deploy a website by copying your project folder onto the server, it's possible that the .git directory comes with it.

A tool such as git-dumper can easily reconstruct your full source tree.

In both cases, the point is clear: the attacker can walk the tree back and read the secret you believed had been erased.

Deleting doesn't help

A photocopier's output tray holds a stack of identical sheets each marked with a key, and several hands lift copies off the top and carry them away in different directions, while in the foreground a hand feeds a single copy into a shredder — too late.

Even if you try to rewrite git history in the proper way — git filter-repo or BFG strip the file from every commit — the secret is still not safe.

From the very second it was pushed it may have been cloned, forked, cached by a crawler, or copied by a scanner.

Rotate the secret

Treat any secret that has reached a shared repository as burned. Make it your policy to revoke it and rotate it. Rotate the key, invalidate the token, reset the password. That is the only thing that will actually close that open door for the attacker.

Quick check on your website

If you serve a website on the public internet, it's worth a quick check: GET /.git/config. This simple check may save you many hours of pain in the future.

If this returns 200 you are in a bad spot and I would act quickly and trigger urgent incident response following your organization's secret leakage playbook. That usually involves:

  1. Evidence collection — immediately snapshot the server's memory and data to safe storage.
  2. Containment — stop serving the folder.
  3. Recovery — rotate all secrets in there, assume everything was leaked.
  4. Root cause analysis — check for lateral movement, and how it happened.
  5. Lessons learned — talk with your team and implement policies and procedures to prevent this from happening again.

If you don't have an incident response playbook, you should make creating one a priority. When the day comes, the worst thing you can do is spend all your time thinking about what you should do instead of just following an established process.

Continuous monitoring

A commit moving down a build pipeline into a scanning gate labelled gitleaks: the gate blocks a commit carrying a key and stamps the build failed, while a clean commit passes through.

The attacker's one advantage is speed, so scan before they do. gitleaks reads a repository's history and its diffs for anything shaped like a credential.

Run it as:

  1. A pre-commit hook — the secret is stopped on the developer's laptop.
  2. A CI/CD gate — on every push and pull request. This will catch any secrets that slipped through to the git remote.
  3. A cron job — run it periodically across all your repos (public repos are a priority).

By implementing this as a process, you will have a higher chance of avoiding a leak.


Many of the exposed secrets we find on an assessment were "removed" long ago — deleted in a commit and trusted to be gone.

When was the last time you scanned your repos for leaked secrets?

Partner with Panke to improve your Cyber posture

References

  1. The State of Secrets Sprawl 2026 — GitGuardian
  2. git-dumper: dump a git repository from a website — arthaud
  3. Gitleaks: find secrets with Gitleaks — Gitleaks
  4. Removing sensitive data from a repository — GitHub Docs
Concerned about your attack surface?

If you'd like to know how your infrastructure scores in an attacker's scanning model, reach out at contact@pankeit.com for an external attack surface assessment.

Subscribe to our blog

Stay up to date with the latest security trends

No spam. Unsubscribe anytime.

HomeAboutPrivacyDMCA

©2026 Panke IT Solutions LLC

Austin, TX