Loading...
Loading...
A `.env` file served by the web server exposes every credential the application uses: database URLs, API keys, signing secrets, cloud credentials, and more.
This is the single highest-severity finding in most WebShield scans because a `.env` almost always contains full-access credentials. Laravel apps commonly expose `.env` when the document root is set to the project root instead of `/public`. Public research in 2025 cataloged hundreds of exposed Laravel `APP_KEY` values in the wild, with the majority sitting alongside at least one additional production credential (S3 keys, Stripe keys, database passwords). A single exposed `.env` is often the entire blast radius of a company compromise.
Rotate before you patch. If the file was reachable for any length of time, assume it was scraped. Scanners index `.env` paths continuously. Rotate every secret in the file, then update the web server config to block dotfiles, then fix the underlying deployment problem (usually: document root pointing at the project root instead of `public/`). Finally, remove the file from git history if it was ever committed.
Attackers scan for a standard list of `.env` variants continuously. Probe every one of them. A `200 OK` with any content is a critical finding - the cleartext value of your API keys is public the moment the URL works once.
for f in .env .env.local .env.production .env.backup .env.old .env.dev .env.staging; do
printf "%-20s %s\n" "$f" "$(curl -s -o /dev/null -w '%{http_code}' https://yourdomain.com/$f)"
donefor f in config.php wp-config.php config.yml secrets.json credentials.json; do
printf "%-20s %s\n" "$f" "$(curl -s -o /dev/null -w '%{http_code}' https://yourdomain.com/$f)"
doneYes. Automated scanners index `.env` paths 24/7 - the probability of capture during a multi-minute window is effectively 100%. Rotate every credential in the file, in the order listed in the rotation checklist.
Yes. All three publish only the build output directory, so a `.env` at repo root is never served. But if you commit `.env` to git, the next developer who sets up a different hosting environment inherits the problem. Never commit it.
Safe to commit and safe to serve. It should contain variable names with dummy values, no real secrets. Make that distinction explicit in your README so contributors do not accidentally commit the real file.
Applied the configuration change? Run a live scan to confirm the vulnerability is patched.