Skip to content
Info disclosure Write-up Beginner

How I found a .env file and can access the whole server of mysql

A website exposed its .git directory, which the author found using a browser extension. Browsing the exposed files revealed a .env file containing MySQL server credentials, which the author did not use because it was out of scope.

jeetpal2007 Follow

Published on medium.com

First we need to install a extension called DotGit

JEETPAL, 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 .git directory and a .env file were deployed to the public web root without being blocked or removed.

Impact

Anyone could read the exposed .env file and obtain the MySQL server username and password, potentially giving access to the whole database server.

What the attacker needed

Target has a publicly reachable .git directory; a .env file is present in the exposed files

The fix

The exposed .git directory and .env file should be removed from the web root and blocked from public access, and the leaked database credentials should be rotated.

How it was found

  1. Install the DotGit browser extension.
  2. Open the target website and watch for the extension flagging an exposed .git directory.
  3. Open the exposed git directory through the extension's pop-up.
  4. Browse the collected files and find the .env file with database credentials.

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.

Some websites keep a hidden folder called .git that holds the project's version history. If that folder is left publicly reachable, anyone can download it and read files that were never meant to be public, such as a .env file that stores passwords and keys. Here that file held the database username and password.

What is Info disclosure?

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

More by jeetpal2007

View all

6 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.