Clickjacking & UI Redressing
Framing vulnerabilities, X-Frame-Options, and CSP frame-ancestors.
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.
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.
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 VisualizerClaim Your Free $500 Gift Card!
Click the button below to instantly deposit your bonus reward.
Code Implementation & Patching
<!-- 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>// Server response header blocking all framing X-Frame-Options: DENY Content-Security-Policy: frame-ancestors 'none';
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.