NGINX
TMA-NGINX-4.1.3
Ensure private key permissions are restricted
Mô tả
The server's and potentially its vhost's private keys should be protected from unauthorized access by limiting access based on the principle of least privilege. Every ssl_certificate_key and every *.key file under /etc/nginx must have mode 400 or stricter (relative paths are resolved against /etc/nginx; variables and engine: keys are skipped). 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.
Cách kiểm tra
Phương pháp kiểm tra: Lệnh shell
out=$(nginx -T 2>/dev/null) || exit 1; { printf '%s\n' "$out" | awk '$1=="ssl_certificate_key"{v=$2; sub(/;$/,"",v); gsub(/["\047]/,"",v); print v}'; find /etc/nginx -name '*.key' 2>/dev/null; } | sort -u | { bad=0; while IFS= read -r k; do case "$k" in data:*|engine:*|store:*|*'$'*) continue;; /*) ;; *) k=/etc/nginx/$k;; esac; [ -e "$k" ] || continue; [ -z "$(find -L "$k" -perm /377)" ] || bad=1; done; [ "$bad" = 0 ] && echo compliant || echo noncompliant; }- Đầu ra mong đợi
compliant
Cách khắc phục
Phương pháp khắc phục: Hướng dẫn hoặc bản vá hạ tầng
find /etc/nginx/ -name '*.key' -exec chmod u-wx,go-rwx {} + (and the same for keys stored elsewhere).
Thuộc tính
- Hệ điều hành
- Bất kỳ
- Thẻ
- nginxtlspermissions
- Tham chiếu
- CIS NGINX Benchmark v3.0.0 - 4.1.3 Ensure private key permissions are restricted
Kiểm tra máy này
Chạy lệnh này trên máy bạn được phép kiểm tra. Lần quét chỉ ở chế độ đọc.
tmaegis scan --target nginx