2.3.2 Ensure access to NGINX directories and files is restricted

Information

The NGINX configuration directory ( /etc/nginx or equivalent) and its contents should have restrictive permissions to enforce the principle of least privilege.

- Directories should be accessible only by the root user and the root group (and potentially read/execute by the group), but not by others.
- Files should be readable/writable by root and readable by the group, but inaccessible to others.

Restrictive file permissions prevent unauthorized users on the system from viewing sensitive configuration details, such as backend IP addresses, routing logic, or loaded module paths. By removing \"world\" access (permissions for \"other\"), we ensure that only administrators (via sudo ) can interact with the web server configuration. This is a fundamental defense against information disclosure.

Solution

To restrict access to the NGINX configuration directory and files, execute the following commands:

1. Restrict Directories ( 750 ):

Allow owner ( root ) full access, group read/execute, deny others.

find /etc/nginx -type d -exec chmod 750 {} +

2. Restrict Files ( 640 ): Allow owner ( root ) read/write, group read, deny others.

find /etc/nginx -type f -exec chmod 640 {} +

Note: Private keys (e.g., .key files) require even stricter permissions ( 400 or 600 ) and should be addressed separately or manually verified here.

Impact:

Setting permissions to 640 (files) and 750 (directories) prevents non-privileged users from listing the configuration directory or reading configuration files.

See Also

https://workbench.cisecurity.org/benchmarks/18528

Item Details

Category: ACCESS CONTROL, MEDIA PROTECTION

References: 800-53|AC-3, 800-53|AC-5, 800-53|AC-6, 800-53|MP-2, CSCv7|14.6

Plugin: Unix

Control ID: fec88797425b628dffaaa8dc8f8c2868ae23d766f1c99de892004d226b728e76