**Exploiting an Exposed .git: Gaining Access to Source Code and Database**
A publicly accessible .git folder allowed the entire source code repository to be downloaded, which contained a database backup with hashed credentials for admin and staff accounts. The attacker could then log into the system using those credentials.
Hello everyone, this is my first post on Medium. I want to share a little of my experience when doing Bug Hunting on Web applications.
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, exposing the repository and a database backup with credentials.
Impact
An attacker could obtain source code and credentials, potentially leading to unauthorised access to the system.
What the attacker needed
None
The fix
The .git directory should not be publicly accessible; it should be blocked or removed from the web root.
How it was found
- Access the .git/config file on the target subdomain.
- Use GitDumper to download the .git files.
- Use Extractor to reconstruct the repository.
- Find a database backup file in the source code.
- Analyse the authentication code to determine the hashing method.
- Generate a matching hash and log in with the stored accounts.
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 part of a website's source code management and should never be public. If it is, anyone can download the code and look for secrets like passwords or database backups. Here, the backup contained password hashes, which the attacker could use to log in.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.