Home / patterns

Exposed .env or .git on a deployed site

Quick answer: If your hosting or build setup copies everything in your project folder to the live site, anyone may be able to download /.env (your API keys, database URL and other secrets) or /.git/config and the rest of the .git folder (your code and its history). Request both paths on your own domain: each should return 404. If either loads, remove it from the deployed files and treat every secret in it as leaked.

Last updated November 16, 2026

Steps

  1. Request /.env and /.git/config on your own domain (and any staging or preview domains you own).
  2. Both should return 404 (not found) or 403, never the file’s contents.
  3. If either loads, remove it from the deploy output: deploy only your build folder, and keep .env and .git out of it.
  4. Rotate every secret that was in the exposed file (API keys, database passwords, webhook secrets), not just the ones you think matter.
  5. If .git was exposed, assume your source code and any secrets ever committed to its history are public, and rotate those too.
  6. Re-check both paths after each hosting or build-setting change.

Why it matters

This is a common failure pattern in apps built quickly with AI coding tools. The steps above check your own app only. Never test apps you don't own.

Related patterns

Found a problem you'd rather not fix yourself?

Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.

Get it fixed by StorenTech

Vibe Security Weekly

One email a week with new failure patterns and how to fix them.

By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.