Home › Security notes › A public .env file or .git folder on a live site
Weekly security note
A public .env file or .git folder on a live site
What it is
Some deploys copy the whole project folder to the web server, including hidden files. That can make a .env file (with secrets) or the .git folder (with your full source history) downloadable from your live domain.
Why it's risky
Anyone who requests yoursite.com/.env may get your database passwords and API keys. With a public .git folder, tools can rebuild your source code and history, including secrets committed in the past.
How to check
- Visit https://yoursite.com/.env and https://yoursite.com/.git/HEAD in a private window. Both should return 404 or 403, not file contents.
- Check that your build output folder (dist, build, public) contains no dotfiles.
- Or use curl as below.
Example
# Example: both should return 403 or 404
curl -s -o /dev/null -w "%{http_code}\n" https://yoursite.com/.env
curl -s -o /dev/null -w "%{http_code}\n" https://yoursite.com/.git/HEAD
Or run a free scan. It checks your app's public surface for this and other common exposures.
How to fix it
- Deploy only your build output folder, not the project root.
- Block dotfiles at the web server or host.
Example
# Example: nginx location ~ /\.(?!well-known) { deny all; } - Rotate every secret that was in the exposed .env or anywhere in git history.
- Redeploy and re-check both URLs.
After you fix it
Treat every exposed secret as compromised: rotate it and review provider logs.
Re-run a scan to confirm no dotfiles are served.
To catch it if this comes back, Warditor Monitor re-scans your app every 6 days for $19/month.
FAQ
Is .well-known safe to leave public?
Yes. /.well-known/ is meant to be public (for security.txt, domain verification and similar). The example rule leaves it open.
My .env only had public keys. Is that a problem?
Less so, but review it carefully. Env files often collect secrets over time.
Does a 403 mean I'm fine?
For that URL, yes. Also make sure no backup copies like .env.bak or .env.production are served.
Does Warditor download my source code?
No. The scan checks whether these paths are reachable and records only the finding type.
Scan your app free
Look-only check of what any visitor can already see. No login, no changes to your app.
Scan your app freeNeed help fixing it? See Fix Pack, Monitor and Shield.
More security notes
- Row-level security turned off on a Supabase table
- A secret API key shipped in frontend code
- Firebase security rules left in test mode
This page describes a generic mistake pattern. It is not about any specific app, site or person.