NGINX
TMA-NGINX-4.1.7
Ensure Online Certificate Status Protocol (OCSP) stapling is enabled
Description
OCSP stapling allows a server to efficiently deliver certificate revocation information to the client, improving performance and privacy. The server caches the OCSP response from the Certificate Authority (CA), eliminating the need for the client to make a separate connection. All four directives must be present: ssl_stapling on, ssl_stapling_verify on, ssl_trusted_certificate and resolver. 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.
How it is checked
Audit method: Shell command
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=="ssl_stapling" && a(2)=="on"{s=1} $1=="ssl_stapling_verify" && a(2)=="on"{v=1} $1=="ssl_trusted_certificate"{t=1} $1=="resolver"{r=1} {o=gsub(/\{/,"{"); c=gsub(/\}/,"}"); while(o-->0){sp++; b=$1; sub(/\{.*/,"",b); st[sp]=b} while(c-->0 && sp>0) sp--} END{print (s&&v&&t&&r)?"compliant":"noncompliant"}'- Expected output
compliant
How it is fixed
Fix method: Guidance or infrastructure patch
Add 'ssl_stapling on; ssl_stapling_verify on; ssl_trusted_certificate /etc/nginx/ssl/chain.pem; resolver <dns ip>;' to the HTTPS server blocks. Then run nginx -t and reload nginx.
Properties
- Operating systems
- Any
- Tags
- nginxtls
- Reference
- CIS NGINX Benchmark v3.0.0 - 4.1.7 Ensure Online Certificate Status Protocol (OCSP) stapling is enabled
Check this host
Run this on a machine you are allowed to audit. The scan is read-only.
tmaegis scan --target nginx