How to fix: Raw .env File Content Served
The response body looks like raw .env file content (APP_DEBUG/APP_KEY/DB_PASSWORD-style KEY=VALUE lines) rather than rendered application output.
Why it matters
A leaked .env file typically contains database credentials, API keys, encryption keys, and session secrets in plaintext, giving an attacker everything needed for full application and data compromise in a single request.
.env files are meant to be read by the server process at startup and never served over HTTP. A response that consists of literal KEY=VALUE lines means either the web root includes the .env file directly, or an endpoint is echoing its contents (e.g. a debug/info route left enabled).
How to fix it
- 1Remove .env from the web-accessible document root immediately and rotate every credential it contained.
- 2Add a web-server rule that denies access to dotfiles (Nginx: 'location ~ /\.'; Apache: '<FilesMatch "^\.">').
- 3Audit for any debug/info endpoint that dumps environment variables and remove it from production.
Code examples
Nginx: deny dotfiles
location ~ /\. {
deny all;
return 404;
}References
Detected automatically by VulnRadar. The check id is dotenv-file-content-leaked, stable across every scan so you can filter or diff on it.
More config checks
- MediumNo Rate-Limit Policy Detected
- MediumVary: Cookie Missing on Cookie-Bearing Response
- LowSet-Cookie Header Exceeds 4 KB
- LowVary Header Missing on Compressed Responses
- InfoDownloadable Content Served as inline
- InfoX-XSS-Protection Header Is Deprecated
- LowServer-Timing Exposes Cache Timings
- LowVary: Cookie on Static Resource
Questions
- How severe is Raw .env File Content Served?
- VulnRadar rates this critical severity in the config category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id dotenv-file-content-leaked, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Raw .env File Content Served map to?
- It maps to CWE-538. In the OWASP Top 10 it falls under A05:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.