Why it matters
- Scripts, stylesheets, frames, icons and subtitles: browsers block them on HTTPS pages, since anyone on the way could change them, so the page breaks or loses its styles. So too images chosen by
srcsetor<picture>, and images on an IP address rather than a domain name. - Other images, video and audio: browsers that follow Mixed Content Level 2, Chrome and Firefox among them, ask for them over HTTPS instead, so they vanish when they are not there. Other browsers load them and show the page as not secure.
- Forms: what the visitor types, such as a password or a phone number, is sent in the clear, and browsers warn before sending it.
Example
<img src="http://shop.example/images/halwa.jpg" alt="علبة حلوى عمانية" width="400" height="300" />
<img src="/images/halwa.jpg" alt="علبة حلوى عمانية" width="400" height="300" />
How to fix
- Change
http://tohttps://in resource addresses, or use paths that start with/on the same site. - For a resource on another site that does not work over HTTPS: move it to your site, or replace it.
Content-Security-Policy: upgrade-insecure-requestshas the browser ask for everyhttp:address over HTTPS, forms included, so the page passes this rule. The addresses are still wrong wherever the HTML is read without it, so fix them too.
How we detect
- The rule applies to HTTPS pages.
- We read the page's HTML for elements that load over
http::script,iframe,object,embed,linkfor stylesheets and icons, andimg,srcset,video,audio,sourceandtrack; and for forms that send tohttp:(action, andformactionon a form's submit button). - We resolve each address as the browser does, including what
<base>changes, and readsrcsetas HTML does. A script the browser does not fetch, such asnomoduleor a template, does not count. - A page that asks for
upgrade-insecure-requests, in aContent-Security-Policyheader or in a<meta>in<head>before the element, passes: the browser fetches each address over HTTPS. AContent-Security-Policy-Report-Onlyheader upgrades nothing. - We do not check what scripts add to the page after it loads.