Homeglossary

Clickjacking

Clickjacking is a web security attack that tricks a user into clicking something different from what appears on screen. Attackers often place a transparent or disguised page element over a convincing decoy, causing an unintended action on a trusted site. It is also called UI redressing and primarily exploits unsafe page embedding rather than a flaw in the user's device.

Build safer web apps with Emergent.

What Is Clickjacking?

Clickjacking is a web security attack that tricks a user into clicking something different from what appears on screen. Also called UI redressing, it uses a hidden or transparent interface element over a convincing decoy, causing an unintended action on another site. It often abuses an already signed-in session to change a setting, approve access, or submit a form rather than automatically extracting device data.

The weakness is unsafe framing. If a sensitive page can appear inside another website's iframe, an attacker may place its controls beneath misleading content. Browsers and servers provide framing controls to reduce this risk.

How Does a Clickjacking Attack Work?

The attacker uses visual deception and a page that permits embedding.

  1. The attacker creates a decoy page, such as a video or prize offer.
  2. They load a target site in an iframe, if framing is allowed.
  3. They align a hidden target button beneath a visible decoy button.
  4. The user clicks the decoy, but the browser sends the click to the hidden control.
  5. A logged-in user may unknowingly approve a connected application or change an account preference.

Clickjacking vs. Phishing and Cross-Site Scripting

These attacks may look similar, but they exploit different weaknesses and need different defenses.

AttackTechniqueWhat the user seesPrimary control
ClickjackingHidden or disguised interface controlsA legitimate-looking decoyFrame restrictions
PhishingDeceptive messages or fake sitesA request to trust a sender or pageUser verification and email controls
Cross-site scriptingInjected script runs in a trusted siteOften no visible warningOutput encoding and content security policy

How to Prevent Clickjacking Vulnerabilities

Set prevention at the server response level, not through browser-side workarounds.

  • Use the Content-Security-Policy frame-ancestors directive as the primary defense, allowing only approved sites to frame a page.
  • Send X-Frame-Options as a legacy compatibility layer where appropriate.
  • Allowlist framing partners narrowly rather than permitting all origins.
  • Review account settings, payment flows, permission screens, and embedded forms as sensitive routes.
  • Add clear confirmation steps for high-impact actions. Do not rely on JavaScript frame-busting alone, as it is not a dependable primary defense.

How to Test for Clickjacking

Only test applications you own or have explicit permission to assess.

  1. List sensitive routes, including dashboards, authorization prompts, and account-management pages.
  2. Create a separate test origin and try loading each route in an iframe.
  3. Inspect response headers for frame-ancestors and X-Frame-Options.
  4. Verify that supported browsers refuse unauthorized framing.
  5. Add automated regression checks so new routes do not lose protection.

Clickjacking in Modern Web App Development

Teams should define framing policy early when building dashboards, forms, account pages, and third-party integrations. Secure app design and development treats embedding as an explicit product decision. When building an AI web app with Emergent, teams can describe security requirements, test sensitive flows, and review deployment settings. Build safer web apps with Emergent.

Start Building
on Emergent today
Start Building