Is your .env file or .git folder public?
A .env file holds a website's passwords and keys, and a .git folder holds its full source code history. Neither should ever be reachable from a browser. If typing yourwebsite.com/.env or yourwebsite.com/.git/HEAD shows a file instead of an error, anyone can download them, and you should block access and change every password and key the same day.
What the Shield scan checks
Exposed secret files, shown beside your score. It is not part of the 100 points. Shield requests /.git/HEAD and /.env on the hostname you entered, over HTTPS, without following redirects. A file is reported only when the response is HTTP 200 and the content has the shape of the real file. Shield does not keep or show the contents.
If the check finds a problem, the scan tells you: Anyone can download: your settings file (.env), which usually holds passwords and keys. Block it today and change every password and key it contains.
What these files are
- .env is a plain text settings file. It typically holds the database password, payment and email service keys, and the secret used to sign logins.
- .git is the folder where the Git version-control tool keeps every past version of a project. With it, a stranger can rebuild your full source code, including anything that was ever committed and later removed.
How to check your own website
In a browser, open these two addresses, replacing the name with your own:
https://yourwebsite.com/.env
https://yourwebsite.com/.git/HEAD
You want an error page for both. If either one shows text such as DB_PASSWORD= or ref: refs/heads/main, it is public.
How to fix it
- Block every address that starts with a dot, except the
/.well-known/folder, in your web server or hosting settings. - Move the .env file out of the folder your web server serves, or use your host's own settings screen for secrets instead of a file.
- Do not upload the .git folder. Deploy only the built website.
- Replace every password, key and token that was in the exposed files.
- Run the scan again to confirm both addresses are closed.
Check your website for exposed files now
Type your website address to run the free scan. It checks this and the other 10 items. No account, no email.
The interactive scan needs JavaScript. See the checks you can run yourself.
Questions
How do these files end up public?
Usually the whole project folder is uploaded to the web server, including files that were only meant for the developer's computer. The server then serves anything in that folder, dot files included, unless it is told not to.
I blocked the file. Do I still need to change my passwords?
Yes. You cannot know who downloaded it while it was public. Treat every password, key and token in the file as stolen and replace each one.
Is it enough to delete the .git folder from the server?
It closes the hole going forward. If the history ever contained passwords or keys, those are still compromised and must be replaced.
Does a 403 or 404 on these addresses mean I am safe?
It means those two addresses are not being served, which is what you want. Shield checks only these two files; other leftover files, such as backups, need their own check.
Sources
- OWASP Web Security Testing Guide: Review Old Backup and Unreferenced Files for Sensitive Information
- OWASP Top 10: A05 Security Misconfiguration
- OWASP: Secrets Management Cheat Sheet
Written by Apex Flow Labs LLC for Apex Flow Shield. A score of 100 means the responses Shield received passed all 11 of its checks. It does not prove each setting is configured well, and no scan can show that a website cannot be attacked.