5.3.2 Ensure that Content Security Policy (CSP) is enabled and configured properly

Information

C ontent S ecurity P olicy (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 C ross- S ite S cripting (XSS) and data injection attacks. Furthermore, CSP's frame-ancestors directive is the modern replacement for the X-Frame-Options header to prevent Clickjacking.

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.

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

Solution

CSP must be tailored to the specific application. There is no single \"correct\" policy.

Step 1: The Baseline Policy (High Security)

Start with a policy that denies everything by default and only allows resources from the same origin. It also prevents the site from being framed by anyone (Clickjacking protection).

add_header Content-Security-Policy \"default-src 'self'; frame-ancestors 'self'; form-action 'self';\" always;

Step 2: Adaptation (Example)

If your application loads images from a CDN and needs to be embeddable by a specific partner site:

add_header Content-Security-Policy \"default-src 'self'; img-src 'self' https://cdn.example.com; frame-ancestors 'self' https://partner-site.com;\" always;

Note: Use Content-Security-Policy-Report-Only during the testing phase to debug your policy without breaking the site.

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.

See Also

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

Item Details

Category: CONFIGURATION MANAGEMENT, SYSTEM AND INFORMATION INTEGRITY

References: 800-53|CM-7, 800-53|CM-7(1), 800-53|SI-7, 800-53|SI-7(1), CSCv7|2.9

Plugin: Unix

Control ID: 7d3b072dd557f92ccabfda1f6577081ad9f43f5e4f5f8fe40befcdec387b4310