# .env file exposure
*Exposure*
Make sure .env and other secret files cannot be downloaded from the public site.

## Why it matters
A downloadable .env file can hand over database passwords, API keys, and signing secrets in one request.
This is one of the fastest ways for an automated scanner to take over a service. It is worth checking even if you think it is hidden.

## How to fix it
1. Request /.env and confirm it returns 404
2. Keep secrets in the hosting environment, not in files under the web root
3. Rotate any secret that was ever reachable

## Prompt for an AI assistant
Copy the text below and paste it into an AI assistant.
```text
You are the person improving this website. Check the item below and fix it if it applies to the site.

Item: .env file exposure
Summary: Make sure .env and other secret files cannot be downloaded from the public site.
Steps:
1. Request /.env and confirm it returns 404
2. Keep secrets in the hosting environment, not in files under the web root
3. Rotate any secret that was ever reachable
References:
- Secrets Management (OWASP) (https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html)

Constraints:
- Keep the existing design and tone of voice.
- Show the file or section you changed and the suggested final wording.
- Do not decide ambiguous points alone; give options and a recommendation.
- Do not change anything outside the listed item.
```

## Checked by
- **[vuln](https://ismyappok.com/en/vuln/checks)** — Public exposure checks

## Related checks
- **[.git exposure](https://ismyappok.com/en/checks/git-config-exposure)** — Block access to /.git/ so the repository history is not downloadable.
- **[Secrets in client JavaScript](https://ismyappok.com/en/checks/client-secrets)** — Keep API keys and tokens out of the JavaScript that browsers download.

## References
- **[Secrets Management (OWASP)](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html)** — OWASP cheat sheet（Reference）

## Check your site now
Enter a URL and find what is missing before launch, for free.
[Run audit](https://ismyappok.com/en/audit/check)