Skip to content
Info disclosure Write-up Beginner

How a Simple Git Leak Led to AWS Keys & Database Credentials

An exposed .git directory allowed the download of its config file, which contained a Bitbucket access token and private repository URL. Using the token, the researcher cloned the private source code and found AWS keys and database credentials, which could let an attacker access or delete data.

shehzadinfosec1337 Follow

Published on medium.com

Hi everyone, I’m Shehzad Ali, a cybersecurity researcher and penetration tester. This is my second write-up where I’ll share something very interesting that I found during a pentest.

Shehzad Ali, 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, exposing its contents including the config file with credentials.

Impact

An attacker could connect to the databases, steal or delete data, and access AWS S3 keys, potentially leading to further compromise.

What the attacker needed

None

The fix

The .git directory should be blocked from web access using server rules, and any exposed secrets should be revoked and rotated.

How it was found

  1. Detected the .git directory using a browser extension.
  2. Accessed and downloaded files from the .git path.
  3. Opened the .git/config file and found a Bitbucket token and private repo URL.
  4. Cloned the private repository using the token.
  5. Searched the source code for secrets using regex patterns.

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 history and should not be publicly accessible. If it is, anyone can download it and may find passwords or tokens inside. Here, a token let the researcher download private code, which contained more secrets.

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.