In short
Clickjacking (or UI redressing) involves loading your site within an invisible frame (iframe) on a page controlled by the attacker, then tricking the victim into clicking on a decoy placed directly above a button on your site. Believing they are clicking on the visible page, the logged-in user is actually confirming an action on your site: changing a setting, deleting an account, or authorizing an app. Protection involves preventing your pages from being displayed within a third-party frame.
How the attack works
The attacker creates an attractive page (a game, a fake “Win a Prize” button) and embeds your application within a transparent iframe. They position the frame so that the clickable button on your site is located directly below their decoy. The click is sent to your application, along with the victim’s session and cookies.
The attack bypasses anti-CSRF tokens: it is the application’s actual page, with its genuine token, that sends the request.
How to Protect Against It
| Protection | Recommended value | Role |
|---|---|---|
| Content-Security-Policy | frame-ancestors 'none' (or 'self') | The modern method: specifies which sites are allowed to display the page in a frame |
| X-Frame-Options | DENY (or SAMEORIGIN) | The history header, which should be retained for older browsers |
| SameSite Cookies | Lax or Strict | Prevents the session cookie from being sent when the site is loaded in a third-party frame |
The `frame-ancestors` directive must be sent in an HTTP header; it is not recognized in a meta tag.
Frequently asked questions
Is my site at risk if it doesn’t have any sensitive buttons?
The risk is low for a purely showcase website. It becomes a real threat as soon as a logged-in area allows actions to be triggered with just one or two clicks. Preventing framing costs almost nothing and resolves the issue.
Sources
Find out where an attacker would get in.
Our AI agents actually attack your scope, fully automated, and hand you the proof of every vulnerability.
