Clickjacking
Tricking a user into clicking something on another site by loading it invisibly in a frame beneath a decoy, and the headers that stop a page from being framed.
Clickjacking tricks a user into clicking something they cannot see. The attacker's page loads a legitimate site, such as a bank, social network, or settings page, inside an invisible frame, then positions a decoy beneath it: a game button, a "play" icon, a prize. The user aims for the decoy and actually clicks the hidden page above it, which is logged in as them. The click might change a setting, approve a payment, or grant camera access.
Robert Hansen and Jeremiah Grossman named the attack in 2008, alongside a demonstration that used Adobe Flash's settings panel, framed invisibly, to switch on a visitor's webcam and microphone. Likejacking soon spread on Facebook, where hidden Like buttons made users unknowingly promote pages. The general term is UI redressing.
The attack works because of how pages compose:
- Framing. A page can embed almost any other page with an iframe unless that page forbids it.
- Opacity and layering. CSS can make the frame fully transparent and stack it above the decoy, as described under Stacking Context.
- Ambient credentials. The framed page receives the user's cookies, so it acts as them. The Same-Origin Policy keeps the attacker from reading the frame, but not from getting the user to click it.
Clickjacking is related to Cross-Site Request Forgery, since both abuse a logged-in session, but CSRF forges a request directly, while clickjacking gets the user to perform a real one. Anti-CSRF tokens don't help, since the click happens on the genuine page with its genuine token.
Defenses moved from scripts to headers:
- Framebusting scripts. Early sites ran JavaScript that broke out of any frame. Attackers defeated it with sandboxed frames and other tricks.
- X-Frame-Options. Microsoft introduced this header in Internet Explorer 8 in 2009.
DENYforbids framing andSAMEORIGINallows only the site itself. - frame-ancestors. The Content Security Policy directive supersedes it, listing exactly which origins may frame a page.
- SameSite cookies. Cookies marked
SameSite, described under HTTP Cookie, are not sent to a page framed by another site, so the framed page loads logged out. - Confirmation. Sensitive actions can require an extra step a single click can't complete.
Browsers added their own protections, such as ignoring clicks on frames that just moved or became visible. Attackers keep adapting. Cursorjacking draws a fake pointer offset from the real one, and in 2024 Paulos Yibelo described double-clickjacking, which asks for a double-click and swaps windows between the two clicks, so the second lands on a page that loaded normally, such as an OAuth consent prompt, sidestepping framing protections entirely.
Framing remains legitimate for embeds, payment widgets, and previews, so the goal is precise permission rather than a blanket ban, applied alongside defenses against Cross-Site Scripting.
See also3
Iframe
A whole web page embedded inside another, the web's main isolation boundary for ads, payments, and widgets, and the messaging and sandboxing rules that govern it.
Web Platform12 connections
Same-Origin Policy
The browser rule isolating documents by scheme, host, and port, and the mechanisms for relaxing it.
Web Platform30 connections
Dark Pattern
An interface deliberately designed to steer users toward a choice that serves the business rather than the user.
Design & Interface17 connections
Linked from6
- Content Security PolicyWeb Platform
An HTTP header that tells the browser which sources of script, style, and other content a page is allowed to load.
- Cross-Site Request ForgeryWeb Platform
Tricking a logged-in user's browser into sending a state-changing request to another site, which works because the browser attaches that site's cookies automatically.
- Dark PatternDesign & Interface
An interface deliberately designed to steer users toward a choice that serves the business rather than the user.
- HTTP CookieWeb Platform
A small piece of state a server asks the browser to store and send back on later requests, governed by attributes that decide exactly where it goes.
- IframeWeb Platform
A whole web page embedded inside another, the web's main isolation boundary for ads, payments, and widgets, and the messaging and sandboxing rules that govern it.
- Stacking ContextDesign & Interface
The nested coordinate system that decides what paints above what, and why z-index often does nothing.