Menu

1 / 2

Secret Leaks in Git: Set Up gitleaks, Key Rotation, and History Rewriting

DEV Community: devsecops·Florient DOGBE·12 days ago
#FvgovrCa
#devtodevsecops#devto#dev#gitleaks#commit
Long article (2312 words) — no AI summary yet.
Reading 0:00
15s threshold

A developer commits a .env file "just for a quick test". The commit gets amended, the file is deleted in the next commit, and everyone moves on. Six weeks later, the AWS access key inside that blob is still perfectly readable in git log -p , and it has already been indexed by three bots scanning public GitHub pushes.

This article walks through both halves of the problem: blocking future leaks with gitleaks in pre-commit and CI, and cleaning up a repository that is already compromised — revocation, rotation, and history rewriting with git filter-repo . No prior security tooling experience is assumed.

Why a leaked secret in Git is worse than it looks

Git is an append-only object database. Deleting a file in a new commit does not delete the blob; it just stops referencing it from the tip of the branch.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.