Beginner·16 min read·Updated 2026-10-15

HTTPS Mixed Content: Passive vs. Active Insecure Resources & Complete Fix Guide

Original WeSecureX guide for authorized testing of sites you own. Linked Sources are citations for verification - not copied articles. Ads are not served on this page.

When a website migrates to HTTPS, all of its subresources (scripts, stylesheets, images, fonts, and iframes) must also be delivered over a secure TLS connection. If an HTTPS webpage requests resources over unencrypted HTTP, the page enters a **Mixed Content** state. Modern web browsers automatically block high-risk active mixed content (scripts and iframes) and display broken padlock warnings or degrade security indicators for passive mixed content (images). Mixed content exposes visitors to Man-in-the-Middle (MitM) eavesdropping and code injection, where an attacker on the same local network alters HTTP scripts to hijack sessions. This guide explores the distinction between passive and active mixed content, automated diagnosis via the [WeSecureX SSL Checker](/tools/ssl-checker), and rapid resolution using the `Content-Security-Policy: upgrade-insecure-requests` header.

Quick Answer

Fix mixed content by deploying the Content-Security-Policy: upgrade-insecure-requests HTTP response header, replacing absolute http:// resource URLs with relative or https:// URLs in your source code, and auditing external asset CDNs with the WeSecureX SSL Checker.

Key Takeaways
  • Mixed content degrades user trust by stripping browser green padlocks and displaying warnings.
  • Active mixed content (scripts, stylesheets, iframes) is blocked by modern browsers by default.
  • The CSP upgrade-insecure-requests header provides an instant browser-side fix.
  • Permanent resolution requires updating database URLs and asset templates to relative or HTTPS links.
Visual Diagram · Mixed Content Blocking Architecture in Modern Web Browsers
1

1. Secure HTTPS Request

User connects securely to https://example.com via TLS 1.3.

2

2. Insecure Subresource Call

HTML contains <script src='http://cdn.example.com/app.js'>.

3

3. Browser Blocking Engine

Browser detects Active Mixed Content and blocks execution immediately (net::ERR_BLOCKED_BY_CLIENT).

4

4. CSP Upgrade Header

Server emits upgrade-insecure-requests; browser rewrites call to https:// automatically.

ShareShare on XLinkedIn

1. Passive vs. Active Mixed Content: Threat Profiles & Browser Handling

WeSecureX SSL Checker validating TLS encryption and certificate chains
WeSecureX SSL Checker validating TLS encryption and certificate chainsWeSecureX Platform View

Browsers classify mixed content into two distinct risk categories based on whether the insecure subresource can alter the Document Object Model (DOM) of the parent page:

Active Mixed Content (Critical Risk): Occurs when the browser loads executable resources - such as JavaScript files (<script src='http://...'>), CSS stylesheets (<link rel='stylesheet'>), iframes, XMLHttpRequest, or WebSocket connections - over unencrypted HTTP. An attacker on the local network (such as a public Wi-Fi hotspot) can intercept the cleartext HTTP traffic and replace the script with malicious code. The injected script inherits full access to the HTTPS page's DOM, allowing the attacker to capture keystrokes, harvest login passwords, and steal session tokens. Because of this extreme risk, modern browsers block active mixed content automatically.

Passive Mixed Content (Moderate Risk): Involves non-executable media files - such as images (<img src='http://...'>), audio files, and video streams. While an attacker cannot directly execute JavaScript through an image file, they can swap image content to display misleading financial information or phish users. In addition, an eavesdropper can track which images a user loads to reconstruct their browsing activity. Modern browsers strip the security padlock or attempt automatic HTTPS upgrades. Verify your SSL certificate installation with our Free SSL Checker Tool.

CategoryResource TypesSecurity RiskModern Browser Behavior
Active Mixed Content<script src>, <link rel='stylesheet'>, <iframe>, fetch(), XMLHttpRequestCritical: Attacker can intercept HTTP and inject malicious JS to steal cookies or redirect usersBlocked automatically by default in all modern browsers; throws console errors
Passive Mixed Content<img>, <audio>, <video>, <source>Moderate: Attacker can swap images or monitor user viewing habits via cleartext trafficBrowsers attempt auto-upgrading to HTTPS; if upgrade fails, resource may be blocked or padlock removed

2. Instant Mass Remediation: The CSP upgrade-insecure-requests Header

WeSecureX Security Headers Tool analyzing CSP and HSTS headers
WeSecureX Security Headers Tool analyzing CSP and HSTS headersWeSecureX Platform View

Migrating enterprise websites with thousands of legacy articles and hardcoded database URLs to HTTPS can be time-consuming. Fortunately, the W3C Content Security Policy specification provides an elegant mechanism for instant, zero-downtime remediation: the `upgrade-insecure-requests` directive.

When you publish the Content-Security-Policy: upgrade-insecure-requests HTTP response header, modern browsers automatically rewrite all insecure http:// subresource URLs to https:// before initiating network requests. A legacy tag like <img src="http://cdn.example.com/logo.png"> is transparently requested over https://cdn.example.com/logo.png, eliminating browser mixed content warnings without requiring manual database find-and-replace scripts.

