Quick fix
Inventory scripts, styles, frames, fonts, images, and connection destinations used by the application.
What this finding means
SecuTest checks for a `Content-Security-Policy` header and warns when it contains `unsafe-inline` or `unsafe-eval`. The scanner does not prove that the policy covers every route or that the application contains an injection vulnerability.
Associated attack or threat scenario
How the attack or failure scenario works
Cross-site scripting occurs when attacker-controlled content is executed as trusted script in a victim's browser. A restrictive CSP limits which scripts, styles, frames, and network destinations the browser may use, reducing the impact of many injection flaws. CSP is defense in depth and does not replace output encoding or safe APIs.
Conditions and limitations
- The application has an injection path or a compromised third-party resource.
- The victim loads the affected page.
- The CSP is absent or permits the attacker's execution or exfiltration path.
Why it matters
Step-by-step fix
Where to make the change
- The outermost component emitting the public HTTP response: CDN, reverse proxy, ingress, web server, or application middleware.
- Apply the control consistently to normal pages, redirects, error responses, and relevant subdomains.
Remediation procedure
- Inventory scripts, styles, frames, fonts, images, and connection destinations used by the application.
- Deploy a report-only policy and collect violations without blocking production.
- Replace inline scripts with external files or nonce/hash-based authorization and remove `unsafe-eval`.
- Promote the tested policy to enforcement and keep route-specific exceptions narrow.
Commands and configuration examples
Replace example values with the hostname, selector, IP address, port, provider, or policy values shown in your SecuTest evidence. Review every example before production use.
add_header Content-Security-Policy "default-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; script-src 'self'; style-src 'self'" always;
Header always set Content-Security-Policy "default-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; script-src 'self'; style-src 'self'"
Content-Security-Policy-Report-Only: default-src 'self'; report-to csp-endpoint
Verify the fix
- Run `curl -sS -D- -o /dev/null https://example.com/` and inspect the CSP header.
- Use browser developer tools and CSP violation reports to identify blocked legitimate resources.
- Test authenticated, error, checkout, and embedded-content routes.
- Confirm `script-src` does not rely on broad wildcards or unnecessary unsafe keywords.
After DNS, CDN, certificate, mail, or application propagation completes, run a fresh SecuTest scan and compare the new evidence with the original finding.
Common mistakes
- Copying a strict sample directly into production without inventorying application dependencies.
- Keeping `unsafe-inline` permanently instead of using nonces or hashes.
- Assuming CSP makes unsafe template rendering or DOM APIs acceptable.