Clickjacking, also called a UI redress attack, tricks a user into clicking something different from what they think they are clicking. An attacker loads a real website inside a transparent or disguised frame on a malicious page, so a click meant for a harmless button actually hits a hidden button on the real site. The fix is to stop your site being framed, using the Content-Security-Policy frame-ancestors directive and the X-Frame-Options header.
Key takeaways
- Clickjacking hides a real site inside a transparent frame, so your clicks land on buttons you cannot see.
- It can bypass some anti-CSRF protections because the click comes from the real site in your own browser.
- The main defense is CSP frame-ancestors plus X-Frame-Options, with SameSite cookies and confirmation steps for sensitive actions.
You click a button to play a video. Behind it, invisible, sits a real button on a real website — and your click just confirmed a payment, changed a setting, or granted an app access to your account. That is clickjacking, and it works because the click is genuine.
What is clickjacking?
Clickjacking is a UI redress attack in which an attacker uses transparent or disguised layers to trick you into clicking a button or link on another page when you meant to click something on the page you can see. The term was coined by Jeremiah Grossman and Robert Hansen in 2008.
OWASP describes it in test WSTG-CLNT-09 as a technique that deceives a web user into interacting with something other than what they believe they are interacting with. The OWASP testing guide for clickjacking notes the attack can send unauthorized commands or reveal confidential information while the victim uses a seemingly harmless page.
The weakness is catalogued as CWE-1021, Improper Restriction of Rendered UI Layers or Frames, which lists clickjacking, UI redress attack and tapjacking as alternate names. It is a client-side issue that affects a variety of browsers and platforms.
How does clickjacking work?
The attacker builds a page that looks harmless — a game, a video, a quiz, a prize claim — and loads the target site inside an invisible frame on that page. The visible button sits exactly over a real button on the hidden site.
When you click, your browser sends the click to the framed site, not to the decoy. Because you are already logged into the real site, the click carries your real session, so the action succeeds as if you had meant it.
OWASP notes a key detail: because the action comes from the hidden but authentic target page, some anti-CSRF protections can be bypassed. The attack is often designed to work even where anti-CSRF tokens are in use.
What are the main types of clickjacking?
Clickjacking has several variants, all built on the same idea of hiding the real target behind a decoy. Knowing the variants helps you recognize them in the wild.
Classic clickjacking
A transparent frame covers the whole page, with a visible decoy element placed over the target button. This is the original form and still the most common.
Likejacking
The hidden button is a social media "Like", follow or share button. Victims unknowingly endorse pages or spread links, which then reach their friends and pull in more victims.
Tapjacking
The same attack on a touch screen. A malicious app or mobile page overlays a fake interface so a tap lands on a hidden control, such as granting a permission or confirming a purchase.
Cursorjacking
The attacker moves the visible cursor away from the real one, so you click in a different place than you think. It is rarer, but it shows how far UI deception can go.
Filejacking and drag-and-drop attacks
Some variants abuse drag-and-drop: you think you are dragging an image into a game, but you are actually dragging text into a hidden file-upload or settings field.
What can clickjacking actually do?
What clickjacking can do depends entirely on what the target site lets one click do. On a banking site it could confirm a transfer; on a social network it could change privacy settings or post as you.
CWE-1021 gives a social media example: clickjacking could trick a user into changing privacy settings. Other realistic outcomes include granting an app access to your account, deleting content, following a malicious account, or turning on a webcam or microphone permission.
The common thread is that the victim is already authenticated. The attack does not need your password — your browser hands it the session for free. That is why clickjacking is dangerous even though it never shows you a fake login page.
Clickjacking vs CSRF: what is the difference?
Clickjacking and cross-site request forgery (CSRF) are often confused because both abuse your logged-in session from another site. The difference is who performs the action.
| Clickjacking | CSRF | |
|---|---|---|
| Who clicks? | You do, without knowing it | Nobody — the attacker's page sends the request for you |
| How it works | Hidden frame under a decoy button | Hidden form or image request to the target site |
| Needs you to visit a page? | Yes, and to click | Yes, just visiting is enough |
| Main defense | Stop framing: CSP frame-ancestors, X-Frame-Options | Anti-CSRF tokens, SameSite cookies |
| Can CSRF tokens stop it? | Often not — the click comes from the real page | Yes, that is their job |
The two attacks can combine: clickjacking gets you to click, and the click submits a request that CSRF defenses would otherwise have blocked. That is why defenses need to cover both.
How do you spot a clickjacking attempt?
Clickjacking is hard to spot because the page looks normal. The clues are small inconsistencies in how a page behaves, and a habit of pausing before you click.
- The page feels off. Buttons do not respond as expected, or a click seems to do nothing visible while something changes elsewhere.
- Unexpected permission prompts. A video or game page asking for camera, microphone or notification access is a warning sign.
- Overlays that follow your mouse. If a button seems to move or a layer tracks your cursor, close the page.
- Too-good-to-be-true offers. Free prizes, exclusive videos and "click to claim" pages are classic clickjacking bait.
- Strange URLs. A page that claims to be a video but sits on an unfamiliar domain deserves suspicion.
Browser extensions such as NoScript can reveal unexpected scripts and frames, but the simplest defense is habit: never click "allow", "confirm" or "play" on a page you do not trust, and never grant permissions to a site that has no reason to need them.
How do developers prevent clickjacking?
Prevention belongs to the site owner first. The OWASP Clickjacking Defense Cheat Sheet recommends defense in depth: combine framing controls with cookie protections, so even if a page is framed, the request does not carry the victim's session.
1. Set Content-Security-Policy frame-ancestors
This is the modern, preferred defense. Send Content-Security-Policy: frame-ancestors 'none' on all responses if your site never needs to be framed, or frame-ancestors 'self' if only your own pages may frame it. It supports multiple allowed origins, unlike the older header.
2. Add X-Frame-Options as a backup
Send X-Frame-Options: DENY to block all framing, or SAMEORIGIN to allow only your own domain. It covers older browsers that do not support CSP frame-ancestors. Send both headers — they do not conflict.
3. Mark cookies SameSite
Set authentication cookies with SameSite=Lax or SameSite=Strict plus the Secure flag. OWASP notes that cookies marked this way are withheld from cross-site iframe requests, which can prevent clickjacking that depends on those cookies.
4. Require confirmation for sensitive actions
For one-click actions such as transfers, deletions or permission grants, require a step that cannot be pre-positioned — entering a value, solving a challenge, or re-authenticating. A single click should never move money or change a security setting on its own.
5. Test that framing actually fails
OWASP's testing guide is direct: build a test page that tries to load your site in a frame. If the page loads, your site is vulnerable. Test after every deployment, because a single missing header on one page can undo the rest. You can check your headers quickly with our free security headers checker.
What is frame busting, and should you still use it?
Frame busting is the older client-side defense: a script on each page that breaks out of a frame if the page is loaded inside one. It was the most common protection before CSP frame-ancestors existed.
It is not enough on its own. Attackers found ways to defeat frame-busting scripts, for example by blocking the script or by using the frame's sandbox attribute. Treat frame busting as a last resort, not a replacement for headers — and never rely on it as your only defense.
How can users protect themselves from clickjacking?
As a user you cannot set headers, but you can reduce the risk a lot. Keep your browser updated, since browsers add framing protections over time, and be careful with the two things clickjacking needs: a visit and a click.
- Do not click blindly. Pause on unfamiliar pages, especially ones promising prizes, videos or free downloads.
- Log out of sensitive sites such as banking and email when you are done, so a hidden frame has no session to abuse.
- Use separate browser profiles for banking and for casual browsing.
- Be wary of permission prompts from sites that have no business asking for camera, microphone or notifications.
- Consider a script-blocking extension such as NoScript if you are comfortable managing it.
If you run a website, check it today with our security headers checker — it shows whether your framing headers are present.
At home, the network side matters too: our guide to securing your Wi-Fi covers the basics.
For the bigger picture, the small business cybersecurity checklist puts framing headers alongside backups, updates and access control.
The bottom line
Clickjacking works because the click is real — it is the context that is fake. The fix is to make sure your site can never be framed in the first place, and to make sure a single click can never do something irreversible on its own.
Send Content-Security-Policy: frame-ancestors 'none' and X-Frame-Options: DENY, mark session cookies SameSite, and add confirmation steps for sensitive actions. Then verify it all with the free security headers checker.
Frequently asked questions
What is clickjacking in simple terms?
Clickjacking is a trick where a website hides a real page underneath a fake one. You think you are clicking a play button or a prize claim, but your click actually lands on a hidden button on the real site, such as confirming a payment or changing a setting.
Is clickjacking the same as phishing?
No. Phishing tricks you into handing over information on a fake site. Clickjacking tricks you into taking an action on a real site while you think you are doing something else. Both rely on deception, but clickjacking uses your own logged-in session against you.
What is the difference between clickjacking and tapjacking?
Tapjacking is clickjacking on a touch screen. The idea is the same — a hidden layer intercepts your tap — but the victim taps instead of clicking. Mobile apps and mobile browsers can both be targets.
Can clickjacking steal my password?
It usually cannot read your password, but it can abuse your logged-in session. For example, it can trick you into changing your email address, granting an app permission, or confirming a transfer. Combined with other attacks, that can lead to account takeover.
How do I know if a website is vulnerable to clickjacking?
Test whether the site can be loaded inside a frame on another domain. If it loads, it has no framing protection. You can also check its response headers for Content-Security-Policy with frame-ancestors, or X-Frame-Options.
Does X-Frame-Options still matter if I use CSP?
Yes, as a backup. CSP frame-ancestors is the modern, preferred defense and supports multiple allowed origins. X-Frame-Options covers older browsers that do not support CSP frame-ancestors. OWASP recommends sending both.
Can antivirus software stop clickjacking?
Not reliably. Clickjacking happens in the browser using normal web features, so antivirus rarely flags it. Browser-level framing protections and careful clicking are the real defenses, along with site owners sending the right headers.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against the OWASP Web Security Testing Guide (WSTG-CLNT-09) and the OWASP Clickjacking Defense Cheat Sheet.
How we write and fact-check →