Sensitive Files Exposure
Common sensitive files like .env, .git, backups, and config files should not be publicly accessible.
Results in 1–3 minutes · Free · No signup required
Want the result for your own site? Free Website Vulnerability Scanner — paste your domain, get the report.
Why It Matters
These files often contain credentials, API keys, database passwords, and other secrets. Exposure leads directly to system compromise.
How We Check
We probe for common sensitive files and directories including .env, .git, config files, backup archives, and database dumps.
Good vs Bad Values
| Value | Verdict | Why |
|---|---|---|
/.env returns 404 or 403 | Good | The expected answer. A 403 is acceptable; a 404 is better because it does not confirm the file exists. |
/.git/HEAD returns 404 (or an HTML page) | Good | A catch-all that returns index.html with status 200 is not treated as an exposure: the check wants the real content such as ref: refs/heads/main. |
/.env returns 200 with lines such as DB_PASSWORD=… | Bad | Critical. Every credential in the file must be considered stolen and rotated. |
/.git/config returns 200 with [core] and [remote "origin"] | Bad | The repository metadata is public. Tools can usually rebuild the full source and history from /.git/, including old secrets. |
/backup.sql, /dump.sql or /database.sql containing CREATE TABLE | Bad | A whole database in a single request, including user records and password hashes. |
/backup.zip or /site.zip returning a PK archive | Bad | Source code and configuration for the whole site, often forgotten after a migration. |
/phpinfo.php returning a page that contains "PHP Version" | Bad | Reveals paths, loaded modules, environment variables and sometimes secrets passed to PHP. |
/package-lock.json, /composer.lock or /.DS_Store served | Weak | Lower severity, but the lock files list exact dependency versions and .DS_Store lists file names in the folder. Both save an attacker time. |
How to Fix
Configure your web server to block access to sensitive files. Use .htaccess rules or nginx location blocks. Move sensitive files outside the web root.
Nginx — deny every dotfile except the ACME and security.txt directory, and common backup extensions:
location ~ /\.(?!well-known) {
return 404;
}
location ~* \.(sql|bak|old|orig|swp|log|zip|tar|tar\.gz|sqlite|sqlite3|db)$ {
return 404;
}
location ~* ^/(composer\.(json|lock)|package(-lock)?\.json|phpinfo\.php|info\.php)$ {
return 404;
}
Apache — in the vhost or .htaccess:
RedirectMatch 404 "/\.(?!well-known)"
<FilesMatch "\.(sql|bak|old|orig|swp|log|zip|tar|gz|sqlite3?|db)$">
Require all denied
</FilesMatch>
<FilesMatch "^(composer\.(json|lock)|package(-lock)?\.json|phpinfo\.php|info\.php)$">
Require all denied
</FilesMatch>
Stop shipping them. Deploy a build artifact, not a checkout. With rsync, exclude the hidden and local files:
rsync -a --delete --exclude='.git' --exclude='.env*' --exclude='*.sql' --exclude='*.bak' ./dist/ deploy@host:/var/www/site/
In Docker, list them in .dockerignore so they never enter the image: .git, .env*, *.sql, *.log. In Next.js or any static-folder framework, keep secrets in environment variables and never in public/.
If a file was exposed: rotate every credential in it first, then remove the file, then search the access log for earlier requests to that path.
Verify every high-risk path from the outside:
for p in .env .git/config .git/HEAD backup.sql backup.zip phpinfo.php .DS_Store; do
printf '%s ' "$p"; curl -s -o /dev/null -w '%{http_code}\n' "https://example.com/$p"
done
Common Mistakes
- Deploying by running git pull inside the web root. The .git directory then sits next to index.html and is served by default.
- Blocking .env in one virtual host but not another. Check every vhost, subdomain and the default catch-all server.
- Denying only the file you know about. A backup made by an editor or a person (config.php~, wp-config.php.bak, site-old.zip) has a name nobody thought to add to the deny list.
- Placing files in the static directory of a framework. Anything under public/ in Next.js, or the static folder in Express, is served exactly as it is.
- Fixing the file but not the credentials. Once /.env was reachable it may have been fetched, so rotate the keys and check the logs for the first request.
- Hiding a file with a deny rule while the same content is reachable through a second path, such as a CDN origin or an object storage bucket.
Frequently Asked Questions
What is Sensitive Files Exposure?
Common sensitive files like .env, .git, backups, and config files should not be publicly accessible.
Why does Sensitive Files Exposure matter for website security?
These files often contain credentials, API keys, database passwords, and other secrets. Exposure leads directly to system compromise.
How do I fix Sensitive Files Exposure issues?
Configure your web server to block access to sensitive files. Use .htaccess rules or nginx location blocks. Move sensitive files outside the web root.
Related Security Checks
Related Tool
Website Vulnerability Scanner
Run all 7 related checks with our free website vulnerability scanner
Check Your Website Now
Run a free security scan to check for Sensitive Files Exposure issues and 61 other security checks.
Scan Your Website Free