I ran trufflehog against my GitHub Org. I discovered some secrets.
I then followed the steps below to cleanup my history
-
Installed bfg repo cleaner and trufflehog
-
Performed git clone --bare git@github.com:MyOrg/MyRepo.git
-
Created a file named sensitive.txt with one line, containing a password that had been leaked into GitHub.
-
Executed bfg --replace-text sensitive.txt
-
Run git reflog expire --expire=now --all && git gc --prune=now --aggressive from within the bare repo's folder
-
Run git push --force --all
Now comes the interesting part.
The secret is still available in GitHub when I visit
https://github.com/MyOrg/MyRepo/blob/<commit-sha-where-the-sensitive-data-was-added>/folder1/folder2/filename.php#L13
This is more or less expected since github states that:
those commits may still be accessible elsewhere:
-
In any clones or forks of your repository
-
Directly via their SHA-1 hashes in cached views on GitHub
-
Through any pull requests that reference them
So running
trufflehog github --only-verified git@github.com:MyOrg/MyRepo.git
still finds that commit and the secret.
What I don't understand is why
trufflehog git --only-verified git@github.com:MyOrg/MyRepo.git
i.e. the git scanner still finds the secret, while at the same time trying to checkout the specific commit results in an error
git checkout <commit-sha-where-the-sensitive-data-was-added>
error: pathspec '<commit-sha-where-the-sensitive-data-was-added>' did not match any file(s) known to git
I ran
trufflehogagainst my GitHub Org. I discovered some secrets.I then followed the steps below to cleanup my history
Installed
bfgrepo cleaner andtrufflehogPerformed
git clone --bare git@github.com:MyOrg/MyRepo.gitCreated a file named
sensitive.txtwith one line, containing a password that had been leaked into GitHub.Executed
bfg --replace-text sensitive.txtRun
git reflog expire --expire=now --all && git gc --prune=now --aggressivefrom within the bare repo's folderRun
git push --force --allNow comes the interesting part.
The secret is still available in GitHub when I visit
This is more or less expected since github states that:
So running
still finds that commit and the secret.
What I don't understand is why
i.e. the
gitscanner still finds the secret, while at the same time trying to checkout the specific commit results in an error