Skip to content
Module 7 of 8Browser Defense
Estimated time: 15 min

Clickjacking & UI Redressing

Framing vulnerabilities, X-Frame-Options, and CSP frame-ancestors.

Core Concept & Mental Model

Clickjacking (UI Redressing) is an attack where an attacker embeds a legitimate target website inside an invisible `<iframe>` layered beneath a deceptive decoy button, tricking the user into clicking unintended actions.

Threat Vector & Impact

An attacker creates a "Claim Free Prize" game on `evil.com`, but overlays an invisible `opacity: 0` iframe pointing to `target.com/delete-account` exactly under the user's mouse cursor.

Defensive Architecture & Mitigation

Disallow unauthorized framing using `Content-Security-Policy: frame-ancestors` and legacy `X-Frame-Options`.

Technical Deep Dive

Frame Protection Standards

  • X-Frame-Options: DENYCompletely prevents any page (even same origin) from framing this document.
  • X-Frame-Options: SAMEORIGINPermits framing only if the framing page shares the exact same origin.
  • CSP: frame-ancestors 'none'Modern W3C replacement for DENY with broader browser and multiple-parent support.
  • CSP: frame-ancestors 'self' https://trusted.comAllows framing only by specific, verified partner applications.

Interactive Mental Model Simulation

Live Visualizer
Interactive Clickjacking & UI Redressing Sandbox
CWE-1021
// No framing headers sent (default vulnerable)
Target Iframe Opacity:25%
0% (Invisible to victim)100% (Fully visible target)
🎉 Congratulations!

Claim Your Free $500 Gift Card!

Click the button below to instantly deposit your bonus reward.

bank.com/transferAuthenticated Session
Transfer Funds
Target Sensitive Action Form

Code Implementation & Patching

Vulnerable Code (Exploitable)
<!-- Evil site framing target without frame protection -->
<div style="position: relative;">
  <button>Click to win $1000!</button>
  <iframe 
    src="https://bank.com/transfer-funds" 
    style="opacity: 0.0001; position: absolute; top: 0; left: 0; z-index: 99;">
  </iframe>
</div>
Secure Patched Code (Hardened)
// Server response header blocking all framing
X-Frame-Options: DENY
Content-Security-Policy: frame-ancestors 'none';
Security Analysis & Core Architectural Rule

When the browser receives frame-ancestors none, it refuses to render the iframe and displays a framing violation error in the console.

Test Your Knowledge on Clickjacking & UI Redressing

Challenge yourself with realistic scenario questions in the Web Security Arena.

Launch Practice Arena