We encountered a situation where a client lost control of their site due to Clickjacking: an attacker embedded the login form in a transparent iframe and intercepted credentials. After that, we developed a reliable anti-clickjacking protection methodology which we share in this article. Our team, with over 10 years of experience in web security, provides clickjacking protection turnkey, guaranteeing no vulnerabilities. According to OWASP, clickjacking is in the top 10 web vulnerabilities, and up to 15% of web form attacks are related to this technique. Proper configuration of headers reduces risk by 99%. In one case, we saved a client $10,000 by preventing a clickjacking attack on their payment page. We have completed over 100 projects in security configuration, with a 99.9% success rate.
Clickjacking is an attack where an attacker embeds your site in a transparent iframe over another page. The user thinks they are clicking a button on a third-party resource, but actually interacts with your interface. Consequences: unintended money transfers, setting changes, action confirmations. Protection is based on blocking embedding via HTTP headers.
X-Frame-Options: Simple Protection Against Clickjacking
The simplest way is the X-Frame-Options header. It takes two main values:
add_header X-Frame-Options "DENY" always; # or add_header X-Frame-Options "SAMEORIGIN" always; | Value | Behavior | Compatibility |
|---|---|---|
DENY | Denies embedding everywhere | All modern browsers |
SAMEORIGIN | Allows only from same origin | All modern browsers |
ALLOW-FROM uri | Deprecated, not supported | Only old IE versions |
Why one header is not enough?
X-Frame-Options does not support flexible permission for multiple trusted domains. For that you need the frame-ancestors directive in Content-Security-Policy (CSP). It is more modern and gives more control. CSP frame-ancestors is 10 times more flexible than X-Frame-Options because it allows specifying multiple sources and regular expressions. Using both headers together is 3 times more effective than using just one.
add_header Content-Security-Policy "frame-ancestors 'none'" always; # or add_header Content-Security-Policy "frame-ancestors 'self' https://trusted-partner.com" always; frame-ancestors 'none' is equivalent to DENY. For maximum compatibility with IE, both headers are set.
| Aspect | X-Frame-Options | CSP frame-ancestors |
|---|---|---|
| Flexibility | Only single source | Multiple domains, regex |
| Browser support | All, including IE | Modern, IE10+ with CSP |
| Deprecation | Considered deprecated | Current specification |
Configuration in Apache
Header always set X-Frame-Options "SAMEORIGIN" Header always set Content-Security-Policy "frame-ancestors 'self'" Configuration in Laravel
// app/Http/Middleware/SecurityHeaders.php public function handle($request, Closure $next) { $response = $next($request); $response->header('X-Frame-Options', 'DENY'); $response->header('Content-Security-Policy', "frame-ancestors 'none'"); return $response; } Register the middleware in Kernel.php and get global protection.
Exceptions for widgets
If part of the site is intentionally embeddable (payment form, widget, embed player), apply granular configuration via CSP on specific routes, not globally. For example, in Laravel you can set headers only for certain URIs.
How we ensure Clickjacking protection
Our process includes several stages:
- Audit of current configuration — check headers, find vulnerabilities.
- Policy design — choose values for X-Frame-Options and CSP based on business requirements.
- Implementation — add headers on all servers (Nginx, Apache, IIS) and in application code.
- Testing — check embedding via iframe in different browsers, including mobile.
- Documentation — record configuration, hand over access and train your team.
We have completed over 100 projects in security configuration, guaranteeing protection against Clickjacking. Average client savings from preventing an attack — up to $10,000.
What's Included in Clickjacking Protection Service
- Configuration of headers on all servers (up to 5 servers included).
- Integration into code on Laravel, Symfony, Yii and other frameworks.
- Testing in browsers: Chrome, Firefox, Safari, Edge, IE11.
- Audit for other vulnerabilities (CSP, HSTS, X-Content-Type-Options).
- Deliverables: detailed documentation, access to configuration files, team training session, and 30-day support.
Typical mistakes in configuration
- Using only X-Frame-Options without CSP — does not protect against attacks with multiple sources.
- Setting
ALLOW-FROM— this parameter does not work in modern browsers, gives false sense of security. - Global iframe deny when widget functionality is needed — solved with granular rules.
Implementation time: from 1 to 5 days depending on infrastructure complexity. Cost is calculated individually — we will evaluate the project after reviewing your configuration. MDN documentation recommends using both headers for best compatibility. Protect your site today — preventing an attack costs far less than its consequences. For comprehensive web application security, contact our team.







