Skip to main content
MediumSSLOWASP A02:2021CWE-319

How to fix: Inline script calls a cleartext HTTP endpoint

An inline script on an HTTPS page issues a request to a cleartext http endpoint. The call is a fetch, an XMLHttpRequest.open, or a library helper such as axios.get or jQuery ajax.

Why it matters

Requests made this way are active mixed content. Where a browser allows the request, the payload and any credentials it carries travel in cleartext and the response, which is usually parsed as JSON and rendered into the page, can be replaced wholesale by an on-path attacker. Where the browser blocks it, the feature simply stops working, often silently in a catch block.

Markup-oriented mixed-content checks do not see this: the URL is in JavaScript, not in an attribute. It typically survives an HTTPS migration inside a hardcoded API base URL or a configuration object emitted into the page. Loopback URLs are excluded here, since a development script pointing at localhost is normal.

How to fix it

  1. 1Change the endpoint to https, and confirm the API actually serves TLS before switching.
  2. 2Move the base URL into one configuration value rather than repeating it across scripts.
  3. 3Add upgrade-insecure-requests to the CSP so any remaining cleartext request is upgraded.
  4. 4Use a CSP report-only policy to find the rest in real traffic rather than by grepping.

Code examples

One configured base URL

JavaScript
const API_BASE = 'https://api.example.com';

const res = await fetch(`${API_BASE}/v1/items`, {
  credentials: 'include',
});

CSP: catch what is left

text
Content-Security-Policy-Report-Only: default-src https:; connect-src https:; report-uri /csp-report

References

Detected automatically by VulnRadar. The check id is ssl-http-fetch-endpoint-in-script, stable across every scan so you can filter or diff on it.

See every ssl check

Questions

How severe is Inline script calls a cleartext HTTP endpoint?
VulnRadar rates this medium severity in the ssl 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 ssl-http-fetch-endpoint-in-script, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Inline script calls a cleartext HTTP endpoint 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.

Propose a checkHow a check is built

Scan your own site for inline script calls a cleartext http endpoint

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

Inline script calls a cleartext HTTP endpoint | VulnRadar