Monitory
← All guides

Guides

How to find and close exposed files on your website

The files that should never be public, how to test your own site and how to fix a leaked .env, .git folder or debug tool.

The mistake behind many breaches

One file left publicly readable can hand over your database password. It usually happens quietly: a deploy that copies the whole project folder, a backup saved in the web root, a debug tool left on in production. Attackers do not need skill, only a list of paths to try, and they try them on every site.

What gets exposed

  • Configuration and secrets: /.env, /.htpasswd.
  • Version control: /.git/HEAD and /.git/config, which let someone download your source code.
  • Database dumps: /backup.sql, /dump.sql.
  • Logs and debug tools: /storage/logs/laravel.log, /phpinfo.php, the Symfony profiler, Laravel Telescope and Horizon.
  • Directory listings: /uploads/, /storage/, /backup/.
  • API descriptions: /swagger.json, /openapi.json, and GraphQL introspection.

Check your own site

curl -s -o /dev/null -w "%{http_code}\n" https://example.com/.env
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/.git/HEAD

Anything but a 404 or a 403 deserves a closer look. Ignore a 200 that is only your normal page: some sites answer every path with it.

Fix it

  • .env or .git exposed. Your web server's document root is the project folder instead of its public folder (public/ in Laravel). Point it to the public folder, then change every secret in the exposed file, because you must assume it has been read.
  • Debug tools exposed. Disable Telescope, Horizon and the profiler in production, or protect them with authentication.
  • Directory listings. Turn off auto-indexing (autoindex off; in nginx, Options -Indexes in Apache).
  • GraphQL introspection. Disable it in production.

Keep watching

A file can come back with any deploy. The exposed files check requests these paths once a day and only counts a path when its content matches the file's signature, so sites that answer every path with their normal page are not flagged. It fails when a sensitive file is publicly readable and lists each one in the report.

Keep reading