← All tracks
Web InfrastructureClickjacking10 labsIntermediate → Advanced6h practice

Clickjacking

The click was real; the page was not.

“The user clicked a prize button. The browser clicked an admin action.”

CWE-1021OWASP Top 10 A05:2021OWASP ASVS 14.4.3
The mental model
A frame turns someone else's UI into your attack surface. Ask whether a sensitive action can be embedded and disguised, and whether the server forbids framing.

HTML frames allow one origin to render another origin's page. Without X-Frame-Options or CSP frame-ancestors, an attacker can overlay a transparent iframe and route a real click into a privileged control.

The victim sees a legitimate page and performs a real click. The browser cannot tell that the visible control belongs to the attacker.

Threat model

What is actually at stake?

Before touching a payload, map the assets, the actors and the boundary that is supposed to protect them. A finding only becomes a vulnerability when you can connect the failed boundary to a real asset.

Assets

  • Administrative approvals
  • Refunds and payouts
  • Security settings and MFA
  • Data exports and impersonation

Actors

  • Attacker who can host a page
  • Malicious ad or social link
  • Compromised site embedding the target
  • Insider sending a crafted page

Trust boundaries

  • Target page to framing origin
  • Visible UI to actual click target
  • Single click to privileged action
  • Browser frame policy to server headers

Abuse cases

  • Frame an admin approval and overlay a prize button
  • Use opacity and positioning to hide the target
  • Trick a double click into a confirmation
  • Frame a sensitive settings page
  • Bypass a JavaScript frame-buster
PrerequisitesHTML iframes and the same-origin policyX-Frame-Options and CSP frame-ancestorsUI redress and multi-step confirmation
Request anatomy

Follow the decision, not the payload

Every family has a moment where trusted data becomes an authorization, parsing or state decision. Learn to point at that moment in the request path.

  1. 01

    Frame

    The attacker page loads the target in an iframe; the browser asks whether framing is allowed.

  2. 02

    Disguise

    The attacker overlays transparent or misleading content so the visible control differs from the target control.

  3. 03

    Click

    The victim clicks the attacker's page; the browser routes the click to the framed target.

  4. 04

    Action

    The target performs the privileged action with the victim's session.

  5. 05

    Impact

    The attacker achieves a state change without reading the response or stealing a token.

Case study

The invisible approval

Composite case study from public clickjacking disclosures
Context

A composite case based on common admin-console reviews: a refund approval page had no frame protection and completed with one click.

Discovery

A tester embedded the approval page in an iframe, placed a transparent overlay over the button, and clicked the bait. The refund was approved.

Impact

An attacker could approve refunds, grant roles or export data by convincing an administrator to click a harmless-looking page.

Root cause

The sensitive page lacked CSP frame-ancestors and X-Frame-Options, and the action required only one click.

Fix

Send frame-ancestors 'none' and X-Frame-Options: DENY, require confirmation for high-impact actions, and avoid one-click privileged controls.

Read it as a chain: discovery → failed decision → impact → fix. Then ask which link would have broken earliest.

Attacker lens

A repeatable testing sequence

  1. Find a sensitive action that needs one click.
  2. Check X-Frame-Options and CSP frame-ancestors.
  3. Build a framing page on a different origin.
  4. Disguise the click with an overlay and verify the action fires.
  5. Show the state change or data exposure.

Where smart people get fooled

  • X-Frame-Options: SAMEORIGIN is not protection against a different origin, but a missing header is worse.
  • A frame-busting JavaScript snippet can be bypassed or may not run.
  • CSP must include frame-ancestors; default-src does not cover framing.
  • A button that requires typing or a second confirmation is much harder to clickjack.
Detection engineering

What would the logs show?

A control is stronger when someone can see it fail. These signals are starting points for a detection rule, not a complete SIEM use case.

  • Sensitive pages loaded inside a cross-origin frame
  • CSP reports for frame-ancestors violations
  • A burst of approvals or exports after a user visits an external page
  • Clicks on high-impact controls with no preceding in-app navigation
  • Pages with no X-Frame-Options or frame-ancestors directive
