TMAegis베타
nginx 관련 규칙 더 보기

NGINX

TMA-NGINX-2.4.2

Ensure requests for unknown host names are rejected

보통레벨 1자동nginx

설명

NGINX routes incoming requests to the appropriate virtual host by matching the Host header (HTTP/1.1) or :authority pseudo-header (HTTP/2, HTTP/3) against the server_name directives in your configuration. If no explicit match is found, NGINX falls back to the first defined server block or the one marked as default_server. Compliant when at least one server block has a listen ... default_server and every such block returns a 4xx/444 code or sets ssl_reject_handshake on. 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}' | awk 'function a(i,  x){x=$i; sub(/;$/,"",x); gsub(/["\047]/,"",x); return x} function inb(n,  i){for(i=1;i<=sp;i++) if(st[i]==n) return 1; return 0} $1=="server" && /\{/ && !ins {ins=1; sd=sp+1; ds=0; rj=0} ins && $1=="listen" && /default_server/ {ds=1} ins && (($1=="return" && a(2)~/^(4[0-9][0-9])$/) || ($1=="ssl_reject_handshake" && a(2)=="on")) {rj=1}  {o=gsub(/\{/,"{"); c=gsub(/\}/,"}"); while(o-->0){sp++; b=$1; sub(/\{.*/,"",b); st[sp]=b} while(c-->0 && sp>0) sp--} ins && sp<sd {ins=0; if(ds){n++; if(rj) ok++; else bad=1}} END{print (n>0&&ok==n)?"compliant":"noncompliant"}'
예상 출력
compliant

조치 방법

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

Add a catch-all server block, e.g. server { listen 80 default_server; listen 443 ssl default_server; ssl_reject_handshake on; return 444; } Then run nginx -t and reload nginx.

속성

운영 체제
모두
태그
nginxnetwork
참고 자료
CIS NGINX Benchmark v3.0.0 - 2.4.2 Ensure requests for unknown host names are rejected

이 호스트 점검하기

감사 권한이 있는 시스템에서 실행하세요. 스캔은 읽기 전용입니다.

shell
tmaegis scan --target nginx