| name | cis-nginx-v300-5-3-2 |
| description | Ensure that Content Security Policy (CSP) is enabled and configured properly (Manual) |
| category | cis-nginx |
| version | 3.0 |
| author | cyberstrike-official |
| tags | ["cis","nginx","web-server","reverse-proxy","browser-security","request-filtering"] |
| cis_id | 5.3.2 |
| cis_benchmark | CIS NGINX Benchmark v3.0.0 |
| tech_stack | ["nginx","linux","web-server"] |
| cwe_ids | [] |
| chains_with | [] |
| prerequisites | [] |
| severity_boost | {} |
CIS 5.3.2 — Ensure that Content Security Policy (CSP) is enabled and configured properly
Profile Applicability
Description
Content Security Policy (CSP) is an HTTP response header that allows site administrators to declare approved sources of content that browsers are allowed to load on that page. It is a mechanism to detect and mitigate certain types of attacks, including Cross-Site Scripting (XSS) and data injection attacks. Furthermore, CSP's frame-ancestors directive is the modern replacement for the X-Frame-Options header to prevent Clickjacking.
Rationale
A robust CSP significantly reduces the attack surface of a web application. By restricting the domains from which scripts, styles, images, and other resources can be loaded, it effectively neutralizes many XSS vectors. Additionally, by using the frame-ancestors directive, it explicitly controls which parent pages are allowed to embed the application (e.g., via <iframe>), providing a more flexible protection against Clickjacking than the legacy X-Frame-Options header.
Impact
Implementing a strict CSP is complex and carries a high risk of breaking application functionality. If a legitimate resource (e.g., a CDN script, a font file, or an inline script) is not whitelisted, the browser will block it, potentially making the site unusable. CSP implementation should always start in "Report-Only" mode (Content-Security-Policy-Report-Only) to gather violation reports before enforcing the policy.
Audit Procedure
1. Run the following command to inspect the CSP configuration:
nginx -T 2>/dev/null | grep -i 'Content-Security-Policy'
2. Evaluate the policy:
- Is the header present?
- Does it include at least a restrictive
default-src directive (e.g., 'self' or 'none')?
- Does it include the
frame-ancestors directive to mitigate Clickjacking?
- Critically: Is
unsafe-inline or unsafe-eval avoided in script-src? (Allowing these significantly weakens the protection).