Post

Git Forensics CTF – Recovering Secrets from Git History

A Git forensics challenge demonstrating how sensitive credentials committed to a repository can be recovered from commit history using Git investigation techniques.

Git Forensics CTF – Recovering Secrets from Git History

Git Forensics CTF Writeup

Objective

Identify a hidden flag inside a Git repository by analyzing commit history.

Tools Used

  • Git
  • Linux Terminal
  • Basic Git Forensics Techniques

Challenge Source

This challenge was provided by Sturtle Security Pvt Ltd as part of a Git forensics exercise.


Step 1: Extract the Challenge Files

Step 1

The archive was extracted and the repository inspected. The .git directory confirmed that the project contains version control history.


Step 2: Inspect Commit History

Step 2

Using git log --oneline, I reviewed commit history to identify suspicious commits. One commit referenced a secrets file containing an API key.


Step 3: Inspect the Commit Contents

Step 3

Using git show, I examined the commit contents and discovered a hardcoded key.


Captured Flag


Security Lesson

This challenge demonstrates a common security mistake where developers commit sensitive credentials into Git repositories. Even if removed later, Git history still preserves the data.

Attackers frequently analyze repository history to recover leaked secrets.

Mitigation

  • Never commit secrets into repositories
  • Use environment variables
  • Implement secret scanning tools such as GitLeaks or TruffleHog

Author

Antony Mbugua Githinji
Cybersecurity Enthusiast | Cloud & Network Security | SOC & SIEM

This post is licensed under CC BY 4.0 by the author.