Skip to main content
SiteScan.top

.env, .git and backup.zip: the files a deploy should never publish

Configuration with passwords, the whole repository, a database dump left in the web root. Why these files leak, how bots find them within hours, and how to close them off for good.

Security · Published: 3 November 2026 · 5 min read · Дмитрий Орлов

Some of the worst website breaches start with no exploit at all. Someone requests https://example.com/.env, the server hands over a text file with the database password and the payment provider's API key, and that is the whole attack. Automated scanners request these addresses on every domain they come across, so a file like this is usually found within hours of going live — long before anyone on the team notices it.

How the files get there

Almost always the same way: the site is deployed by copying a working folder to the server. Everything in that folder travels along — the hidden directories, the local configuration, the archive somebody made "just in case" before a risky change. A second route is the web server itself: a folder without an index file, served by Apache with Options +Indexes or nginx with autoindex on, becomes a browsable list of everything inside it.

The usual suspects

If one of them was public

Removing the file is not enough. Assume that whatever it contained has already been copied: rotate the database password, regenerate application keys, revoke and reissue every API token, and check the provider dashboards for activity you do not recognise. For an exposed .git, go through the history for secrets as well, not only the current files.

Closing it off for good

Deploy a build, not a working folder. The cleanest fix is a pipeline that uploads only what the site needs to run. Then there is nothing to forget.

Deny hidden paths at the server. On nginx:

``nginx location ~ /\.(?!well-known) { deny all; } ``

On Apache, in the configuration or .htaccess:

``apache RedirectMatch 404 /\.(?!well-known) Options -Indexes ``

The (?!well-known) part matters: /.well-known/ holds files that must stay public, such as security.txt and the ACME challenges used to issue certificates.

Keep backups and dumps outside the web root, and delete diagnostic pages once you are done with them.

Do not publish source maps unless you mean to. In Vite and webpack they are a build setting; if you need them for error tracking, upload them to that service instead of shipping them next to the bundles.

The headers that limit damage when something does slip through are covered in security headers; the wider server review in the technical audit guide.

What SiteScan checks

Every scan asks your site for the paths above and reads the answers. A status code alone proves nothing — many sites answer 200 to every address — so a file counts as exposed only when its content matches: the [core] section of a git config, the variable names of a .env, the header of a SQL dump, the magic bytes of a zip archive. Only the first few kilobytes are read. The findings appear in the "Exposure" group of the site checks, each linked to an explanation: exposed files, directory listing, source maps and WordPress endpoints. Run a free scan to check your domain.

Read next

Check how much of this is on your own site

A free scan surfaces broken links, JS errors and performance problems in about a minute.