Gitrob: Mining GitHub's Commit History for Secrets That Developers Thought They Deleted
Hook
Deleting a file from your repository doesn't delete it from Git history—and attackers know this. Thousands of API keys, database passwords, and private certificates remain accessible in commits that developers assumed were erased.
Context
The conventional wisdom about leaked secrets in Git repositories focuses on scanning the current state of the codebase. Run a quick grep for 'password' or 'api_key', check the latest commit, and call it done. But this approach misses the real treasure trove: historical commits where developers accidentally committed credentials, then quickly removed them in a panic. Those secrets remain in the Git history forever unless the repository is force-pushed or rewritten.
Gitrob, created by Michael Henriksen, emerged from the penetration testing and bug bounty communities where researchers needed to automate the tedious process of manually reviewing commit histories across dozens or hundreds of repositories. Traditional approaches required cloning each repository individually, running git log commands, and manually reviewing changes. For organizations with large GitHub footprints—think companies with 50+ repositories and teams of 100+ developers—this manual process became impossible. Gitrob transformed this reconnaissance work from a days-long manual effort into an automated scan that could run overnight, complete with a web interface for triaging findings.
Technical Insight
Gitrob's architecture demonstrates thoughtful use of Go's concurrency primitives to handle the inherently I/O-bound task of cloning repositories and scanning commit histories. At its core, the tool maintains a worker pool of goroutines that process repositories in parallel while respecting GitHub's API rate limits. The scanning workflow follows three distinct phases: enumeration, cloning, and analysis.
During enumeration, Gitrob uses the GitHub API to discover repositories belonging to the target organization or user. If you specify an organization, it automatically enumerates all members and their repositories—a crucial feature for comprehensive reconnaissance. The tool then queues these repositories for processing by worker goroutines.
The cloning phase is where Gitrob's concurrent architecture shines. Here's how you'd configure and launch a scan:
// Example usage pattern
gitrob -threads 10 -commit-depth 500 -save session.json target-org
// What happens internally:
// 1. Create a worker pool with 10 goroutines
// 2. Each goroutine clones a repository to a temp directory
// 3. For each repo, iterate through last 500 commits
// 4. Apply pattern signatures to changed files
// 5. Store findings in shared results structure
The pattern-matching engine applies a collection of signatures to identify sensitive files. These signatures include regex patterns for common credential files, AWS keys, private keys, and configuration files. For example, Gitrob flags files matching patterns like .*_rsa$, .env, credentials.xml, or files containing strings like BEGIN RSA PRIVATE KEY. Each signature has a severity score that helps prioritize findings during triage.
What makes Gitrob particularly effective is its commit depth parameter. By default, it scans the last 500 commits of each repository—deep enough to catch secrets from months or years ago, but shallow enough to avoid scanning ancient history that's less likely to contain valid credentials. You can adjust this based on your needs:
# Shallow scan for quick reconnaissance
gitrob -commit-depth 100 target-org
# Deep historical analysis
gitrob -commit-depth 2000 target-org
The findings are stored in a session file as JSON, enabling several powerful workflows. You can pause a scan, share findings with teammates, or parse the JSON for custom reporting. The session structure looks like this:
{
"findings": [
{
"file_path": "config/database.yml",
"commit_id": "a1b2c3d4e5f6",
"repository": "target-org/api-server",
"severity": "high",
"matched_pattern": "database.yml"
}
]
}
The built-in web server presents these findings through an interactive interface where you can filter by severity, repository, or file type. This UI design choice recognizes that secret scanning generates significant noise—false positives are inevitable when using pattern matching. The web interface allows security researchers to quickly mark findings as reviewed, add notes, and focus on high-severity items.
One clever architectural decision is Gitrob's handling of temporary repository clones. Rather than keeping all cloned repositories on disk (which could consume gigabytes for large organizations), it clones to temporary directories, scans them, extracts findings, and immediately deletes the clone. This keeps disk usage minimal while still enabling deep commit analysis. The tool only needs to store the relatively small JSON findings, not entire repository histories.
Gotcha
Gitrob's biggest limitation stems from its reliance on GitHub's API and public repository access. Without authentication, you'll hit GitHub's rate limits quickly—typically 60 requests per hour. Even with authentication (5,000 requests per hour), scanning a large organization with hundreds of repositories and thousands of commits can take hours or hit quota limits. There's no built-in rate limiting backoff, so you may need to manually restart scans if you hit these limits.
The pattern-matching approach, while fast, generates substantial false positives. A file named test_credentials.rb might be flagged even if it only contains mock data for unit tests. Files like .env.example or config.sample.yml will trigger alerts despite being intentionally committed as templates. You'll spend significant time triaging findings, especially on first scan of a large organization. The signature system also isn't easily extensible—adding custom patterns requires modifying the source code rather than providing them via configuration file. For organizations with domain-specific secret patterns (custom API key formats, proprietary credential structures), you'll need to fork and modify Gitrob rather than simply configuring it.
Verdict
Use if: You're conducting security assessments or bug bounties against organizations with significant GitHub presence, need to audit historical commits for leaked credentials across many repositories, or want an automated way to enumerate an organization's public GitHub attack surface. Gitrob excels when you need both broad organizational coverage and deep historical analysis, particularly during time-boxed engagements where setting up multiple tools isn't practical. Skip if: You need real-time monitoring of commits (Gitrob is a point-in-time scanner), require multi-platform support for GitLab or Bitbucket, work primarily with private repositories where API access is restricted, or need high-accuracy scanning with minimal false positives. Development teams building preventive controls should look at CI/CD-integrated tools like gitleaks instead, while enterprises needing continuous monitoring should evaluate commercial solutions like GitGuardian that offer better accuracy and real-time detection.