Clickjacking Protection: X-Frame-Options & CSP Setup

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

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:

Frequently Asked Questions

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1414
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1285
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    980
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1240
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    982
  • image_bitrix-bitrix-24-1c_fixper_448_0.webp
    Website development for FIXPER company
    994

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:

  1. Audit of current configuration — check headers, find vulnerabilities.
  2. Policy design — choose values for X-Frame-Options and CSP based on business requirements.
  3. Implementation — add headers on all servers (Nginx, Apache, IIS) and in application code.
  4. Testing — check embedding via iframe in different browsers, including mobile.
  5. 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.