Starter query
index=web sourcetype=app_logs action=admin.approve | stats count values(referer) by user_id, action | where count > 0 AND NOT match(referer,"^https://academy\.buggravity\.com/")
The defender's move

Fix the decision, then prove it stays fixed

  • Send Content-Security-Policy: frame-ancestors 'none' on sensitive pages.
  • Keep X-Frame-Options: DENY for legacy browsers.
  • Require confirmation or re-authentication for high-impact actions.
  • Design sensitive controls so a single blind click cannot complete them.
Vulnerable patternhttp
# Sensitive admin response
Content-Type: text/html
# No frame protection
Safer patternhttp
Content-Security-Policy: frame-ancestors 'none'
X-Frame-Options: DENY
Cache-Control: no-store

frame-ancestors is the modern control; X-Frame-Options is a legacy fallback. Use both on sensitive pages and require a deliberate confirmation for high-impact actions.

Regression tests a reviewer would ask for

Frame blocked

GivenA sensitive admin page

WhenAn attacker origin embeds it in an iframe

ThenThe browser refuses to render the frame

CSP directive

GivenThe page sends a CSP

WhenThe policy is inspected

Thenframe-ancestors 'none' is present, not only default-src

Legacy header

GivenAn older browser ignores CSP

WhenIt reads X-Frame-Options

ThenDENY prevents framing

Confirmation

GivenA high-impact action is framed

WhenThe user clicks once

ThenA second deliberate confirmation is required

False positives

What this finding is not

Strong testers kill their own findings before someone else does. These are the shortcuts that turn a real bug into a weak report — or a false alarm into a wasted escalation.

  • The page sets X-Frame-Options: SAMEORIGIN and the attacker is on a different origin: framing is blocked, so the basic attack fails.
  • A frame-buster script exists: test whether it runs before the click and whether it can be bypassed.
  • The iframe loads but the action needs a typed confirmation: a blind click is not enough.
  • CSP exists but lacks frame-ancestors: default-src does not protect framing; check the exact directive.
Working vocabulary

Terms you should be able to use precisely

Clickjacking
UI redress where a victim's click is routed to a different, often privileged, control.
iframe
An HTML element that embeds another browsing context inside a page.
frame-ancestors
A CSP directive naming which origins may frame the page.
X-Frame-Options
A legacy response header that can deny or restrict framing.
UI redress
Disguising the true target of a user interaction.
Frame buster
JavaScript intended to break out of a frame; it is not a reliable security control.
Interview drill

Answer these without reciting a payload

Why is X-Frame-Options: SAMEORIGIN not enough for a cross-origin attacker?

SAMEORIGIN blocks frames from other origins. It protects against the basic attack, but a missing header or a same-origin framing path can still be abused; frame-ancestors is more precise.

Does a frame-busting script fix clickjacking?

No. It can be bypassed with sandboxing, double framing or disabled JavaScript. Server headers are the reliable control.

How do you reduce clickjacking impact even if framing is possible?

Require a deliberate second confirmation, re-authentication or a non-click interaction for high-impact actions.

Knowledge check

Can you separate the mechanism from the payload?

Four questions, graded on the server. Answers and explanations are released only after you submit, and signed-in learners keep a best score.

4 questions
01What is the core mechanism of clickjacking?
02Which header most directly prevents framing?
03Why is default-src not enough?
04Which design reduces impact even if framing occurs?
الخلاصة الموسّعة
لماذا هذا مهم؟

Clickjacking لا تسرق جلسة؛ تستغل إطارًا شفافًا لتوجيه نقرة حقيقية إلى زر إداري. الحل الأساسي هو منع التأطير عبر CSP frame-ancestors وX-Frame-Options، وليس الاعتماد على JavaScript. وحتى مع الحماية، اجعل الإجراءات الحساسة تتطلب تأكيدًا واعيًا أو إعادة مصادقة، لأن النقرة الواحدة يجب ألا تكفي.

If the action requires two deliberate steps, does the clickjacking story still work?