Clickjacking Explained: The Invisible Attack That Hijacks Your Clicks


Imagine clicking a "Play Video" button — and instead silently confirming a money transfer, changing your email address, or deleting your account. You never saw the real button. You never had a chance. That is clickjacking: one of the oldest UI tricks in web hacking, and still a valid bug bounty finding today.

How Clickjacking Works

The attacker builds a harmless-looking page — a game, a quiz, a video player — and loads the victim's real website inside an invisible iframe on top of it. The iframe is transparent and positioned so that its buttons sit exactly under the fake page's buttons. When you click what looks like "Claim Your Prize", your click passes through to the real button underneath. If you are logged in to the real site, the click performs a real action with your session. The attacker never needs your password — they borrow your clicks.

Classic targets are account settings pages: change email, change password, delete account, transfer funds, or "like" and "follow" actions on social platforms. The damage depends entirely on what the hidden button does.

Why It Still Works

Clickjacking needs no fancy exploit. It needs only two things: a site that allows itself to be framed, and a victim who clicks. That is why it survives every era of web security — the vulnerability is a missing header, and the attack is pure deception. Bug bounty programs still pay for it when it leads to a real impact, like account takeover or unauthorized actions.

How to Test for It (Your Sites Only)

Only test sites you own or have written permission to test. Create a test page that tries to frame your site:

<html>
  <body>
    <h1>Clickjacking test — my own site only</h1>
    <iframe src="https://your-own-site.com/settings" width="800" height="600"></iframe>
  </body>
</html>

If your site loads inside the iframe, it can be framed — and clickjacking is possible. If the browser refuses to load it, your framing protection is working.

How to Fix It

  • Send the X-Frame-Options header. X-Frame-Options: DENY blocks all framing; SAMEORIGIN allows only your own pages to frame you. Set it on every response from your server or CDN.
  • Use Content-Security-Policy frame-ancestors. Content-Security-Policy: frame-ancestors 'none' is the modern replacement and overrides X-Frame-Options where supported. Use both for maximum coverage.
  • Add frame-busting JavaScript as a backup layer, but never rely on it alone — it can be bypassed. Headers are the real fix.
  • Protect sensitive actions with re-authentication. Even if a click is hijacked, asking for the password again before changing an email or password stops the attack cold.

Defense in Depth

Clickjacking is a reminder that web security is not only about code — it is about what the user sees and trusts. Framing headers are a one-line fix, and there is no excuse for a modern site to miss them. Check your own sites today: if they load in an iframe, add the header. It takes five minutes and closes a bug class that has embarrassed companies for over a decade.

For bug bounty hunters, clickjacking is a great first find: easy to understand, easy to demonstrate, and a perfect lesson in how the browser's trust model can be turned against the user.

Comments

Popular Posts