4516-nginx-browserSecurity - Suggest Adding Browser Security Headers¶
Rule ID¶
- 4516-nginx-browserSecurity
Category¶
- nginx
Level¶
- info
Compatible Versions¶
- Linux
Description¶
-
The
X-Frame-Optionsheader should be set to allow only specific websites or no website at all to embed your site as an object, depending on your organization's policy and application requirements. -
The
X-Content-Type-Optionsheader should be used to enforce supported user agents to check theContent-Typeheader of the HTTP response and the expected content type from the request target. -
The
X-XSS-Protectionheader allows you to leverage browser-based protection against cross-site scripting. This should be implemented on your web server to protect users and increase user trust in your site. Your policy should be set toblockmode where possible to ensure that the browser blocks the page when cross-site scripting is detected.
Scan Frequency¶
0 */30 * * *
Rationale¶
- Setting
X-Frame-Options,X-Content-Type-Options, andX-XSS-Protectionhelps secure your website. Modify them according to your actual application requirements!
Risk Items¶
- nginx security
Audit Method¶
- To verify the current settings of
X-Frame-Options,X-Content-Type-Options, andX-XSS-Protectionheaders:
grep -ir X-Xss-Protection /etc/nginx
# The output should include
add_header X-Xss-Protection "1; mode=block";
grep -ir X-Content-Type-Options /etc/nginx
# The output should include
add_header X-Content-Type-Options "nosniff";
grep -ir X-Frame-Options /etc/nginx
# The output should include
add_header X-Frame-Options "SAMEORIGIN";
Remediation¶
- Locate the HTTP or server block in the nginx configuration. Add the headers according to your specific application and web system requirements:
# Reduce clickjacking
add_header X-Frame-Options DENY;
# Prevent server from automatically parsing resource types
add_header X-Content-Type-Options nosniff;
# Protect against XSS attacks
add_header X-XSS-Protection "1; mode=block";
Impact¶
- If the browser security headers are not configured or are incorrectly configured, the website may be vulnerable to intrusion and attacks.
Default Value¶
- Not set by default.
References¶
- None
CIS Controls¶
- None