Avatar

Labs / Git Exposed

  • Challenge
  • Released 22 Oct 2025

What secrets lie hidden in the commit history?

A corporate website looks ordinary, but beneath its surface lurks a developer's mistake that exposes everything. An exposed .git directory sits on the production server, ready to reveal its secrets to anyone who knows where to look. Dive into version control history, reconstruct deleted files, and uncover sensitive information that should never have made it to production. Can you extract the flag from the depths of Git history?

1
Flags
1
Points
Challenge
Free Access
Start Lab Environment

Launch your dedicated AWS machine to begin hacking

~1-2 min setup
AWS dedicated
Private instance
Industry standard
Challenge

Understanding Exposed Git Repositories

Exposed Git repositories represent a critical security vulnerability where developers accidentally deploy .git directories to production web servers. These directories contain the complete version control history, including source code, commit messages, file changes, and potentially sensitive information like API keys, passwords, and proprietary code.

What is a .git Directory?

Git stores all repository data in a hidden .git directory at the root of every Git-managed project. This directory contains:

  • Object Database: All file contents, commits, and tree structures stored as objects
  • Commit History: Complete chronological record of all changes made to the repository
  • Branches and Tags: References to different development branches and release versions
  • Configuration: Repository settings, remote URLs, and user information
  • Index/Staging Area: Information about files staged for the next commit

Why .git Directories Get Exposed

Several common deployment mistakes lead to exposed .git directories:

  • Direct Repository Deployment: Deploying entire Git repositories instead of building artifacts
  • Improper .gitignore: Not excluding .git from deployment processes
  • FTP/SFTP Uploads: Manually uploading directories without excluding .git
  • Container Misconfigurations: Including .git in Docker images or web directories
  • CI/CD Pipeline Errors: Deployment scripts that don't filter out version control directories

Security Impact

When .git directories are publicly accessible, attackers can:

  • Download Entire Codebase: Reconstruct the complete application source code
  • Analyze Commit History: Review all changes, including deleted sensitive data
  • Discover Credentials: Find API keys, passwords, and tokens in commit history
  • Identify Vulnerabilities: Study source code to find security weaknesses
  • Access Removed Files: Retrieve files that were deleted but remain in Git history
  • Learn Infrastructure Details: Understand deployment processes and system architecture

Common Discovery Techniques

Security professionals and attackers discover exposed .git directories through:

  • Direct Access Testing: Attempting to access /.git/config or /.git/HEAD
  • Automated Scanners: Tools that check for exposed version control directories
  • Directory Enumeration: Testing for common Git files and folder structures
  • Google Dorking: Search queries like 'intitle:index.of .git'
  • Shodan/Censys: Internet-wide scanning for exposed Git repositories

Exploitation Tools and Methods

Once discovered, attackers use specialized tools to download Git repositories:

  • wget/curl: Manual downloading of Git objects and references
  • git-dumper: Python tool that reconstructs repositories from exposed .git directories
  • GitHack: Automated tool for downloading and restoring Git repositories
  • dvcs-ripper: Tool for ripping web-accessible distributed version control systems
  • GitTools: Collection of scripts for finding and downloading exposed Git repositories

Prevention Strategies

Organizations must implement proper controls to prevent .git directory exposure:

  • Web Server Configuration: Block access to .git directories in Apache/Nginx configurations
  • Build Processes: Create deployment artifacts that exclude version control directories
  • Container Best Practices: Use multi-stage Docker builds and .dockerignore files
  • Deployment Scripts: Explicitly exclude .git when copying files to production
  • Security Scanning: Regularly test for exposed version control directories
  • CI/CD Pipelines: Build and deploy only necessary files, not entire repositories

Real-World Examples

Exposed Git repositories have affected major organizations:

  • Fortune 500 companies exposed internal source code and API keys
  • Government websites leaked sensitive authentication credentials
  • Financial institutions disclosed proprietary trading algorithms
  • Technology startups revealed complete application codebases
  • E-commerce platforms exposed payment processing logic

Git History Analysis

Even if sensitive data is removed from current files, it may still exist in Git history:

  • Deleted Credentials: Passwords removed in later commits remain in history
  • Experimental Code: Security vulnerabilities tested and removed still accessible
  • Commented Secrets: API keys commented out but preserved in commits
  • Configuration Files: Production settings accidentally committed and later deleted

Learning Objective: This challenge teaches reconnaissance techniques for discovering exposed Git repositories and analyzing version control history. Understanding this vulnerability helps security professionals identify and protect against source code exposure attacks.

First Blood 🩸
Malekith