TMAegis베타
nginx 관련 규칙 더 보기

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

조치 방법

조치 방식: 가이드 또는 인프라 패치

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