Web Development

Clickjacking Guide: Definition, Types & Prevention

Understand clickjacking and how UI redress attacks work. Implement defense strategies like CSP frame-ancestors and X-Frame-Options to protect your site.

12.1k
clickjacking
Monthly Search Volume
Keyword Research

Clickjacking, also known as a UI redress attack, tricks users into clicking concealed web elements by overlaying invisible frames on legitimate-looking pages. This technique hijacks user interactions to perform unauthorized actions, such as transferring funds or stealing credentials, without the victim's knowledge. For marketers and SEO practitioners, clickjacking poses a direct threat to analytics integrity, wastes advertising budgets on fake social engagements, and erodes user trust when attackers exploit your brand's legitimate pages.

What is Clickjacking?

Clickjacking is a malicious technique where an attacker uses multiple transparent or opaque layers to deceive a user into clicking on a button or link on another page when they intend to click on the visible top layer. [Jeremiah Grossman and Robert Hansen coined the term "clickjacking" in 2008] (SecTheory) after discovering that [Adobe Flash Player was able to be clickjacked] (SecTheory), potentially allowing attackers to access user cameras and microphones. The attack represents an instance of the confused deputy problem, where a computer is tricked into misusing its authority.

Why Clickjacking Matters

Clickjacking creates specific risks for marketing operations and SEO performance:

  • Corrupted social metrics: Likejacking forces users to "like" pages unintentionally, inflating engagement numbers and wasting retargeting budgets on audiences who never intended to interact with your brand.
  • Polluted analytics data: Unauthorized form submissions or purchases generated through clickjacking create false conversion signals, skewing attribution models and ROI calculations.
  • Reputation damage: When attackers use your legitimate site as the hidden layer in a scam, victims associate the fraud with your brand, potentially triggering browser warnings and search engine security flags.
  • Loss of user trust: Credential theft via clickjacking leads to account takeovers that can result in spam content posted from legitimate user profiles, damaging community trust and platform standing.

How Clickjacking Works

The attack follows a predictable technical pattern:

  1. Target identification: The attacker identifies a page with sensitive actions, such as a bank transfer confirmation or social media like button, that the victim is likely already authenticated to access.
  2. Decoy creation: The attacker builds a legitimate-looking page with enticing content, such as a free gift offer or viral video.
  3. Layer overlay: Using an iframe with CSS opacity set to zero, the attacker loads the target page over the decoy, aligning specific buttons so that the visible "Receive Gift" button sits directly above the hidden "Confirm Transfer" button.
  4. Interaction capture: When the user clicks the visible element, they actually trigger the hidden action on the authenticated target site.
  5. Untraceable execution: The target site processes the action as legitimate since the request includes the user's real credentials, making the attack difficult to trace back to the attacker.

Types of Clickjacking

Clickjacking manifests in several distinct forms:

Type Description Primary Target
Classic Uses hidden iframes in web browsers to overlay malicious pages on legitimate ones. General web users
Likejacking Manipulates Facebook's "Like" button to force users to like content unintentionally. Social media marketers
Cursorjacking Manipulates the cursor's appearance and location to misdirect user clicks. [Eddy Bordi discovered this technique in 2010] (Black Hat). Firefox users (historically)
Nested Embeds a malicious frame between two frames of the original page, exploiting X-Frame-Options SAMEORIGIN vulnerabilities. Google+ (historically)
Cookiejacking Tricks users into dragging objects to select and steal cookie content from browsers. General web users
Filejacking Sets up the affected device as a file server to acquire personal data through browser file dialogs. General web users
Password manager attack Exploits autofill capabilities to steal credentials via invisible form fields. [A 2014 Carnegie Mellon study found some managers insecurely filled http versions of https-saved passwords] (USENIX). Password manager users

Best Practices

Protect your site and users with these actionable strategies:

Implement Content Security Policy frame-ancestors Configure the frame-ancestors directive in your CSP to explicitly control which domains can embed your content. Use 'none' to prevent all framing, or 'self' to allow only your own domain. This directive obsoletes X-Frame-Options and provides granular control over embedding.

Deploy X-Frame-Options for legacy support Set the X-Frame-Options header to DENY or SAMEORIGIN to prevent your pages from being displayed in frames on external sites. [This header was introduced in 2009 in Internet Explorer 8] (MSDN Blogs) and [officially published as RFC 7034 in 2013] (IETF). Avoid relying on the ALLOW-FROM value, as it lacks universal browser support.

Configure SameSite cookie attributes Set the SameSite attribute on session cookies to Strict or Lax to prevent browsers from sending cookies in cross-site requests, limiting the damage from embedded attacks.

Use Intersection Observer v2 for framed content If you provide embeddable widgets, implement [Intersection Observer v2, enabled by default since Google Chrome 74 in April 2019] (Google Developers), to detect when your content is being obscured by other elements.

Educate your marketing team Train team members to recognize signs of clickjacking, such as sudden spikes in social engagement without corresponding traffic increases, or user reports of unexpected account behavior. Quick reporting can limit damage to brand reputation.

Common Mistakes

