Header Security
Content-Security-Policy Header Check
Learn how to configure the CSP header to prevent malicious script execution and XSS attacks. A practical guide with policy examples tailored to your site.
What this test checks
This test checks for the presence and configuration of the Content-Security-Policy (CSP) header. It allows you to define allowed content sources (scripts, images, styles), thereby preventing unauthorised script execution (XSS) and malicious content injections.
Our recommendation
Add the CSP header with a strict policy, e.g.: 'default-src 'self'; script-src 'self' https://cdn.example.com; style-src 'self' 'unsafe-inline';'. Avoid using 'unsafe-inline' and 'unsafe-eval' if possible. Use 'report-only' mode to test changes before applying them in production.
Security tests