5.2.1 Ensure timeout values for reading the client header and body are set correctly

Information

To protect against slow clients holding connections open indefinitely, NGINX supports several timeout directives. The most important ones for client-facing connections are:

- client_header_timeout : Sets the maximum time the server will wait for a client to send the request header.
- client_body_timeout : Sets the maximum time allowed between sequential read operations when receiving the request body. This timer does not apply to the total time of the transfer.
- send_timeout : Sets the maximum time allowed between sequential write operations when sending a response to the client.

If any of these timeouts are reached, the server closes the connection, freeing up resources.

Aggressively low timeout values are a primary defense against slow-read Denial of Service (DoS) attacks. These attacks attempt to exhaust server resources by opening many connections and keeping them alive for as long as possible by sending data extremely slowly. By setting low timeouts, NGINX efficiently closes these malicious connections, preserving resources for legitimate users.

NOTE: Nessus has provided the target output to assist in reviewing the benchmark to ensure target compliance.

Solution

Set reasonably low timeout values globally in your http block. If specific locations require longer timeouts (e.g., for file uploads), override them within that location block.

Example Configuration:

http {

# Set a global default of 15 seconds, which overrides the default of 60s.

client_header_timeout 15s;
client_body_timeout 15s;
send_timeout 15s;

server {
# ... other settings ...

# This location handles large file uploads and needs a longer timeout.
location /upload {

client_body_timeout 300s; # Allow 5 minutes between read operations for uploads
# ...
}
}
}

Impact:

Setting these values too low can terminate legitimate connections too early. For example, a user uploading a large file over a slow mobile connection could be cut off if client_body_timeout is too aggressive. The values must be carefully evaluated to achieve a balance between security (low values) and functionality (higher values for specific use cases such as file uploads).

See Also

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

Item Details

Category: SYSTEM AND SERVICES ACQUISITION

References: 800-53|SA-3, CSCv7|18.1

Plugin: Unix

Control ID: 21836280f79e6fb5cf0bc22ddcf92db8270b85440da5d162503bae60578d050e