← PHP / Laravel · 目录

PHP-012 / 入门

Web 根目录中的 .env 文件可访问

A05:2021 Security Misconfiguration · CWE-538 Insertion of Sensitive Information into Externally-Accessible File

为什么存在问题?

数据库口令和 API 密钥通过 HTTP 泄露。

如何修复

nginx
root /var/www/app/public;   # 仅公开 public,.env 位于上级目录
location ~ /\.(?!well-known) { deny all; }

延伸阅读