Join our Newsletter — 33% off our NHI Course
Home› Guides› Mixed Content and Secure Contexts Guide: Upgradable vs…
Guide Web & API Security

Mixed Content and Secure Contexts Guide: Upgradable vs Blockable Content and upgrade-insecure-requests

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 14 min read
On this page

An HTTPS page that still pulls a script, stylesheet, frame or API call over plain HTTP gives an on-path attacker a way to read or rewrite the page, and modern browsers respond by silently upgrading some of those requests and blocking the rest, which is why so many HTTPS migrations end with broken pages nobody can explain. This guide explains how browsers classify mixed content under the W3C Mixed Content Level 2 specification, what a secure context is and which features need one, and how the CSP upgrade-insecure-requests directive, HSTS and the obsolete block-all-mixed-content directive differ. It ends with a practical method to find and fix mixed content using CSP reporting. It is written for web developers, front-end platform owners and application security engineers finishing or auditing an HTTPS migration. Specification status and browser behaviour were checked in November 2026.

Key takeaways

  • Only images, audio and video are upgradable. Browsers following Mixed Content Level 2 rewrite those requests from http to https; everything else (scripts, stylesheets, iframes, fetch, XHR, fonts, srcset images) is blockable and fails with a network error.
  • An upgrade never falls back to HTTP. If the HTTPS copy does not exist, the image or video simply does not load, and requests to a bare IP address are blocked rather than upgraded.
  • Secure contexts gate powerful features. Service workers, Web Crypto, WebAuthn, Geolocation, the Push and Payment Request APIs and dozens more are exposed only when the page and every ancestor frame are potentially trustworthy.
  • upgrade-insecure-requests and HSTS solve different problems. The CSP directive rewrites a page's own subresource URLs; HSTS stops the browser ever using HTTP for your host. Use both, and drop block-all-mixed-content, which the specification now marks obsolete.
  • Report first, then enforce. A Content-Security-Policy-Report-Only policy with a default-src https: style rule and a report-to endpoint gives you a list of every insecure URL real users hit before you change anything.

What mixed content is

Mixed content is any resource requested over an insecure scheme from a document that was itself delivered securely. The page arrived over TLS, so the browser shows it as secure, but some of the content that makes up the page did not. The W3C specification checks this for the top-level document and for every ancestor frame: if a secure page frames another secure page that then loads http:// content, that request is still mixed and is treated as such.

The risk depends on what the resource can do. A script loaded over HTTP runs with the full authority of the page, so anyone on the network path (a hostile Wi-Fi hotspot, a compromised router, an ISP injecting content) can replace it and take over the session, read form fields or rewrite links. This is the adversary-in-the-middle position described in MITRE ATT&CK T1557 Adversary-in-the-Middle. A replaced image is less dangerous but can still mislead users or leak which pages they visit.

Two related cases are easy to miss:

  • Mixed downloads: a download started from a secure page but fetched over HTTP. The specification says these are not upgraded; the browser aborts them, although the bytes may already have crossed the network. MDN notes that browsers which block them usually warn the user and offer to keep or discard the file.
  • Insecure form actions: a form on an HTTPS page that posts to an http:// URL. The specification lets browsers warn on these and treat them as blockable even at top level, so never rely on such a form working.

Older documentation talks about "active" and "passive" or "blockable" and "optionally blockable" content. Mixed Content Level 2 replaced that model: the old optionally blockable set became the much smaller upgradable set, and everything else is blockable.

Upgradable vs blockable content

The current specification is a W3C Candidate Recommendation Draft dated 23 February 2023. It defines upgradable content narrowly and makes everything else blockable. Browsers autoupgrade the first group and block the second.

