A secret removed from HEAD still lives in every earlier commit, reflog, fork, clone, cache and (on GitHub) the public event archive, so deletion is never remediation; only revocation is.
How it works
Git is append-only: a commit that removes a secret adds a new object, it does not erase the old one. Copies survive in:
every prior commit on every branch and tag;
local reflogs and unpruned objects;
forks, collaborator clones, CI runner caches, backups, email notifications;
GitHub “oops commits” — force-pushed/deleted commits remain retrievable, and GH Archive records them as zero-commit PushEvents;
build artifacts made from the working tree rather than the index: a .gitignored settings.local.json still lands in Docker images (613 secrets, 99 valid, reached Docker Hub that way; one valid Cloudflare token appeared in 559 tags).
AI coding agents reproduce the human anti-pattern at scale: told to “remove the credential”, they commit a fix to HEAD and stop. A GitHub search for commit messages such as “redact exposed client secret” / “remove credentials from documentation” returned ~124,000 hits, many with timing signatures of agent-driven commits.
Techniques (finding it)
# working tree incl. uncommitted, then full history (gitleaks >= 8.19 syntax)gitleaks dir . --redact -vgitleaks git . --log-opts="--all" --redact -v --report-path gitleaks-report.json# verified-only history scantrufflehog git file://. --results=verified# hunt by variable name, not by pasting a live valuegit log -p --all -S 'AWS_SECRET_ACCESS_KEY'
Truffle Security’s Force Push Scanner mines GH Archive for dangling commits in an org/user; Sharon Brizinov’s scan of all oops commits since 2020 earned ~$25k in bounties, including an admin PAT over the Istio repos.
Mass history scans: 7.25M Gitee repos yielded 26,400 live credentials (Alibaba Cloud AccessKeys 9,473; YouTube 3,805; DeepSeek 3,170; OpenAI 1,348), ~3.64 per 1,000 repos; nearly half (~12,242) dated from 2025.
GitHub secret scanning covers all branches and full history by default once enabled.
Coordinate the force-push, have every collaborator re-clone, and rotate again if the old value could still have been live during the rewrite. Rewrites break PRs, and forks keep the old objects.
Prevent recurrence with pre-commit hooks and push protection (Secret Scanning).
Belief
Reality
Delete the file and push
Value remains in prior commits
git filter-branch/BFG purge
Forks, clones, caches, GH Archive retain it
Force-push over it
GitHub keeps the dangling commit; it is scannable
Repo is private
32.2% of internal repos hold a hardcoded secret vs 5.6% public; access changes, clones persist
Notable cases
CISA “Private-CISA” (2025–26) — contractor used a public repo to sync files between work and home machines; AWS GovCloud admin keys and a plaintext password CSV, with GitHub’s secret blocking deliberately disabled. Keys stayed valid ~48h after the repo came down.
tj-actions/changed-files (CVE-2025-30066) — secrets printed into workflow logs; CISA’s guidance was rotate, because values may appear even in obfuscated form. See tj-actions changed-files Compromise.
Rust Miri cache — Miri stored all env vars under target/; with GitHub Actions caching target/, secrets persisted into a cache readable by PRs (fixed to keep only CARGO_* and OUT_DIR).