Skip to content
Info disclosure Write-up Beginner

Git Happens: When .git Folders Revealed the Whole Damn Backend

A publicly reachable .git directory let the author download the application's source code, which contained a .env file with database, mail and JWT secrets. Using those credentials the author logged into an admin panel and retrieved the full user list including password hashes.

medium.com

Published on medium.com

Free Link ๐ŸŽˆ

Iski, on medium.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 publicly, and secrets were committed into the repository's .env file.

Impact

An attacker could read the application source, obtain secrets, log in as admin and extract all user records including password hashes.

What the attacker needed

No account needed; target serves .git publicly

The fix

The .git directory should be blocked at the web server and secrets should be kept out of the repository, with any leaked credentials rotated.

How it was found

  1. Request the .git config file on the target host and see it return 200
  2. Request the .git HEAD file and see it return a branch reference
  3. Dump the repository with git-dumper
  4. List the dumped files and find the .env file
  5. Use the credentials from .env to log in to the admin panel and obtain a JWT
  6. Call the admin users endpoint with the token to retrieve user data

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.

Many websites keep their code in a hidden folder called .git, which is used by the version control tool Git. If the web server serves that folder to anyone, a visitor can download the source code and any secrets stored in it, such as passwords. Here the exposed folder handed over credentials that opened the admin area.

What is Info disclosure?

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

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.