In addition to CSP, deploy the HTTP Strict Transport Security (HSTS) header (Strict-Transport-Security: max-age=31536000; includeSubDomains; preload). HSTS ensures that browsers automatically upgrade all future top-level and subdomain requests to HTTPS, preventing SSL-stripping attacks. Audit your server headers with the WeSecureX Security Headers Checker.

nginx
# Deploying CSP upgrade-insecure-requests in Nginx
server {
  listen 443 ssl http2;
  server_name example.com;

  # Enforce automatic HTTPS rewriting for all subresources
  add_header Content-Security-Policy "upgrade-insecure-requests;" always;
  
  # Enforce HSTS for 1 year including subdomains
  add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
}

# Deploying in Apache (.htaccess)
<IfModule mod_headers.c>
  Header always set Content-Security-Policy "upgrade-insecure-requests;"
  Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
</IfModule>

3. Permanent Resolution: Database & Source Code Auditing

WeSecureX Website Scanner testing mixed content subresources and TLS configurations
WeSecureX Website Scanner testing mixed content subresources and TLS configurationsWeSecureX Platform View

While upgrade-insecure-requests resolves mixed content on modern browsers, it is a client-side patch. If a third-party asset provider does not support HTTPS, the upgraded request will fail with an SSL handshake error, resulting in broken images or failed scripts. A robust security strategy requires permanent remediation in application templates and databases.

Audit your CMS databases (WordPress, Ghost, Drupal) for hardcoded http:// URLs. Execute SQL updates to replace hardcoded protocol prefixes with relative paths (e.g., /images/logo.png) or explicit https:// links. In your source code repositories, search for hardcoded http:// asset imports in JSX, HTML, and CSS bundles.

Verify that your continuous integration pipelines audit all new pull requests for insecure asset URLs. Use the WeSecureX Technical SEO Scanner to crawl your entire domain and detect mixed content links, broken SSL certificates, and insecure redirects before your users encounter browser warnings.

sql
-- SQL Query to audit and clean hardcoded HTTP links in database tables
-- 1. Identify posts containing legacy http links
SELECT id, title FROM blog_posts WHERE content LIKE '%http://static.example.com%';

-- 2. Bulk replace legacy HTTP URLs with HTTPS
UPDATE blog_posts 
SET content = REPLACE(content, 'http://static.example.com', 'https://static.example.com')
WHERE content LIKE '%http://static.example.com%';

-- 3. Replace third-party HTTP widgets with HTTPS
UPDATE blog_posts 
SET content = REPLACE(content, 'http://widgets.provider.com', 'https://widgets.provider.com')
WHERE content LIKE '%http://widgets.provider.com%';

Apply it with WeSecureX

Add a hostname you own or are allowed to test, run a scan, and open the findings for that target. A confirmed result includes the request WeSecureX sent and the response the site returned, so you can reproduce it, fix it in your own application, and rescan the same host to confirm the issue is gone. WeSecureX is automated testing, not a manual penetration test, and a clean report is not a promise that every weakness is gone.

Checks that belong with this topic

  • Deploy the Content-Security-Policy: upgrade-insecure-requests header across your web server.
  • Replace hardcoded http:// protocol prefixes with root-relative paths (/path/to/asset).
  • Audit third-party widget, font, and analytics providers to confirm HTTPS support.
  • Validate SSL certificate installation and expiration using the WeSecureX SSL Checker.
  • Check your site with the WeSecureX Security Headers Checker to confirm HSTS and CSP.

Actionable Checklist

WeSecureX Platform · Surface Monitor

Application Attack Surface Analyzer

Inspect open ports, TLS certificate chains, HTTP headers, and API endpoint security posture.

Includes: TLS/SSL cipher suite & expiration monitoring · Security header verification (CSP, HSTS) · Subdomain asset discovery

Frequently Asked Questions

If the third-party server hosting the resource does not have an active SSL/TLS certificate, the browser's upgraded HTTPS request will fail with an SSL handshake error (`ERR_CERT_COMMON_NAME_INVALID` or `ERR_CONNECTION_REFUSED`), and the asset will not load.

HSTS fixes mixed content *only* for the domain and subdomains covered by the HSTS policy (`includeSubDomains`). It does not upgrade third-party external resources (e.g., external CDNs) loaded over cleartext HTTP unless `upgrade-insecure-requests` is also present.

The [WeSecureX Technical SEO Scanner](/seo-scanner) and [Website Scanner](/scanner) crawl your internal pages and flag all unencrypted HTTP subresources and insecure redirects.

Authoritative Sources & References

  • Google Web Fundamentals: Preventing Mixed ContentGoogle (official)
    View Source
  • W3C Mixed Content SpecificationW3C (official)
    View Source

Continue exploring related technical architecture and defensive guides

Security Research & Engineering Articles

All articles