How to fix: CSP script-src allows HTTP sources
The Content-Security-Policy allows scripts to be loaded over unencrypted HTTP, enabling man-in-the-middle injection of arbitrary JavaScript.
Why it matters
An attacker on the network path (coffee shop Wi-Fi, compromised router, ISP-level interception) can inject malicious scripts into HTTP responses, executing arbitrary code in the victim's browser on your HTTPS page.
CSP's value is negated when scripts can be loaded over HTTP. Restrict all sources to https:// or use 'self' with a relative path.
How to fix it
- 1Replace all http:// sources in script-src and default-src with https:// equivalents
- 2Prefer 'self' and relative paths over absolute URLs for first-party scripts
- 3Add upgrade-insecure-requests to automatically upgrade HTTP sub-resources
Code examples
Use HTTPS sources only
# Before (vulnerable)
Content-Security-Policy: script-src 'self' http://cdn.example.com;
# After (safe)
Content-Security-Policy: script-src 'self' https://cdn.example.com; upgrade-insecure-requests;References
Detected automatically by VulnRadar. The check id is csp-allows-http-sources, stable across every scan so you can filter or diff on it.
More headers checks
Questions
- How severe is CSP script-src allows HTTP sources?
- VulnRadar rates this medium severity in the headers category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id csp-allows-http-sources, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does CSP script-src allows HTTP sources map to?
- It maps to CWE-319. In the OWASP Top 10 it falls under A02:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.