Overview
Attacker overlays transparent iframe of target site over a decoy page. Victim clicks what they think is the decoy but actually interacts with the hidden target — changing settings, transferring funds, etc.Detection
Check Headers
Vulnerable If
- No
X-Frame-Optionsheader - No
frame-ancestorsin CSP X-Frame-Options: ALLOW-FROM(deprecated, not supported in modern browsers)
X-Frame-Options
Best practice: use both
X-Frame-Options: DENY and frame-ancestors 'none' for backward compatibility.
CSP frame-ancestors (Modern)
frame-ancestors overrides X-Frame-Options when both present.
Basic PoC
Visible for Testing (opacity: 0.5)
Advanced Techniques
Drag-and-Drop Clickjacking
Trick user into dragging content from target iframe into attacker-controlled area:Multi-Step Clickjacking
Move iframe between clicks to chain multiple actions:Cursorjacking
Replace cursor with offset image — user clicks different position than expected:Common Targets
Additional Defenses
SameSite Cookies
SameSite=Strict or Lax session cookies are not sent in any framed (iframe) request regardless of method (GET or POST), since iframe loads are subresource requests — so they block clickjacking of authenticated actions. The real limitation: no protection when the targeted action doesn’t require the session cookie (or when tokens live in localStorage/sessionStorage).
JavaScript Frame-Busting (Unreliable)
sandbox attribute on iframe. Not a reliable defense.