Skip to content
Leaked secrets Write-up Beginner

A Simple Git Misstep That Could Open Doors For Hackers

The article explains that secrets committed to a Git repository remain recoverable from history even after deletion, and that commit messages mentioning terms like 'key' or 'env' can hint at where such files existed. An attacker with access to the repository could use Git commands to find deleted sensitive files and view their contents.

Thinley Jigme Follow

Published on systemweakness.com

Hi folks! 👋 Welcome to my second article, where we delve into a seemingly minor but potentially catastrophic oversight that developers might unknowingly commit.

Thinley Jigme, on systemweakness.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely, sensitive files were committed to the repository and only removed in a later commit, leaving their contents in Git history, while commit messages hinted at the sensitive file names.

Impact

An attacker with access to the repository could recover secrets that were deleted from the working tree, potentially gaining access to systems those secrets protect.

What the attacker needed

Access to the Git repository; secrets were committed at some point

The fix

Sensitive files should never be committed, and if they are, the secret should be rotated and the history rewritten or the repository treated as compromised.

How it was found

  1. Search commit messages for sensitive keywords such as key or env.
  2. Filter the history for deleted files and look for sensitive file names.
  3. Find the commit hash where the sensitive file was deleted.
  4. Use git show with that commit hash to view the file contents before deletion.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

When developers save changes in Git, every version is kept in a history, like an undo trail that never fully erases old versions. If someone accidentally saves a file with passwords or keys and later deletes it, the old version is still in that history. Anyone who can see the repository can look through the history and recover the secret.

What is Leaked secrets?

Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.

Similar reports

View all

Same bug class and techniques, clearest first.

Leaked secrets and credentials

The lesson behind this report.

Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.