Skip to content
Info disclosure Write-up Beginner

Exposed .git Directory Exploitation

An exposed .git directory on a web server allowed anyone to download the repository metadata and recover source code and hardcoded secrets. An attacker could extract credentials such as AWS access keys from the repository history.

Yani Follow

Published on infosecwriteups.com

Nearly two million .git folders containing vital project information are exposed to the public, the Cybernews research team found. Git is the most popular open-source distributed version control system.

Yani, on infosecwriteups.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 the web server was misconfigured to serve the .git directory, which should never be publicly accessible.

Impact

An attacker could obtain source code and hardcoded secrets such as AWS access keys, potentially leading to further compromise.

What the attacker needed

Exposed .git directory on web server; No authentication required

How it was found

  1. Add .git to the root URL of the target website to check for an exposed repository.
  2. If directory listing is disabled, try accessing specific files like .git/config.
  3. Download the .git folder using a tool such as GitTools' gitdumper.sh.
  4. Run git status to see deleted files, then restore them with git checkout -- .
  5. Use extractor.sh to recover source code from all commits.
  6. Search the recovered files for hardcoded secrets using a tool like gitleaks.

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.

A .git folder is a hidden directory that Git uses to store the history of a project. If a web server serves this folder to anyone, visitors can download it and see old versions of files, including ones that were deleted but still contain passwords or keys. This is like leaving a backup of your diary on the front porch.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More by Yani

View all

4 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.