Skip to content
Deployment hardening

.env file and .git folder exposed: how to check

Check whether your own server actually returns environment-file or Git-metadata content, not merely a 200 status. If a real private credential is exposed, revoke it before treating a file-removal or routing change as containment.

Check your app free, first fix free
By Brennan ZamboUpdated
In short

A static fallback can return the homepage for a nonexistent dotfile, so inspect response type and content carefully. Keep tests to your own authorized deployment and avoid collecting repository contents. Remove unintended files from the serving directory, block their public routes, rotate real credentials and verify that normal application paths still work.

Do not confuse a soft 404 with a real file

Many single-page applications return the same HTML shell for unknown paths. A request to /.env or /.git/config can therefore return status 200 without exposing either file. A useful check examines the response structure and content, not just the status.

An authentication page, generic error or hosting challenge can also look superficially successful to a simple HTTP client. Record what the response actually establishes. An ambiguous result belongs in the unknown category rather than a dramatic claim that the repository was stolen.

Keep the check narrow

For an app you own, inspect headers before deciding whether a small response-body review is needed. Avoid dumping potentially sensitive contents into a shared terminal transcript.

bash
curl --head --max-time 10 https://your-app.example/.env
curl --head --max-time 10 https://your-app.example/.git/config

These header requests alone cannot prove a file's contents. Use the browser or an appropriately bounded private inspection when needed. Do not enumerate an unrelated site's repository or download customer data to demonstrate a finding.

Fix the serving directory, not just one path

If the server is serving the repository root, change the deployment to serve only the intended build output or application routes. Remove accidental environment files and version-control metadata from public artifacts. Review host and web-server rules for dotfiles and ensure they do not block intentionally public paths such as /.well-known where your application needs them.

A path block can help, but it is not a substitute for a clean deployment artifact. Another copy, backup suffix or archived release might still publish the same configuration. Inspect the build pipeline to understand why a private file entered the public output in the first place.

Treat exposed credentials as a separate incident

If an environment file contained real provider credentials, revoke or rotate them through their providers and inspect relevant activity. Renaming the file does not invalidate a key already copied by a visitor. A Git metadata leak can also make earlier committed secrets reachable even after the latest source changed.

Coordinate any repository history cleanup. Rewriting history can disrupt collaborators and does not recall forks or downloads. Keep the credential response separate from the file-serving repair so neither is accidentally omitted.

Verify legitimate routing after the repair

Recheck the exact dotfile paths and a normal deep link in the application. A broad deny rule should not accidentally break static assets, framework resources or domain-verification files. Confirm the final custom domain, not only a preview host.

ProofForge checks selected public file paths within its bounded scan. It does not attempt full repository reconstruction, search every backup name or prove that no private file exists anywhere. Report the observed issue and completed checks without enlarging the claim.

Turn the check into a release decision

Keep a small record of the production URL, the time you checked it, the exact finding and the action you took. A local preview and a deployed application can have different environment variables, response headers and database projects. After a repair, deploy the intended version and check the public address again. Do not assume that changing a repository file changed the live system.

Read coverage as carefully as the score. A timed-out asset, an ambiguous backend configuration or a request that could not safely establish access should remain unknown. It should not disappear from your release notes merely because there is no red finding. If a check was not completed, decide who will review it and what additional evidence is needed.

ProofForge's free report includes the first fix. The $9 Fix Report unlocks all findings' available repair guidance and builder prompts, with a PDF and private report link. Fix + Guard costs $29 once and adds builder rules, on-demand deploy-hook scans for 30 days and four weekly rechecks you start yourself. These are different deliverables, not different promises that an application is completely secure.

Keep private report URLs out of public issues and commits. If you need shareable evidence, use the owner-verification and publication flow for an eligible receipt. A signature protects the recorded assessment against undetected changes; it does not make the assessment exhaustive, prove a business outcome, or show that a later deployment still matches an earlier result.

Questions builders ask

Does /.env returning 200 prove a leak?
No. A frontend fallback may return the homepage for unknown paths. Inspect content and distinguish a real environment file from HTML.
Is blocking the URL enough after a real key was exposed?
No. Revoke or rotate the credential and review activity. The URL repair only stops that distribution path.
Does the scanner reconstruct my repository?
No. It checks selected bounded public signals and does not perform a full repository download.

Continue with a related guide

Sources

Read-only, about a minute

Scan your app free

See what your live app ships to every visitor, with the first fix free. A clean scan is not a full audit. Run it only on an app you own or have permission to test.

Scan your app free
All guides