Avoid these implementation errors that leave your site vulnerable:

Mistake: Relying solely on JavaScript framekillers. Framebusting scripts can be bypassed, particularly on Internet Explorer where the SECURITY=restricted attribute allows circumvention. They also fail entirely if the user has disabled JavaScript. Fix: Implement server-side headers like X-Frame-Options and CSP frame-ancestors as your primary defenses.

Mistake: Using ALLOW-FROM without verifying browser support. The ALLOW-FROM value for X-Frame-Options is not supported by all browsers, creating inconsistent protection when used alone. Fix: Use CSP frame-ancestors for specific domain whitelisting, as it offers broader support and more precise control than X-Frame-Options.

Mistake: Setting protection headers only on the homepage. Attackers target specific functional pages, such as checkout confirmations, account settings, or admin panels, not just landing pages. Fix: Apply X-Frame-Options and CSP headers globally across all pages, particularly those handling authentication, financial transactions, or personal data.

Mistake: Ignoring mobile-specific attack vectors. Browserless clickjacking exploits toast notification delays on Android devices to place invisible buttons under notifications, bypassing traditional iframe defenses. Fix: Test mobile application behavior and ensure notification handling does not create click interception vulnerabilities, particularly on Android devices.

Mistake: Assuming password managers eliminate clickjacking risk. [A 2014 paper from Carnegie Mellon University found that some password managers would insecurely fill in passwords for the http version of https-saved passwords] (USENIX), and most did not protect against iframe-based attacks. Fix: Advise users to verify URL protocols and implement additional verification steps for sensitive actions, even when using password managers.

Examples

Example scenario: The free trip fraud An attacker creates a page promising a free trip to Tahiti. In the background, the attacker checks if the user is logged into their banking site. If so, the attacker loads the bank's transfer page in an invisible iframe, aligning the "Confirm Transfer" button exactly over the "Book My Free Trip" button. When the user clicks to claim the vacation, they actually authorize a wire transfer to the attacker. The bank processes the request as legitimate because it comes from the user's authenticated session, making the attack untraceable.

Example scenario: Likejacking campaign distortion A social media marketer observes a sudden spike in Facebook likes for a campaign page, but conversion rates drop to zero. Investigation reveals likejacking: attackers embedded the campaign's like button invisibly over a viral "Personality Quiz" page. Users clicking "Start Quiz" actually liked the marketing page. This corrupted the campaign's audience data, wasted retargeting budget on users with no genuine interest, and risked platform penalties for artificial engagement.

Example scenario: Flash settings hijacking An attacker loads the Adobe Flash plugin settings page into an invisible iframe on a gaming site. The attacker aligns the "Allow" button for camera and microphone access over the "Start Game" button. When the user clicks to play, they actually grant the attacker permission to access their webcam and microphone through Flash settings. [This attack vector was discovered in 2008 by Grossman and Hansen] (SecTheory).

Example scenario: Nested frame bypass An attacker exploits a vulnerability in X-Frame-Options when set to SAMEORIGIN by inserting a malicious frame between two legitimate frames from the target site. This allows the attack to bypass the header protection that only checks the top and bottom layers, not intermediate frames, potentially exposing Google+ users or similar platforms to UI redressing.

FAQ

What is clickjacking? Clickjacking is a UI redress attack where an attacker tricks you into clicking on a hidden element by overlaying an invisible iframe on top of a legitimate-looking page. You think you are clicking a visible button, but you are actually performing an action on a hidden page, such as transferring money or changing security settings.

How does clickjacking differ from phishing? Phishing involves fake websites that mimic legitimate ones to steal credentials. Clickjacking uses the real legitimate website but hides it under an invisible layer. In phishing, you interact with a copy. In clickjacking, you interact with the real site without knowing it.

Can clickjacking impact my marketing analytics? Yes. Likejacking can inflate social engagement metrics with fake likes from users who never intended to interact with your content. This corrupts audience targeting data and wastes advertising spend. Additionally, unauthorized form submissions or purchases from clickjacking attacks pollute conversion funnels and attribution models.

What is the most effective way to prevent clickjacking? Implement the Content Security Policy (CSP) frame-ancestors directive set to 'none' or 'self' to prevent your site from being embedded in iframes on other domains. Complement this with the X-Frame-Options header for older browser support. These server-side controls are more reliable than client-side JavaScript framekillers.

Are password managers safe against clickjacking? No. [A 2014 paper from Carnegie Mellon University found that some password managers would insecurely fill in passwords for the http version of https-saved passwords] (USENIX), and most did not protect against iframe-based attacks. Users should verify URL protocols and implement additional verification steps for sensitive actions, even when using password managers.

How can I test if my website is vulnerable to clickjacking? Create an HTML page on a different domain that attempts to load your sensitive pages in an iframe. If the content loads without restrictions, your site is vulnerable. The OWASP Testing Guide provides specific code snippets for this verification. Test all pages that handle authentication, financial transactions, or personal data, not just the homepage.

Start Your SEO Research in Seconds

5 free searches/day • No credit card needed • Access all features