Exposure Small

Take the .env file off the web

A .env file holds the settings a site reads at start-up, usually the database password and every API key. When the web server serves the folder it sits in, anyone can download it at /.env, and automated scanners request that path on every site they find.

Find out whether your site has this problem, and every other check, in one free scan.

Check your site free

Why it matters

A .env file usually holds the database password and every API key the site uses. Anyone who downloads it can log in to the database and spend on every connected account, and bots request /.env on every site they find.

How to fix

  1. 1 Rotate every secret the file held, starting with the database password and payment and cloud keys: assume each one has been copied.
  2. 2 Move the .env file out of the directory the web server serves, or deny every path starting with a dot in the server config (nginx: location ~ /\. { deny all; }).
  3. 3 Purge the file from git history if it was ever committed, then confirm /.env no longer returns it.

Common mistakes

  • Deleting the file from the server but not rotating the keys and passwords it held, which may already have been copied.
  • Blocking /.env only, while /.env.production, /.env.local or a backup copy is still served.
  • Hiding it with a rule in an .htaccess file on a server that runs nginx, which ignores .htaccess.

How to verify

  1. 1 Open https://your-site/.env in a private window and confirm you get a 404 or 403, not the file.
  2. 2 Re-run the scan and confirm the public .env finding is gone.
  3. 3 Confirm the database password and each API key in the old file have been changed at their providers.

Related checks

Ready to see where you stand?

Scan your site and get your Engineering Score with a prioritized roadmap in under a minute, no signup required.

Scan your site

Session expired

Your session has expired for security. Please log in again to continue.