Content Security Policy Missing or Weak
The application sends no Content Security Policy, or one too permissive to stop injected script running, so the browser places no effective limit on what its pages may load or execute.
| Severity | Informational |
| CVSS 3.1 | 0 CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:N/A:N Open in the calculator |
| CVSS 4.0 | 0 CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:N/VA:N/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-693: Protection Mechanism Failure |
| OWASP Top 10 | A06:2025 Insecure Design |
| Category | Security Misconfiguration |
Description
Content Security Policy (CSP) is delivered in the Content-Security-Policy response header and tells the browser which sources of script, styles, frames and other content a page may use, whether inline script may run, and which sites may frame the page. A well-built policy means that script injected through a cross-site scripting flaw does not run, because it neither comes from an allowed source nor carries the expected nonce or hash, and so often turns a serious flaw into a much lesser one.
A missing or weak policy has no direct impact of its own: it matters when the application has, or later gains, a flaw that lets an attacker inject content, chiefly cross-site scripting. Without an effective policy, injected script runs with the user's session and can read data, act as the user or capture what they type. The absence of a policy is therefore most significant in applications that handle sensitive data or display content supplied by users.
The finding covers two cases. In the first, no policy is sent, or one is sent only as Content-Security-Policy-Report-Only, which reports violations but enforces nothing. In the second, a policy is enforced but does not restrict script effectively, for example because script-src, or default-src where that is absent, allows 'unsafe-inline' without a nonce or hash, 'unsafe-eval', wildcards, whole schemes such as https: or data:, or domains that host user content or libraries known to allow bypasses; or because object-src and base-uri are left unrestricted. A policy set in a meta element cannot use frame-ancestors or reporting.
The policy is reviewed in the responses, and tools such as CSP Evaluator point out common weaknesses and bypasses.
Remediation
Deploy an enforced policy that restricts script, built for the application rather than copied from elsewhere:
- Prefer a strict policy based on nonces or hashes: a new random nonce generated for every response and added to each legitimate
scriptelement, with'strict-dynamic'so that scripts loaded by trusted scripts are trusted too. Move inline event handlers andjavascript:links into script files or nonced scripts, since such a policy blocks them. - Set
object-src 'none'andbase-uri 'none'(or'self'), and useframe-ancestorsto control framing. - Avoid
'unsafe-inline','unsafe-eval', wildcards and whole schemes inscript-src, and do not allow domains that serve arbitrary or user-uploaded content. - Introduce the policy as
Content-Security-Policy-Report-Onlywith a reporting endpoint, fix what it reports, then switch to the enforcing header.
Here {RANDOM} stands for the nonce generated for that response. Where script cannot yet be restricted, a policy limited to object-src, base-uri and frame-ancestors still removes some attack routes in the meantime. Confirm the fix by checking that the enforcing header is present on all HTML responses, that legitimate pages report no violations, and that an evaluation tool finds no remaining bypass.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.