What is clickjacking?
clickjackingClickjacking, also known as UI Redressing, is a sophisticated client-side attack where a malicious actor tricks a user into clicking on actionable content—such as buttons or links—on a hidden website, while the user believes they are interacting with a completely different, visible website.
The attack leverages the ability to embed external web pages within an <iframe>. The attacker creates a malicious page, embeds the target application (e.g., a banking site or an administration panel) inside a transparent iframe, and meticulously aligns it over deceptive visual elements. When the user attempts to click the visible "Claim Prize" button, they inadvertently execute a state-changing action, like transferring funds or granting permissions, on the hidden target site.
How X-Frame-Options works
The X-Frame-Options HTTP response header was introduced to provide a direct defense against clickjacking. It instructs the browser whether the current page is permitted to be rendered within a <frame>, <iframe>, <embed>, or <object>.
The header operates primarily on three directives:
DENY: This is the most secure setting. It instructs the browser to completely block the rendering of the page within any frame, regardless of the origin attempting the framing. This effectively eliminates the clickjacking risk.SAMEORIGIN: This directive allows the page to be framed, but only if the framing site shares the exact same origin (scheme, hostname, and port) as the page being framed. This is useful for applications that utilize iframes for internal architectural purposes.ALLOW-FROM uri: This directive attempted to allow framing from specific, explicitly trusted external origins. However, this directive is obsolete and deeply flawed.
Limitations of X-Frame-Options
While a critical stepping stone in web security, X-Frame-Options suffers from significant architectural limitations that hinder its application in modern, complex web environments.
- No Wildcards or Multiple Origins: The specification does not support wildcards (e.g.,
*.example.com) or lists of multiple allowed origins. This makes it impossible to securely authorize a distributed ecosystem of partner sites to frame your content using this header alone. - ALLOW-FROM Deprecated: The
ALLOW-FROMdirective was inconsistently implemented across browsers and is now entirely obsolete and ignored by modern browsers (including Chrome, Safari, and Firefox). Relying on it means deploying zero clickjacking protection for the vast majority of your user base.
CSP frame-ancestors as the modern replacement
To address the limitations of X-Frame-Options, the Content Security Policy (CSP) Level 2 specification introduced the frame-ancestors directive. This modern directive supersedes X-Frame-Options and provides granular, robust control over framing authorization.
Content-Security-Policy: frame-ancestors 'self' https://partner1.com https://*.partner2.net;
frame-ancestors supports multiple explicit domains, wildcards for subdomains, and precise scheme enforcement, providing the flexibility required by modern web architectures while maintaining rigorous security.
Comparison table: X-Frame-Options vs frame-ancestors
| Feature | X-Frame-Options | CSP frame-ancestors |
| :--- | :--- | :--- |
| Deny All Framing | DENY | frame-ancestors 'none' |
| Allow Same Origin | SAMEORIGIN | frame-ancestors 'self' |
| Allow Multiple Origins | Not Supported | Supported (https://a.com https://b.com) |
| Wildcard Subdomains | Not Supported | Supported (https://*.example.com) |
| Modern Browser Support| Full | Full |
| Status | Legacy/Fallback | Modern Standard |
Real clickjacking attack scenario
Consider a scenario where a SaaS platform provides an authenticated user settings page at /account/security.
An attacker crafts a malicious page at evil.com. They embed the SaaS settings page in an iframe with opacity: 0; position: absolute; z-index: 10;. They position this iframe such that the "Delete Account" button perfectly aligns with a highly visible, innocuous-looking button on evil.com labeled "Accept Cookies."
When an authenticated user visits evil.com and clicks "Accept Cookies," their browser registers a click on the hidden "Delete Account" button within the iframe, executing the destructive action seamlessly.
Callout: use both headers for maximum compatibility
Tip
For maximum browser compatibility, use both X-Frame-Options and CSP frame-ancestors. Modern browsers will prioritize the CSP directive, while older clients will fall back to X-Frame-Options.
Which pages actually need clickjacking protection
While applying protection globally is a valid defense-in-depth strategy, certain pages are critical targets and require absolute certainty in their framing defenses.
Pages at highest risk include:
- Authentication and registration endpoints (to prevent credential theft via overlay).
- Financial transaction and checkout flows.
- Account settings, password reset, and MFA configuration panels.
- Any interface that executes a state-changing action requiring user authorization.
Server configuration examples
Implementing clickjacking defenses requires configuring your web server or reverse proxy to emit the correct headers.
Nginx:
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Content-Security-Policy "frame-ancestors 'self';" always;
Apache:
Header always set X-Frame-Options "SAMEORIGIN"
Header always set Content-Security-Policy "frame-ancestors 'self';"
Testing clickjacking protection
Validating your defenses involves practical testing. You can create a simple local HTML file containing an iframe pointing to your target application:
<iframe src="https://your-application.com" width="800" height="600"></iframe>
When you open this file in a browser, a properly configured server will prevent the iframe from loading, and the browser's developer console will log an explicit error indicating that the framing was blocked by X-Frame-Options or CSP frame-ancestors.
How CyberFurl Helps
Automated monitoring. Zero manual work.
CyberFurl audits your HTTP response headers for X-Frame-Options and CSP frame-ancestors directives — flagging pages that are missing clickjacking protection or using the deprecated ALLOWALL value. For pages that handle sensitive actions (login, payment, account settings), CyberFurl specifically verifies that framing is denied, reducing the risk of overlay-based UI redressing attacks targeting your users.
