What Is Clickjacking?
Clickjacking tricks a user into clicking something different from what they perceive, typically by overlaying an invisible malicious page on top of a legitim...
Published November 16, 2026
Clickjacking tricks a user into clicking something different from what they see by loading your site in a transparent iframe over a decoy page. Prevent it with the X-Frame-Options header or CSP frame-ancestors.
The concept
The attacker overlays an invisible iframe of your site (a 'Delete account' button) on top of a harmless-looking button. The user thinks they are clicking the decoy.
The defence is to tell browsers your pages must not be embedded by other origins.
Layers
top (invisible): <iframe src="bank.com/confirm"> [Confirm]
bottom (visible): evil page [Win a prize!]
user clicks 'prize' → actually clicks 'Confirm'
Practical examples
CSP (preferred)
Content-Security-Policy: frame-ancestors 'none'Legacy header
X-Frame-Options: DENYNginx
add_header Content-Security-Policy "frame-ancestors 'self'" always;Allow a trusted embedder
Content-Security-Policy: frame-ancestors https://partner.exampleCommon mistakes
- Relying on JavaScript frame-busting.
- Setting the header only on some pages.
- Allowing * in frame-ancestors.
Key takeaways
- Invisible iframe overlays trick clicks.
- Use frame-ancestors / X-Frame-Options.
- Apply to all responses.
FAQ
Can I still embed my own pages?
Yes, use frame-ancestors 'self'.
Is it still relevant?
Yes, whenever a page has sensitive one-click actions.