ResourceCategoryBrowser handling on an HTTPS pageFix
<img src>, CSS background-image and border-image (host name, not IP)UpgradableRewritten to https; fails if the HTTPS copy is missingChange URL to https or relative path
<audio>, <video> and their <source> elementsUpgradableRewritten to https; fails if unavailableHost media on HTTPS
<img> with srcset or inside <picture>BlockableBlockedRewrite every candidate URL
<img crossorigin> (CORS request)BlockableForce-failed by the specificationServe over HTTPS with CORS headers
Any upgradable type addressed by IP (http://192.0.2.10/x.png)BlockableBlocked, not upgradedUse a host name with a valid certificate
<script src>, <link href> stylesheets, web fonts, @font-faceBlockableBlockedSelf-host or use the provider's HTTPS URL
<iframe src>, <object data>BlockableBlockedFrame HTTPS content only
fetch(), XMLHttpRequest, navigator.sendBeaconBlockableBlocked with a network errorMove APIs to HTTPS, fix base URLs in config
Download link to http://Mixed downloadAborted, usually with a user warningServe files over HTTPS

Chrome introduced this behaviour in stages: the Chromium team announced in October 2019 a per-site setting to unblock mixed content in Chrome 79, autoupgrade of mixed audio and video in Chrome 80, and autoupgrade of mixed images, later delayed to Chrome 84 or later. MDN now lists mixed content handling as Baseline widely available, so assume every current major browser upgrades the upgradable set and blocks the rest. Users can still override blocking in site settings, which the specification allows, so a page that "works on my machine" may only work because a tester once clicked through.

Secure contexts and the features that require them

A secure context is a window or worker that meets minimum standards of authentication and confidentiality. The W3C Secure Contexts specification (Candidate Recommendation Draft, 10 November 2023) defines it through the idea of a potentially trustworthy origin:

  • Trustworthy: https and wss origins; loopback addresses 127.0.0.0/8 and ::1; localhost and *.localhost where the browser resolves them to loopback; about:blank, about:srcdoc and data: URLs; origins a developer has configured as trusted for testing.
  • Usually trustworthy: file: URLs (the specification says SHOULD, so a hardened browser may exclude them) and vendor schemes such as extension URLs.
  • Not trustworthy: opaque origins and plain http on any other host. Domain and port make no difference.

The ancestor rule matters most in practice. A framed document is a secure context only if it came from a trustworthy origin and its embedder is also a secure context, so an HTTPS widget framed by an HTTP page loses every secure-only feature. Dedicated workers inherit from their owner, shared workers from their creator, and service workers are always secure and can only be registered by secure clients. Code can check self.isSecureContext at runtime, and specification authors mark interfaces with the [SecureContext] IDL attribute so they simply do not exist elsewhere.

The localhost exemption is why development often works and staging breaks: http://localhost:3000 is a secure context, but http://staging.internal is not, so service workers, WebAuthn and the clipboard API vanish the moment the app moves to an internal HTTP host. Put staging behind HTTPS with an internal CA rather than adding browser flags. See the ACME and Automated Certificate Management Guide.

AreaExamples restricted to secure contexts (MDN list, March 2026)
Identity and credentialsWeb Authentication API, Credential Management API, WebOTP API, Payment Request API, Web-based Payment Handler API
Cryptography and storageWeb Crypto API, Storage API, Cookie Store API, File System API, Web Locks API, Shared Storage API
Offline and backgroundService Workers, Background Fetch, Background Synchronization, Push API, Notifications API, Content Index API
Devices and sensorsGeolocation, Generic Sensor, Device Orientation and Motion, Web Bluetooth, WebUSB, WebHID, Web NFC, Web MIDI, Gamepad, WebXR
Media and capturegetUserMedia(), Screen Capture, Encrypted Media Extensions, Audio Output Devices, WebCodecs
OtherAsync Clipboard, Reporting API, WebGPU, WebTransport, Web Share, Screen Wake Lock, Badging, Idle Detection, Window Management

The specification is clear about one limit: secure and non-secure views of the same origin are not fully isolated, so data can still pass between them through localStorage, BroadcastChannel and storage events. Do not treat "secure context" as a substitute for serving the whole origin over HTTPS. Secure-only cookies are a separate control; see the Cookie Security Guide.

upgrade-insecure-requests and HSTS

Three mechanisms are often confused. They work at different layers and you normally want two of them.

MechanismWhat it doesWhat it does not doStatus
CSP upgrade-insecure-requestsRewrites the page's own http: subresource requests (including blockable ones and ws:) to https: before they leave the browser; also upgrades same-origin navigations and form submissions; inherited by nested frames and workersDoes not upgrade third-party links into your site, has no HTTP fallback, ignored in Report-Only policiesW3C Candidate Recommendation (2015), widely implemented
HSTS (Strict-Transport-Security)Tells the browser to use HTTPS for every future request to the host (and subdomains with includeSubDomains), removing the HTTP fallback attackers exploitDoes nothing for third-party hosts your page loads from; first visit is unprotected unless preloadedRFC 6797
CSP block-all-mixed-contentBlocked all mixed content including the old optionally blockable setRedundant now that upgradable content is upgraded and everything else blocked; does nothing when upgrade-insecure-requests is presentObsolete in Mixed Content Level 2; deprecated on MDN

Decision guidance:

  • Large legacy site or CMS with hard-coded http:// links in stored content: send upgrade-insecure-requests as soon as every referenced host supports HTTPS, then clean the content over time. The specification was written for exactly this migration case.
  • Modern application you build from source: fix the URLs at source, use relative or https:// URLs, and treat upgrade-insecure-requests as a safety net rather than the fix.
  • Any site: deploy HSTS on the host itself. The directive protects what the page loads; HSTS protects how the user reaches the page. See the HSTS and HSTS Preload guide.
  • You want to block, not upgrade, a resource class: restrict the relevant fetch directive to HTTPS, for example img-src https:, instead of the obsolete directive.

Browsers that support the directive also send an Upgrade-Insecure-Requests: 1 request header. Servers can use it to redirect an HTTP request to HTTPS (the specification suggests a 307 with Vary: Upgrade-Insecure-Requests), which is a useful hint but no replacement for a blanket redirect plus HSTS. For the wider header set, see the Security Headers Guide and the Content Security Policy Guide.

Finding and fixing mixed content

The fastest reliable inventory comes from real browsers via CSP reporting, backed by a crawl and a source search. Work through it in this order.

  1. Search the source and content stores. Grep templates, front-end bundles, configuration (API base URLs, CDN hosts, analytics snippets) and CMS database fields for http://. Database content and third-party tag managers are where most stragglers live.
  2. Deploy a report-only policy. Send Content-Security-Policy-Report-Only: default-src https: 'unsafe-inline' 'unsafe-eval'; report-to csp-endpoint with a matching Reporting-Endpoints header. This reports every non-HTTPS load without breaking anything; tighten or drop the unsafe keywords once your main CSP exists. Note that upgrade-insecure-requests itself is ignored in report-only mode, and that reports show the original insecure URL.
  3. Triage the reports. CSP Level 3 violation reports carry documentURL, blockedURL and effectiveDirective. Group by blocked host and directive, then by page. Sort fixes by request volume, as the specification advises.
  4. Fix by host. First-party hosts: move to HTTPS and rewrite links. Third-party hosts: switch to their HTTPS endpoint, self-host the asset, or remove it. A third party with no HTTPS option is a supply chain risk in its own right.
  5. Turn on upgrade-insecure-requests in enforcing CSP. Pilot on one section of the site, watch error rates and broken-image reports for a week, then widen. Rollback is removing the directive from the header at the edge.
  6. Add HSTS and redirects. Redirect port 80 to HTTPS on the same host, then ramp HSTS max-age up in stages.
  7. Keep the report-only policy running. New content and new tags will reintroduce http:// links; continuous reporting catches them.

Testing: the browser developer console logs each upgraded and blocked request. MDN also suggests turning on your browser's option to block all mixed content and checking pages still work, plus crawling the site with a link checker. Add an automated check in CI that fails a build on new http:// references in templates. For scripts that must come from a CDN, pair HTTPS with integrity checks; see the Subresource Integrity (SRI) Guide.

Small vs large estates: a small site can usually fix every URL by hand in a day and skip report-only. A large estate with many teams, a CMS and dozens of tag manager containers should treat this as a programme: central reporting endpoint, owner per host, and a dashboard.

Detection and measurement

  • Mixed content reports per day: count of CSP reports with an http: blockedURL, trending to zero.
  • Distinct insecure hosts: number of unique hosts still requested over HTTP, with an owner for each.
  • Pages with blocked resources: share of crawled pages logging any blocked request in the console.
  • HSTS coverage: percentage of public hosts sending HSTS with a max-age of at least one year.
  • Secure-context failures: client errors where isSecureContext is false or a secure-only API is undefined, a sign that an app is being framed or served insecurely.

Framework mapping

FrameworkReferenceHow it applies
NIST SP 800-53 Rev 5SC-8 Transmission Confidentiality and Integrity; SC-23 Session AuthenticityEvery resource of an authenticated page travels over TLS
NIST CSF 2.0PR.DS-02; PR.PS-01Data in transit protected; header and CSP configuration managed
OWASP ASVS 5.0V3.4.1 (HSTS); V3.4.3 (CSP); V3.1.1 (documented browser security features)Verification requirements for headers and policy
CIS Controls v8.1Control 16 Application Software SecuritySecure development and configuration of web applications
ISO/IEC 27001:2022A.8.24 Use of cryptography; A.8.28 Secure codingEncryption in transit and safe coding standards
MITRE ATT&CK v20T1557 Adversary-in-the-Middle; T1185 Browser Session HijackingThreats that insecure subresources enable

Common failure patterns

  • Images break after the migration: the browser upgraded http://cdn.example.com/a.png but the CDN has no certificate for that name. Upgrades never fall back, so the fix is HTTPS on the asset host, not a browser exception.
  • Responsive images missed: teams fix src but leave srcset or <picture> candidates on HTTP, which are blockable, so some devices see blank images while desktops look fine.
  • Relying on upgrade-insecure-requests for top-level safety: the directive does not protect users who arrive via an http:// link from another site. Without HSTS, the first request is still exposed to stripping.
  • Staging on plain HTTP: service workers, WebAuthn and clipboard features work on localhost and in production but fail on an HTTP staging host because it is not a secure context, so bugs reach production untested.
  • Keeping block-all-mixed-content: it adds nothing in current browsers, does nothing alongside upgrade-insecure-requests, and gives a false sense of a control.
  • One-off clean-up with no monitoring: marketing tags, embeds and CMS content reintroduce HTTP links within months unless report-only CSP stays on.

Practitioner checklist

  • Search templates, bundles, configuration and CMS content for http:// and assign an owner to each host found.
  • Deploy a report-only CSP that flags non-HTTPS loads, with a report-to endpoint, before changing behaviour.
  • Move every first-party asset host to HTTPS with automated certificate renewal.
  • Replace or self-host third-party assets that have no HTTPS endpoint.
  • Fix srcset, <picture>, fonts and IP-addressed URLs, which are blocked rather than upgraded, and move WebSockets to wss://.
  • Add upgrade-insecure-requests to the enforcing CSP after a pilot, and remove block-all-mixed-content.
  • Deploy HSTS on every public host and redirect port 80 to HTTPS.
  • Run staging and test environments on HTTPS so secure-context features behave as in production.
  • Fail CI builds on new http:// references and keep CSP reporting on permanently.

Standards and references

Related NHI Mgmt Group resources: Content Security Policy Guide · HSTS and HSTS Preload · Security Headers Guide · Subresource Integrity (SRI) Guide · How TLS Works Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.