Skip to main content
LowSSLOWASP A02:2021CWE-319

How to fix: Canonical URL declared as cleartext HTTP

An HTTPS page declares <link rel="canonical"> pointing at the http:// version of a URL.

Why it matters

Search engines index and link the canonical URL, so results, and every site that copies the canonical from your page, send visitors to the cleartext version. Each of those arrivals is a plaintext first request before any redirect or HSTS policy can act, which is the window an on-path attacker uses to strip TLS.

This survives HTTPS migrations because the canonical URL is usually built from a configured site URL rather than from the current request, so the redirect gets fixed and the configuration does not. The redirect to https does not make it harmless: it fixes the browser's next request, not the link that search results and other sites are handing out.

How to fix it

  1. 1Change the canonical URL to https, in the site configuration rather than per template.
  2. 2Check sitemap.xml, og:url, and any RSS or JSON feed for the same stale scheme.
  3. 3Keep the http to https redirect in place and enable HSTS so an already-published cleartext link costs one plaintext request at most.

Code examples

Canonical over HTTPS

HTML
<link rel="canonical" href="https://example.com/articles/tls-migration">
<meta property="og:url" content="https://example.com/articles/tls-migration">

Find the remaining cleartext URLs

bash
curl -s https://example.com/sitemap.xml | grep -c 'http://'
curl -s https://example.com/ | grep -i 'rel="canonical"'

References

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

See every ssl check

Questions

How severe is Canonical URL declared as cleartext HTTP?
VulnRadar rates this low 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-canonical-link-http, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Canonical URL declared as cleartext HTTP 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 canonical url declared as cleartext http

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

Canonical URL declared as cleartext HTTP fix | VulnRadar