NGINX
TMA-NGINX-2.5.3
Ensure hidden file serving is disabled
中レベル 1自動nginx
説明
Hidden files and directories (starting with a dot, e.g., .git, .env) often contain sensitive metadata, version control history, or environment configurations. Serving these files should be globally disabled. Looks for a regex location matching paths that start with a dot (e.g. location ~ /\. { deny all; }). Evaluated on the merged configuration printed by `nginx -T` (all included files; needs permission to read them). CIS marks this recommendation Manual; the automated check implements its audit procedure.
チェック方法
監査方法: シェルコマンド
shell
out=$(nginx -T 2>/dev/null) || exit 1; printf '%s\n' "$out" | awk '{l=$0; o=""; q=""; for(i=1;i<=length(l);i++){c=substr(l,i,1); if(q!=""){o=o c; if(c==q) q=""; continue} if(c=="\""||c=="\047"){q=c; o=o c; continue} if(c=="#") break; if(c==";"||c=="{"){print o c; o=""; continue} if(c=="}"){if(o~/[^[:space:]]/) print o; print "}"; o=""; continue} o=o c} if(o~/[^[:space:]]/) print o}' | grep -Eq '^[[:space:]]*location[[:space:]]+~\*?[[:space:]]+["^]*/\\\.' && echo compliant || echo noncompliant- 期待される出力
compliant
修正方法
修正方法: ガイダンスまたは IaC パッチ
Add 'location ~ /\. { deny all; return 404; }' to each server block (allow /.well-known/ first if needed). Then run nginx -t and reload nginx.
プロパティ
- オペレーティングシステム
- すべて
- タグ
- nginxinformation-disclosure
- 参照
- CIS NGINX Benchmark v3.0.0 - 2.5.3 Ensure hidden file serving is disabled
このホストをチェック
監査が許可されているマシンで実行してください。スキャンは読み取り専用です。
shell
tmaegis scan --target nginx