Loading...
Loading...
Mixed Content occurs when an HTTPS page loads resources (images, scripts, styles) over insecure HTTP.
1. **Security**: An attacker can modify "passive mixed content" (images) to deface your site, or "active mixed content" (scripts) to fully hijack the session. 2. **UX**: Chrome and Firefox block active mixed content by default, breaking your specific features. Passive content triggers a "Not Secure" warning in the URL bar.
Browsers are increasingly aggressive. `block-all-mixed-content` in your CSP directive is a good safety net. The `upgrade-insecure-requests` directive is a powerful quick fix: it tells the browser to automatically rewrite all `http://` requests to `https://` before sending them.
Mixed content shows up in the browser devtools console (look for "Mixed Content" warnings) and in the page source as literal `http://` URLs. For server-rendered pages, a recursive grep over your source catches most of them before they ship.
grep -rE "\bhttp://[^\s"']+" ./src --include="*.{ts,tsx,js,jsx,html,vue,svelte}"curl -s https://yourdomain.com | grep -oE "http://[^\s"']+" | sort -uContent-Security-Policy: upgrade-insecure-requests; report-to mixed-content`upgrade-insecure-requests` rewrites `http://` to `https://` at request time. `block-all-mixed-content` blocks them outright. Use upgrade first because it preserves functionality; use block for the strictest sites where any cleartext request is unacceptable.
Passive mixed content is images, audio, and video loaded over HTTP. It downgrades the security indicator but is usually still displayed. Active mixed content is scripts, stylesheets, and iframes - those are blocked outright by modern browsers because they can execute code on your page.
Rewrite them. CSP `upgrade-insecure-requests` is a safety net, not a fix. Search your codebase for `http://` in template strings, config files, and database content (CMS posts are a common miss) and switch everything to `https://`.
Applied the configuration change? Run a live scan to confirm the vulnerability is patched.